Resource¶
-
class
pysnow.resource.
Resource
(base_url=None, base_path=None, api_path=None, parameters=None, **kwargs)[source]¶ Creates a new
Resource
objectResources provides a natural way of interfacing with ServiceNow APIs.
Parameters: - base_path – Base path
- api_path – API path
- chunk_size – Response stream parser chunk size (in bytes)
- **kwargs – Arguments to pass along to
Request
-
get
(query, limit=None, offset=None, fields=[])[source]¶ Queries the API resource
Parameters: - query – Dictionary, string or
QueryBuilder
object - limit – (optional) Limits the number of records returned
- fields – (optional) List of fields to include in the response created_on in descending order.
- offset – (optional) Number of records to skip before returning records
Returns: Response
object
- query – Dictionary, string or
-
create
(payload)[source]¶ Creates a new record in the API resource
Parameters: payload – Dictionary containing key-value fields of the new record Returns: - Dictionary of the inserted record
-
update
(query, payload)[source]¶ Updates a record in the API resource
Parameters: - query – Dictionary, string or
QueryBuilder
object - payload – Dictionary containing key-value fields of the record to be updated
Returns: - Dictionary of the updated record
- query – Dictionary, string or
-
delete
(query)[source]¶ Deletes matching record
Parameters: query – Dictionary, string or QueryBuilder
objectReturns: - Dictionary containing information about deletion result
-
request
(method, path_append=None, headers=None, **kwargs)[source]¶ Create a custom request
Parameters: - method – HTTP method to use
- path_append – (optional) relative to
api_path
- headers – (optional) Dictionary of headers to add or override
- kwargs – kwargs to pass along to
requests.Request
Returns: Response
object