Model

class snow.resource.Resource(schema_cls: Union[Type[snow.resource.schema.Schema], snow.resource.schema.Schema], app)[source]

ServiceNow API Resource Model

Parameters:
config

Application config

Type:ConfigSchema
url

API URL

fields

Schema fields

create(payload)[source]

Create a new record

Parameters:payload (dict) – New record payload
Returns:Created record
Return type:dict
delete(selection)[source]

Delete matching record

Parameters:selection – Condition or ID
Returns:{“result”: <status>}
Return type:dict
get(selection=None, **kwargs) → dict[source]

Buffered many

Fetches data and stores in buffer.

Note: It’s recommended to use the stream method when dealing with large number of records.

Keyword Arguments:
 
  • selection – Snow compatible query
  • limit (int) – Maximum number of records to return
  • offset (int) – Starting record index
Returns:

Records

Return type:

list

get_object_id(value)[source]

Get object id by str or Condition

Immediately return if value is str.

Parameters:value – Condition or str
Returns:Object id
Return type:str
get_one(selection=None)[source]

Get one record

Parameters:selection – Snow compatible query
Returns:Record
Return type:dict
get_pk_value(selection)[source]

Given a selection, return the resulting record’s PK field’s value

Parameters:selection – Snow compatible query
Returns:PK field’s value
Return type:str
stream(selection=None, **kwargs) → Iterable[T_co][source]

Stream-like async generator

Fetches data in chunks using the ServiceNow pagination system.

Chunk size determines the number of records to fetch in one go, and can be tweaked to

Keyword Arguments:
 
  • selection – Snow compatible query
  • limit (int) – Maximum number of records to return
  • offset (int) – Starting record index
  • chunk_size (int) – Number of records to fetch in one go
Yields:

list – Chunk of records

update(selection, payload) → dict[source]

Update matching record

Parameters:
  • selection – Condition or ID
  • payload (dict) – Update payload
Returns:

Updated record

Return type:

dict