Resource

class pysnow.resource.Resource(base_url=None, base_path=None, api_path=None, parameters=None, **kwargs)[source]

Creates a new Resource object

Resources 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
path

Get current path relative to base URL

Returns:resource path
attachments

Provides an Attachment API for this resource. Enables easy listing, deleting and creating new attachments.

Returns:Attachment object

Provides full URL to the provided sys_id

Parameters:sys_id – sys_id to generate URL for
Returns:full sys_id URL
get(query, limit=None, offset=None, fields=[], stream=False)[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
  • stream – Whether or not to use streaming / generator response interface
Returns:

  • Response object

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

delete(query)[source]

Deletes matching record

Parameters:query – Dictionary, string or QueryBuilder object
Returns:
  • 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