25
25
26
26
27
27
class CatalogController :
28
- """This is the main class that users will interact with to talk to catalogs.
28
+ """Class that users will interact with to work with catalogs.
29
29
30
30
An instance of this class is available in the
31
31
`client.ContainerPlatformClient` with the attribute name
@@ -43,13 +43,16 @@ def __init__(self, client):
43
43
self .client = client
44
44
45
45
def list (self ):
46
- """Retrieve a list of Catalogs
46
+ """Retrieve a list of Catalogs.
47
47
48
- Returns:
49
- CatalogList: list of Catalogs
48
+ Returns
49
+ -------
50
+ CatalogList
51
+ list of Catalogs
50
52
51
- Raises:
52
- APIException
53
+ Raises
54
+ ------
55
+ APIException
53
56
"""
54
57
response = self .client ._request (
55
58
url = "/api/v1/catalog/" ,
@@ -61,17 +64,21 @@ def list(self):
61
64
)
62
65
63
66
def get (self , catalog_id ):
64
- """Retrieve a catalog identified by {catalog_id}
67
+ """Retrieve a catalog identified by {catalog_id}.
65
68
66
- Args:
67
- catalog_id: str
68
- The Catalog ID - format: '/api/v1/catalog/[0-9]+'
69
+ Parameters
70
+ ----------
71
+ catalog_id: str
72
+ The Catalog ID - format: '/api/v1/catalog/[0-9]+'
69
73
70
- Raises:
71
- APIException
74
+ Returns
75
+ -------
76
+ Catalog
77
+ object representing the requested Catalog
72
78
73
- Returns:
74
- Catalog -- object representing the requested Catalog
79
+ Raises
80
+ ------
81
+ APIException
75
82
"""
76
83
assert isinstance (
77
84
catalog_id , str
@@ -88,19 +95,7 @@ def get(self, catalog_id):
88
95
89
96
90
97
class Catalog :
91
- """Create an instance of Catalog from json data returned from the HPE
92
-
93
- Container Platform API. Users of this library are not expected to create an
94
- instance of this class.
95
-
96
- Parameters:
97
- json : str
98
- The json returned by the API representing a Catalog.
99
-
100
- Returns:
101
- Catalog:
102
- An instance of Catalog
103
- """
98
+ """Catalog Image item."""
104
99
105
100
# All of the fields of Catalog objects as returned by the HPE Container
106
101
# Platform API.
@@ -133,6 +128,23 @@ class Catalog:
133
128
default_display_fields = all_fields
134
129
135
130
def __init__ (self , json ):
131
+ """Create a Catalog Image.
132
+
133
+ Parameters
134
+ ----------
135
+ json : str
136
+ The json returned by the API representing a Catalog.
137
+
138
+ Returns
139
+ -------
140
+ Catalog:
141
+ An instance of Catalog
142
+
143
+ Note
144
+ ----
145
+ Users of the library aren't expected to create instances of this class
146
+ directly.
147
+ """
136
148
self .json = json
137
149
self .display_columns = Catalog .default_display_fields
138
150
@@ -155,13 +167,15 @@ def __len__(self):
155
167
156
168
def set_display_columns (self , columns ):
157
169
"""Set the columns this instance should have when the instance is used
158
-
159
170
with :py:meth:`.CatalogList.tabulate`.
160
171
161
- Parameters:
162
- columns : list[str]
163
- Set the list of colums to return
172
+ Parameters
173
+ ----------
174
+ columns : list[str]
175
+ Set the list of colums to return
164
176
177
+ See Also
178
+ --------
165
179
See :py:attr:`all_fields` for the complete list of field names.
166
180
"""
167
181
self .display_columns = columns
@@ -185,14 +199,17 @@ def state(self):
185
199
186
200
187
201
class CatalogList :
188
- """List of :py:obj:`.Catalog` objects
202
+ """List of :py:obj:`.Catalog` objects.
189
203
190
- This class is not expected to be instantiated by users.
204
+ Parameters
205
+ ----------
206
+ json : str
207
+ json data returned from the HPE Container Platform API get request
208
+ to /api/v1/catalog
191
209
192
- Parameters:
193
- json : str
194
- json data returned from the HPE Container Platform API get request
195
- to /api/v1/catalog
210
+ Note
211
+ ----
212
+ This class is not expected to be instantiated by users.
196
213
"""
197
214
198
215
def __init__ (self , json ):
@@ -234,25 +251,30 @@ def tabulate(
234
251
style = "pretty" ,
235
252
display_headers = True ,
236
253
):
237
- """Provide a tabular represenation of the list of Catalogs
254
+ """Provide a tabular represenation of the list of Catalog images.
255
+
256
+ Parameters
257
+ ----------
258
+ columns : list[str]
259
+ list of columns to return in the table - default
260
+ :py:attr:`.Catalog.default_display_fields`
261
+ style: str
262
+ See: https://github.com/astanin/python-tabulate#table-format
238
263
239
- Parameters:
240
- columns : list[str]
241
- list of columns to return in the table - default
242
- :py:attr:`.Catalog.default_display_fields`
243
- style: str
244
- See: https://github.com/astanin/python-tabulate#table-format
264
+ Returns
265
+ -------
266
+ str
267
+ table output
245
268
246
- Returns:
247
- str : table output
269
+ Example
270
+ -------
271
+ Print the catalog list with all of the avaialble fields:
248
272
249
- Example::
273
+ >>> print(hpeclient.catalog.list().tabulate())
250
274
251
- # Print the catalog list with all of the avaialble fields
252
- print(hpeclient.catalog.list().tabulate())
275
+ Print the cluster list with a subset of the fields:
253
276
254
- # Print the cluster list with a subset of the fields
255
- print(hpeclient.catalog.list().tabulate(columns=['id', 'state']))
277
+ >>> print(hpeclient.catalog.list().tabulate(columns=['id', 'state']))
256
278
"""
257
279
if columns != Catalog .default_display_fields :
258
280
assert isinstance (
0 commit comments