Organization
An organization key can access every project in your organization, so
an integration can work across your portfolio with a single
NovantClient.
Project and Organization Keys
NovantClient accepts either key type:
| Key Type | Prefix | Access |
|---|---|---|
| Project | ak_ |
A single project |
| Organization | ak_org_ |
Every project in the organization |
A project key is bound to its project, so calls do not need to
identify one. An organization key must name the project for every call
to a project method using proj_id. For more on key types,
see Authentication.
Targeting a Project
Every project method accepts an optional proj_id keyword
argument. Pass it per call to work with a different project on each
call:
client = NovantClient(api_key="ak_org_xxx")
zones = client.zones(proj_id=4821)
values = client.values(source_id="s.2", proj_id=5307)Or set a default proj_id on the client. A
proj_id passed to a method overrides the default for that
call:
client = NovantClient(api_key="ak_org_xxx", proj_id=4821)
zones = client.zones() # project 4821
annex = client.zones(proj_id=5307) # project 5307Every result returned by a project method includes the
proj_id of the project it came from:
print(zones.proj_id) # 4821Calling a project method with an organization key and no
proj_id raises a NovantErr with code
400. See Error
Handling.
Projects
Returns the projects in the organization. Requires an organization
key; calls made with a project key raise a NovantErr with
code 403.
org_projects()Returns
OrgProjectList with the following attribute:
| Attribute | Type | Description |
|---|---|---|
projects |
list[OrgProject] |
Projects in the organization |
Each OrgProject has:
| Attribute | Type | Description |
|---|---|---|
proj_id |
int |
Project ID |
proj_name |
str |
Project name |
city |
str |
Project city |
tz |
str |
Project timezone |
area |
int |
Project area, or None if not set |
Look up a single project by ID with
projects.project(proj_id), which returns None
if not found.
Example
client = NovantClient(api_key="ak_org_xxx")
# List every project in the organization
for p in client.org_projects():
print(p.proj_id, p.proj_name, p.city)
# Lookup by ID
proj = client.org_projects().project(4821)
print(proj.proj_name) # "Lumon Industries"
# Read zones across every project
for p in client.org_projects():
zones = client.zones(proj_id=p.proj_id)
print(p.proj_name, len(zones))