36
36
37
37
38
38
class GatewayController :
39
- """This is the main class that users will interact with to work with
40
-
41
- Gateways. An instance of this class is available in the
39
+ """Class that users will interact with to work with Gateways. An instance
40
+ of this class is available in the
42
41
client.ContainerPlatformClient with the attribute name
43
42
:py:attr:`gateway <.client.ContainerPlatformClient.gateway>`. The methods
44
43
of this class can be invoked using `client.gateway.method()`. See the
45
44
example below:
46
45
47
- Example::
48
-
49
- client = ContainerPlatformClient(...).create_session()
50
- client.gateway.list()
51
-
46
+ Example
47
+ -------
48
+ >>> client = ContainerPlatformClient(...).create_session()
49
+ >>> client.gateway.list()
52
50
"""
53
51
54
52
def __init__ (self , client ):
@@ -62,22 +60,25 @@ def create_with_ssh_key(
62
60
self , ip , proxy_node_hostname , ssh_key_data , tags = []
63
61
):
64
62
"""Create a gateway instance using SSH key credentials to access the
65
-
66
63
host.
67
64
68
- Args:
69
- ip: str
70
- The IP address of the proxy host. Used for internal
71
- communication.
72
- proxy_node_hostname: str
73
- Clients will access cluster services will be accessed using
74
- this name.
75
- ssh_key_data: str
76
- The ssh key data as a string.
77
- tags: list
78
- Tags to use, e.g. "{ 'tag1': 'foo', 'tag2', 'bar' }".
79
-
80
- Returns: gateway ID
65
+ Parameters
66
+ ----------
67
+ ip: str
68
+ The IP address of the proxy host. Used for internal
69
+ communication.
70
+ proxy_node_hostname: str
71
+ Clients will access cluster services will be accessed using
72
+ this name.
73
+ ssh_key_data: str
74
+ The ssh key data as a string.
75
+ tags: list
76
+ Tags to use, e.g. "{ 'tag1': 'foo', 'tag2', 'bar' }".
77
+
78
+ Returns
79
+ -------
80
+ str
81
+ gateway ID
81
82
"""
82
83
83
84
assert isinstance (
@@ -110,13 +111,16 @@ def create_with_ssh_key(
110
111
return response .headers ["location" ]
111
112
112
113
def list (self ):
113
- """Retrieve a list of Gateways
114
+ """Retrieve a list of Gateways.
114
115
115
- Returns:
116
- GatewayList: list of Gateways
116
+ Returns
117
+ -------
118
+ GatewayList
119
+ list of Gateways
117
120
118
- Raises:
119
- APIException
121
+ Raises
122
+ ------
123
+ APIException
120
124
"""
121
125
response = self .client ._request (
122
126
url = "/api/v1/workers/" ,
@@ -128,15 +132,19 @@ def list(self):
128
132
def get (self , gateway_id ):
129
133
"""Retrieve a Gateway by ID.
130
134
131
- Args:
132
- gateway_id: str
133
- The gateway ID - format: '/api/v1/workers/[0-9]+'
135
+ Parameters
136
+ ----------
137
+ gateway_id: str
138
+ The gateway ID - format: '/api/v1/workers/[0-9]+'
134
139
135
- Returns:
136
- Gateway: object representing Gateway
140
+ Returns
141
+ -------
142
+ Gateway
143
+ object representing a Gateway
137
144
138
- Raises:
139
- APIException
145
+ Raises
146
+ ------
147
+ APIException
140
148
"""
141
149
assert isinstance (
142
150
gateway_id , str
@@ -163,12 +171,14 @@ def delete(self, gateway_id):
163
171
You can use :py:meth:`wait_for_status` to check for the gateway
164
172
state/existence.
165
173
166
- Args:
167
- gateway_id: str
168
- The Gateway ID - format: '/api/v1/workers/[0-9]+'
174
+ Parameters
175
+ ----------
176
+ gateway_id: str
177
+ The Gateway ID - format: '/api/v1/workers/[0-9]+'
169
178
170
- Raises:
171
- APIException
179
+ Raises
180
+ ------
181
+ APIException
172
182
"""
173
183
assert isinstance (
174
184
gateway_id , str
@@ -188,37 +198,45 @@ def delete(self, gateway_id):
188
198
def wait_for_delete (self , gateway_id , timeout_secs = 1200 ):
189
199
"""Wait for gateway to be deleted.
190
200
191
- Args:
192
- gateway_id: str
193
- The gateway ID - format: '/api/v1/workers/[0-9]+'
194
- timeout_secs: int
195
- How long to wait for the status(es) before raising an
196
- exception.
197
-
198
- Returns:
199
- bool: True if gateway was deleted before timeout, otherwise False
201
+ Parameters
202
+ ----------
203
+ gateway_id: str
204
+ The gateway ID - format: '/api/v1/workers/[0-9]+'
205
+ timeout_secs: int
206
+ How long to wait for the status(es) before raising an
207
+ exception.
208
+
209
+ Returns
210
+ -------
211
+ bool
212
+ True if gateway was deleted before timeout, otherwise False
200
213
"""
201
214
202
215
def wait_for_state (self , gateway_id , state = [], timeout_secs = 1200 ):
203
216
"""Wait for gateway state.
204
217
205
- Args:
206
- gateway_id: str
207
- The gateway ID - format: '/api/v1/workers/[0-9]+'
208
- status: list[:py:class:`GatewayStatus`]
209
- Status(es) to wait for. Use an empty array if you want to wait
210
- for a cluster's existence to cease.
211
- timeout_secs: int
212
- How long to wait for the status(es) before raising an
213
- exception.
214
-
215
- Returns:
216
- bool: True if status was found before timeout, otherwise False
217
-
218
- Raises:
219
- APIItemNotFoundException: if the item is not found and state is not
220
- empty
221
- APIException: if a generic API exception occurred
218
+ Parameters
219
+ ----------
220
+ gateway_id: str
221
+ The gateway ID - format: '/api/v1/workers/[0-9]+'
222
+ status: list[:py:class:`GatewayStatus`]
223
+ Status(es) to wait for. Use an empty array if you want to wait
224
+ for a cluster's existence to cease.
225
+ timeout_secs: int
226
+ How long to wait for the status(es) before raising an
227
+ exception.
228
+
229
+ Returns
230
+ -------
231
+ bool
232
+ True if status was found before timeout, otherwise False
233
+
234
+ Raises
235
+ ------
236
+ APIItemNotFoundException
237
+ if the item is not found and state is not empty
238
+ APIException
239
+ if a generic API exception occurred
222
240
"""
223
241
assert isinstance (
224
242
gateway_id , basestring
@@ -305,13 +323,15 @@ class Gateway:
305
323
Container Platform API. Users of this library are not expected to create an
306
324
instance of this class.
307
325
308
- Parameters:
309
- json : str
310
- The json returned by the API representing a Gateway.
326
+ Parameters
327
+ ----------
328
+ json : str
329
+ The json returned by the API representing a Gateway.
311
330
312
- Returns:
313
- Gateway:
314
- An instance of Gateway
331
+ Returns
332
+ -------
333
+ Gateway
334
+ An instance of Gateway
315
335
"""
316
336
317
337
# All of the fields of Gateway objects as returned by the HPE Container
@@ -368,10 +388,13 @@ def set_display_columns(self, columns):
368
388
369
389
with :py:meth:`.GatewayList.tabulate`
370
390
371
- Parameters:
372
- columns : list[str]
373
- Set the list of colums to return
391
+ Parameters
392
+ ----------
393
+ columns : list[str]
394
+ Set the list of colums to return
374
395
396
+ See Also
397
+ --------
375
398
See :py:attr:`all_fields` for the complete list of field names.
376
399
"""
377
400
self .display_columns = columns
@@ -450,17 +473,18 @@ def _links(self):
450
473
451
474
452
475
class GatewayList :
453
- """List of :py:obj:`.Gateway` objects
476
+ """List of :py:obj:`.Gateway` objects."""
454
477
455
- This class is not expected to be instantiated by users.
478
+ def __init__ (self , json ):
479
+ """Create a GatewayList. This class is not expected to be
480
+ instantiated by users.
456
481
457
- Parameters:
482
+ Parameters
483
+ ----------
458
484
json : str
459
485
json data returned from the HPE Container Platform API get request
460
486
to /api/v1/Gateway
461
- """
462
-
463
- def __init__ (self , json ):
487
+ """
464
488
self .json = [g for g in json if g ["purpose" ] == "proxy" ]
465
489
self .gateways = sorted (
466
490
[Gateway (g ) for g in json if g ["purpose" ] == "proxy" ],
@@ -500,25 +524,28 @@ def tabulate(
500
524
style = "pretty" ,
501
525
display_headers = True ,
502
526
):
503
- """Provide a tabular represenation of the list of Gateways
504
-
505
- Parameters:
506
- columns : list[str]
507
- list of columns to return in the table -
508
- default :py:attr:`.Gateway.default_display_fields`
509
- style: str
510
- See: https://github.com/astanin/python-tabulate#table-format
511
-
512
- Returns:
513
- str : table output
514
-
515
- Example::
516
-
517
- # Print the gateway list with all of the avaialble fields
518
- print(hpeclient.gateway.list().tabulate())
519
-
520
- # Print the cluster list with a subset of the fields
521
- print(hpeclient.gateway.list().tabulate(columns=['id', 'state']))
527
+ """Provide a tabular represenation of the list of Gateways.
528
+
529
+ Parameters
530
+ ----------
531
+ columns : list[str]
532
+ list of columns to return in the table -
533
+ default :py:attr:`.Gateway.default_display_fields`
534
+ style: str
535
+ See: https://github.com/astanin/python-tabulate#table-format
536
+
537
+ Returns
538
+ -------
539
+ str
540
+ table output
541
+
542
+ Example
543
+ -------
544
+ Print the gateway list with all of the avaialble fields
545
+ >>> print(hpeclient.gateway.list().tabulate())
546
+
547
+ Print the cluster list with a subset of the fields
548
+ >>> print(hpeclient.gateway.list().tabulate(columns=['id', 'state']))
522
549
"""
523
550
if columns != Gateway .default_display_fields :
524
551
assert isinstance (
0 commit comments