Skip to content

Commit 5bae8c7

Browse files
committed
Merge pull request #19 from TheJumpCloud/ts-updates-2018-10-13
API v1 and v2 updates 2018-10-13
2 parents 329ea34 + f296872 commit 5bae8c7

241 files changed

Lines changed: 20498 additions & 23079 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 134 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,121 +2,183 @@
22

33
### Description
44

5-
This repository contains the Python client code for the JumpCloud API v1 and v2.
6-
It also provides the tools to generate the client code from the API yaml files, using swagger-codegen.
7-
For detailed instructions on how to generate the code, see the [Contributing](CONTRIBUTING.md) section.
5+
This repository contains the Python client code for the JumpCloud API v1 and
6+
v2. It also provides the tools to generate the client code from the API YAML
7+
files, using Swagger Codegen. For detailed instructions on how to generate the
8+
code, see the [Contributing](CONTRIBUTING.md) section.
89

910
### Installing the Python Client
1011

11-
You can run the following pip commands in order to install the packages directly from Github:
12+
You can run the following `pip` commands in order to install the packages
13+
directly from GitHub:
14+
1215
```
1316
pip install git+https://github.com/TheJumpCloud/jcapi-python.git#subdirectory=jcapiv1
1417
pip install git+https://github.com/TheJumpCloud/jcapi-python.git#subdirectory=jcapiv2
1518
```
1619

17-
Alternatively you can also pull this repository and install manually:
18-
Change to the appropriate directory (jcapiv1 or jcapiv2) and then run the following command:
20+
Alternatively you can also pull this repository and install manually. Change to
21+
the appropriate directory (jcapiv1 or jcapiv2) and then run one of the
22+
following commands.
1923

2024
To install the package for the local user:
25+
2126
```
2227
$ python setup.py install --user
2328
```
29+
2430
To install the package for all users:
31+
2532
```
2633
$ sudo python setup.py install
2734
```
2835

2936
### Authentication and Authorization
3037

