@@ -319,14 +319,14 @@ def share_endpoint(self,recipient,endpoint_id):
319
319
)
320
320
321
321
def get_resource (self , type : str , id : str , accept : str = None ):
322
- """return an object describing an entity
322
+ """Return an object describing a resource entity.
323
+
323
324
:param type: required string of the singular of an entity type e.g. network, endpoint, service, edge-router, edge-router-policy, posture-check
324
325
:param id: the UUID of the entity if not a network
325
326
:param: accept: optional modifier string specifying the form of the desired response. Choices ["create","update"] where
326
327
"create" is useful for comparing an existing entity to a set of properties that are used to create the same type of
327
328
entity in a POST request, and "update" may be used in the same way for a PUT update.
328
329
"""
329
-
330
330
# to singular if plural
331
331
if type [- 1 ] == "s" :
332
332
type = singular (type )
@@ -369,6 +369,14 @@ def get_resource(self, type: str, id: str, accept: str=None):
369
369
entity = json .loads (response .text )
370
370
except :
371
371
raise Exception ('ERROR parsing response as object, got:\n {}' .format (response .text ))
372
+ else :
373
+ raise Exception (
374
+ 'ERROR: got unexpected HTTP code {:s} ({:d}) and response {:s}' .format (
375
+ STATUS_CODES ._codes [response_code ][0 ].upper (),
376
+ response_code ,
377
+ response .text
378
+ )
379
+ )
372
380
373
381
# routers are a special case because the value of entity._embedded.host.dataCenterId is expected by
374
382
# downstream consumers of this method to be found at entity.dataCenterId
@@ -382,7 +390,8 @@ def get_resource(self, type: str, id: str, accept: str=None):
382
390
return (entity )
383
391
384
392
def get_resources (self , type : str ,name : str = None , accept : str = None , deleted : bool = False , typeId : str = None ):
385
- """return the resources object
393
+ """Find resources by type.
394
+
386
395
:param str type: plural of an entity type e.g. networks, endpoints, services, posture-checks, etc...
387
396
:param str name: filter results by name
388
397
:param str accept: specifying the form of the desired response. Choices ["create","update"] where
@@ -391,7 +400,6 @@ def get_resources(self, type: str,name: str=None, accept: str=None, deleted: boo
391
400
:param bool deleted: include resource entities that have a non-null property deletedAt
392
401
:param str typeId: filter results by typeId
393
402
"""
394
-
395
403
# pluralize if singular
396
404
if not type [- 1 ] == "s" :
397
405
type = plural (type )
0 commit comments