Ejemplo n.º 1
0
 def setUp(self):
     self.curr_dir = os.path.dirname(os.path.abspath(__file__))
     with open(os.path.join(self.curr_dir, "..",
                            'basic-auth.json')) as data_file:
         user, password = json.load(data_file)
     self._setup_mocking()
     self.client = Client("https://booboo.service-now.com", user, password)
Ejemplo n.º 2
0
def build_query():
    qb = QueryBuilder()
    start = datetime.strptime('2015-11-17 00:00:00', "%Y-%m-%d %H:%M:%S")
    end = datetime.strptime('2015-11-20 23:59:59', "%Y-%m-%d %H:%M:%S")
    qb.between(start, end)
    qb.orderbydesc("sys_created_on")
    return qb.return_query


# set up the creds in ~/.snow-auth.json with ['user', 'pass']
with open(os.path.join(os.path.expanduser("~"),
                       ".snow-auth.json")) as data_file:
    user, password = json.load(data_file)

# set up the client with the correct URL
client = Client("https://your-sandbox.service-now.com", user, password)

pp = pprint.PrettyPrinter(indent=4)

# use whatever table name is appropriate...
recent_incidents = client.list("incident",
                               sysparm_limit=1000,
                               sysparm_query=build_query())

pp.pprint("dates of incidents found:")
pp.pprint(list(map(lambda x: x.sys_created_on, recent_incidents)))

a_record = random.choice(recent_incidents)
a_record_attrs = a_record.__dict__

# do things with ze data
Ejemplo n.º 3
0
import os
import json
import pprint
from snowclient.client import Client
from snowclient.querybuilder import QueryBuilder

# set up the client with the correct URL
with open(os.path.join(os.path.expanduser("~"),
                       ".snow-auth.json")) as data_file:
    user, password = json.load(data_file)
client = Client("https://boobooservicecloudopsstg.service-now.com", user,
                password)

pp = pprint.PrettyPrinter(indent=4)
a = client.api

## catalogs are the big picture "service catalogs" in the system.
## in our case, 1-1 snow system.
#catalogs = a.catalog_api.catalogs()
#
#pp.pprint("catalogs found:")
#pp.pprint(list(map(lambda x: [x.title, x.sys_id], catalogs)))
#
#catalog = a.catalog_api.catalog(catalogs[0].sys_id)
#
#pp.pprint("specific catalog found:")
#pp.pprint(catalog.__dict__)
#
#catalog_id = catalogs[0].sys_id
#
## categories are where groups of items are stored.