31-
All endpoints support authentication via API key: see the [Authentication and Authorization](https://docs.jumpcloud.com/2.0/authentication-and-authorization/authentication-and-authorization-overview) section in our API docs.
38+
All endpoints support authentication via API key: see the
39+
[Authentication & Authorization](https://docs.jumpcloud.com/2.0/authentication-and-authorization/authentication-and-authorization-overview)
40+
section in our API documentation.
3241

33-
Some Systems endpoints (in both API v1 and v2) also support the [System Context authorization](https://docs.jumpcloud.com/2.0/authentication-and-authorization/system-context) which allows an individual system to manage its information and resource associations.
42+
Some systems endpoints (in both API v1 and v2) also support
43+
[System Context Authorization](https://docs.jumpcloud.com/2.0/authentication-and-authorization/system-context)
44+
which allows an individual system to manage its information and resource
45+
associations.
3446

3547
### Usage Examples
3648

37-
For more detailed instructions, refer to each API's respective README file ([README for API v1](jcapiv1/README.md) and [README for API v2](jcapiv2/README.md)) and the generated docs under each folder.
49+
For more detailed instructions, refer to each API version's respective README
50+
file ([README for API v1](jcapiv1/README.md) and
51+
[README for API v2](jcapiv2/README.md)) and the generated documentation under
52+
each folder.
53+
54+
#### API v1 Example
3855

39-
#### API v1 example:
4056
```python
57+
"""JumpCloud API v1 example."""
58+
4159
import jcapiv1
4260
from jcapiv1.rest import ApiException
4361

44-
...
45-
content_type = 'application/json'
46-
accept = 'application/json'
47-
48-
# set up the configuration object with your API key for authorization:
49-
jcapiv1.configuration.api_key['x-api-key'] = '<YOUR_API_KEY>'
50-
51-
# instantiate the API object for the group of endpoints you need to use
52-
# for instance for Systemusers API:
53-
systemusersAPI = jcapiv1.SystemusersApi()
54-
55-
try:
56-
# make an API call to retrieve all systemusers:
57-
users = systemusersAPI.systemusers_list(content_type, accept)
58-
print(users)
59-
except ApiException as e:
60-
print("Exception when calling SystemusersApi->systemusers_list: %s\n" % e)
61-
62-
try:
63-
# make an API call to modify a specific user's last name:
64-
put_request = jcapiv1.Systemuserputpost()
65-
put_request.lastname = 'Updated Last Name'
66-
systemusersAPI.systemusers_put('<YOUR_SYSTEMUSER_ID>', content_type, accept, body=put_request)
67-
except ApiException as e:
68-
print("Exception when calling SystemusersApi->systemusers_put: %s\n" % e)
62+
API_KEY = "YOUR_API_KEY"
63+
SYSTEM_USER_ID = "YOUR_SYSTEM_USER_ID"
64+
SYSTEM_USER_EMAIL = "YOUR_SYSTEM_USER_EMAIL"
65+
SYSTEM_USER_USERNAME = "YOUR_SYSTEM_USER_USERNAME"
66+
67+
CONTENT_TYPE = "application/json"
68+
ACCEPT = "application/json"
69+
70+
# Set up the configuration object with your API key for authorization
71+
CONFIGURATION = jcapiv1.Configuration()
72+
CONFIGURATION.api_key['x-api-key'] = API_KEY
73+
74+
# Instantiate the API object for the group of endpoints you need to use,
75+
# for instance the system users API
76+
API_INSTANCE = jcapiv1.SystemusersApi(jcapiv1.ApiClient(CONFIGURATION))
77+
78+
def list_users():
79+
"""Make an API call to retrieve all system users."""
80+
try:
81+
users = API_INSTANCE.systemusers_list(CONTENT_TYPE, ACCEPT)
82+
print(users)
83+
except ApiException as err:
84+
print("Exception when calling SystemusersApi->systemusers_list: %s\n" % err)
85+
86+
def update_user():
87+
"""Make an API call to update a system user."""
88+
put_request = jcapiv1.Systemuserputpost(email=SYSTEM_USER_EMAIL, username=SYSTEM_USER_USERNAME)
89+
put_request.lastname = "Updated Last Name"
90+
91+
try:
92+
user = API_INSTANCE.systemusers_put(SYSTEM_USER_ID, CONTENT_TYPE, ACCEPT, body=put_request)
93+
print(user)
94+
except ApiException as err:
95+
print("Exception when calling SystemusersApi->systemusers_put: %s\n" % err)
96+
97+
if __name__ == "__main__":
98+
list_users()
99+
update_user()
100+
69101
```
70102

71-
#### API v2 example:
103+
#### API v2 Example
104+
72105
```python
106+
"""JumpCloud API v2 example."""
107+
73108
import jcapiv2
74109
from jcapiv2.rest import ApiException
75110

76-
...
77-
content_type = 'application/json'
78-
accept = 'application/json'
111+
API_KEY = "YOUR_API_KEY"
112+
113+
CONTENT_TYPE = "application/json"
114+
ACCEPT = "application/json"
115+
116+
# Set up the configuration object with your API key for authorization
117+
CONFIGURATION = jcapiv2.Configuration()
118+
CONFIGURATION.api_key['x-api-key'] = API_KEY
79119

80-
# set up the configuration object with your API key:
81-
jcapiv2.configuration.api_key['x-api-key'] = '<YOUR_API_KEY>'
120+
# Instantiate the API object for the group of endpoints you need to use,
121+
# for instance the user groups API
122+
API_INSTANCE = jcapiv2.UserGroupsApi(jcapiv2.ApiClient(CONFIGURATION))
82123

83-
# instantiate the API object for the group of endpoints you need to use
84-
# for instance for User Groups API:
85-
userGroupsAPI = jcapiv2.UserGroupsApi()
124+
def get_user_groups():
125+
"""Make an API call to retrieve all user groups."""
126+
try:
127+
user_groups = API_INSTANCE.groups_user_list(CONTENT_TYPE, ACCEPT)
128+
print(user_groups)
129+
except ApiException as err:
130+
print("Exception when calling UserGroupsApi->groups_user_list: %s\n" % err)
86131

87-
try:
88-
# make an API call to retrieve all user groups:
89-
userGroups = userGroupsAPI.groups_user_list(content_type, accept)
90-
print(userGroups)
91-
except ApiException as e:
92-
print("Exception when calling UserGroupsApi->groups_user_list: %s\n" % e)
132+
if __name__ == "__main__":
133+
get_user_groups()
93134

94135
```
95136

96-
#### System Context Authorization example:
137+
#### System Context Authorization Example
138+
97139
```python
140+
"""JumpCloud system context authorization example."""
141+
98142
import jcapiv2
99143
from jcapiv2.rest import ApiException
100144

101-
content_type = 'application/json'
102-
accept = 'application/json'
103-
system_id = '<YOUR_SYSTEM_ID>'
104-
105-
# set headers for the System Context Authorization:
106-
# for detailed instructions on how to generate these headers,
107-
# refer to: https://docs.jumpcloud.com/2.0/authentication-and-authorization/system-context
108-
sys_context_auth = 'Signature keyId="system/<YOUR_SYSTEM_ID>",headers="request-line date",algorithm="rsa-sha256",signature="<YOUR_SYSTEM_SIGNATURE>"'
109-
sys_context_date = 'Thu, 19 Oct 2017 17:27:57 GMT' # the current date on the system
110-
111-
# instantiate the API object for the group of endpoints you need to use
112-
# for instance for User Groups API:
113-
systemsAPI = jcapiv2.SystemsApi()
114-
115-
try:
116-
# list the system groups this system is a member of:
117-
# Note that we pass the System Context Authorization headers as the 'date' and 'authorization' parameters
118-
groups = systemsAPI.graph_system_member_of(system_id, content_type, accept, date=sys_context_date, authorization=sys_context_auth)
119-
print groups
120-
except ApiException as e:
121-
print("Exception when calling systemsAPI->graph_system_member_of: %s\n" % e)
145+
# Set headers for System Context Authorization. For detailed instructions on
146+
# how to generate these headers, refer to:
147+
# https://docs.jumpcloud.com/2.0/authentication-and-authorization/system-context
148+
SYSTEM_ID = "YOUR_SYSTEM_ID"
149+
# The current date on the system, e.g. "Thu, 09 Aug 1990 14:25:15 GMT"
150+
SYSTEM_DATE = "YOUR_SYSTEM_DATE"
151+
SYSTEM_SIGNATURE = "YOUR_SYSTEM_SIGNATURE"
152+
SYSTEM_CONTEXT_AUTH = (
153+
'Signature keyId="system/{}",'
154+
'headers="request-line date",'
155+
'algorithm="rsa-sha256",'
156+
'signature="{}"'
157+
).format(SYSTEM_ID, SYSTEM_SIGNATURE)
158+
159+
CONTENT_TYPE = "application/json"
160+
ACCEPT = "application/json"
161+
162+
# Set up the configuration object
163+
CONFIGURATION = jcapiv2.Configuration()
164+
165+
# Instantiate the API object for the group of endpoints you need to use,
166+
# for instance the systems API
167+
API_INSTANCE = jcapiv2.SystemsApi(jcapiv2.ApiClient(CONFIGURATION))
168+
169+
def get_system_groups():
170+
"""Make an API call to retrieve all system groups this system is a member of."""
171+
try:
172+
# Note the System Context Authorization headers are passed as arguments
173+
system_groups = API_INSTANCE.graph_system_member_of(
174+
SYSTEM_ID, CONTENT_TYPE, ACCEPT,
175+
date=SYSTEM_DATE, authorization=SYSTEM_CONTEXT_AUTH,
176+
)
177+
print(system_groups)
178+
except ApiException as err:
179+
print("Exception when calling systemsAPI->graph_system_member_of: %s\n" % err)
180+
181+
if __name__ == "__main__":
182+
get_system_groups()
183+
122184
```

config_v1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"packageName": "jcapiv1",
3-
"packageVersion": "1.1.0"
3+
"packageVersion": "1.2.0"
44
}

config_v2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"packageName": "jcapiv2",
3-
"packageVersion": "1.1.0"
3+
"packageVersion": "1.2.0"
44
}

jcapiv1/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
55

66
- API version: 1.0
7-
- Package version: 1.1.0
7+
- Package version: 1.2.0
88
- Build package: io.swagger.codegen.languages.PythonClientCodegen
99

1010
## Requirements.
@@ -160,7 +160,6 @@ Class | Method | HTTP request | Description
160160
- [SystemputAgentBoundMessages](docs/SystemputAgentBoundMessages.md)
161161
- [Systemslist](docs/Systemslist.md)
162162
- [Systemuser](docs/Systemuser.md)
163-
- [SystemuserAttributes](docs/SystemuserAttributes.md)
164163
- [Systemuserbinding](docs/Systemuserbinding.md)
165164
- [Systemuserbindingsput](docs/Systemuserbindingsput.md)
166165
- [Systemuserput](docs/Systemuserput.md)

jcapiv1/docs/Command.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Name | Type | Description | Notes
66
**name** | **str** | | [optional]
77
**command** | **str** | The command to execute on the server. |
88
**command_type** | **str** | The Command OS | [optional]
9-
**command_runners** | **list[str]** | an array of IDs of the Command Runner Users that can execute this command. | [optional]
9+
**command_runners** | **list[str]** | An array of IDs of the Command Runner Users that can execute this command. | [optional]
1010
**user** | **str** | The ID of the system user to run the command as. |
1111
**sudo** | **bool** | | [optional]
1212
**systems** | **list[str]** | An array of system IDs to run the command on. Not available if you are using Groups. | [optional]

jcapiv1/docs/CommandslistResults.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Name | Type | Description | Notes
99
**launch_type** | **str** | How the Command is executed. | [optional]
1010
**listens_to** | **str** | | [optional]
1111
**schedule** | **str** | A crontab that consists of: [ (seconds) (minutes) (hours) (days of month) (months) (weekdays) ] or [ immediate ]. If you send this as an empty string, it will run immediately. | [optional]
12-
**trigger** | **str** | trigger to execute command. | [optional]
12+
**trigger** | **str** | Trigger to execute command. | [optional]
1313
**schedule_repeat_type** | **str** | When the command will repeat. | [optional]
1414
**organization** | **str** | The ID of the Organization. | [optional]
1515
**id** | **str** | The ID of the command. | [optional]

jcapiv1/docs/OrganizationslistResults.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Properties
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
6-
**id** | **str** | the ID of the organization. | [optional]
6+
**id** | **str** | The ID of the organization. | [optional]
77
**display_name** | **str** | The name of the organization. | [optional]
88
**logo_url** | **str** | The organization logo image URL. | [optional]
99

jcapiv1/docs/Systemuser.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Name | Type | Description | Notes
2727
**associated_tag_count** | **int** | | [optional]
2828
**totp_enabled** | **bool** | | [optional]
2929
**password_expiration_date** | **str** | | [optional]
30-
**attributes** | [**list[SystemuserAttributes]**](SystemuserAttributes.md) | | [optional]
30+
**attributes** | **list[object]** | | [optional]
3131
**created** | **str** | | [optional]
3232
**samba_service_user** | **bool** | | [optional]
3333
**password_never_expires** | **bool** | | [optional]

jcapiv1/docs/SystemuserAttributes.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

jcapiv1/jcapiv1/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
from jcapiv1.models.systemput_agent_bound_messages import SystemputAgentBoundMessages
6868
from jcapiv1.models.systemslist import Systemslist
6969
from jcapiv1.models.systemuser import Systemuser
70-
from jcapiv1.models.systemuser_attributes import SystemuserAttributes
7170
from jcapiv1.models.systemuserbinding import Systemuserbinding
7271
from jcapiv1.models.systemuserbindingsput import Systemuserbindingsput
7372
from jcapiv1.models.systemuserput import Systemuserput

0 commit comments

Comments
 (0)