jcapi-python's People
Forkers
mr-brody rkelleyfrtw rcnobles ahendrickson-jc perlchild ninjastic-ninja vbexpert kkirklandjc jhuzetrackvia ctrinh98 richkifvel jfisher94002 smxzi maorweisssv itc-gumgum ansariyusoff cmichelngt chad-larsen-rapid sujala feimingjcapi-python's Issues
Group
Hi,
I am trying to use the groupsApi for jumpcloud api version2. I've noticed for a few APIs there is a results attribute tied to the returned values. This is good because I can essentially know how many entries exist and can paginate through the results until I reach the end.
For the groups API, I could not find the same. It looks like the datatype returned is a list and only 100 results can be returned in a given API call. This force you to guess how many groups there are. I can compare the current groups to what I have in the console but would like to see if there was another way to perform this action or to file this as a feature improvement for the amount of total entries to be returned in the api call. Below is my code snippet. Thanks!
from __future__ import print_function
import time
import jcapiv2
from jcapiv2.rest import ApiException
from pprint import pprint
import os
# Configure API key authorization: x-api-key
configuration = jcapiv2.Configuration()
configuration.api_key['x-api-key'] = os.environ['jc_api_key']
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['x-api-key'] = 'Bearer'
# create an instance of the API class
api_instance = jcapiv2.GroupsApi(jcapiv2.ApiClient(configuration))
content_type = 'application/json' # str | (default to application/json)
accept = 'application/json' # str | (default to application/json)
fields = ['[]'] # list[str] | The comma separated fields included in the returned records. If omitted, the default list of fields will be returned. (optional) (default to [])
#filter = ['[]'] # list[str] | Supported operators are: eq, ne, gt, ge, lt, le, between, search, in (optional) (default to [])
#limit = 100 # int | The number of records to return at once. Limited to 100. (optional) (default to 10)
#skip = 0 # int | The offset into the records to return. (optional) (default to 0)
sort = ['[]'] # list[str] | The comma separated fields used to sort the collection. Default sort is ascending, prefix with `-` to sort descending. (optional) (default to [])
#x_org_id = '' # str | (optional) (default to )
api_response = api_instance.groups_list(content_type, accept, limit=100)
print(type(api_response))
<class 'list'>
Attributes not returned by graph_system_associations_list
When listing system associations attributes are not returned.
Steps to reproduce is to follow example in documentation.
Curl returns attributes:
curl -X GET https://console.jumpcloud.com/api/v2/systems/{System_ID}/associations?targets=user -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'x-api-key: {API_KEY}'
SDK returns objects without attributes:
from __future__ import print_function
import jcapiv2
from jcapiv2.rest import ApiException
from pprint import pprint
configuration = jcapiv2.Configuration()
configuration.api_key['x-api-key'] = '{API_KEY}'
api_instance = jcapiv2.GraphApi(jcapiv2.ApiClient(configuration))
system_id = '{System_ID}' # str | ObjectID of the System.
content_type = 'application/json' # str | (default to application/json)
accept = 'application/json' # str | (default to application/json)
targets = ['user'] # list[str] |
try:
# List the associations of a System
api_response = api_instance.graph_system_associations_list(
system_id, content_type, accept, targets)
pprint(api_response)
except ApiException as e:
print("Exception when calling GraphApi->graph_system_associations_list: %s\n" % e)
bulk_users_create API does not work
I'm trying to create users with the bulk_users_create
API in the jcapi2
library. My test script runs without error however the user(s) is not created on our jumpcloud service.
Script:
from __future__ import print_function
import jcapiv2
from jcapiv2.rest import ApiException
from pprint import pprint
# Configure API key authorization: x-api-key
configuration = jcapiv2.Configuration()
configuration.api_key['x-api-key'] = 'XXXXXXXXXXXXXXXXXX'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['x-api-key'] = 'Bearer'
# create an instance of the API class
api_instance = jcapiv2.BulkJobRequestsApi(jcapiv2.ApiClient(configuration))
content_type = 'application/json' # str | (default to application/json)
accept = 'application/json' # str | (default to application/json)
x_org_id = '' # str | (optional) (default to )
body = [
{
"email": "[email protected]",
"username": "shunt",
"firstname": "Sally",
"lastname": "Hunt"
}
]
try:
# Bulk Users Create
api_response = api_instance.bulk_users_create(content_type, accept, body=body, x_org_id=x_org_id)
pprint(api_response)
except ApiException as e:
print("Exception when calling BulkJobRequestsApi->bulk_users_create: %s\n" % e)
Execution:
python ./test.py
{'job_id': '5da4cf6113973a47cc6862fa'}
The 'list_users' from API v1 Example should at least provide jq parse able output
Currently it just returns single quoted json which is not useable with common json tools
Missing documentation on running commands
There appears to be a lack of information regarding how to run a command on your documentation https://docs.jumpcloud.com/1.0/commands/QhvaHddE3MvJpE55i
I presume you need to specify the command ID though I tried passing it in through the URL and through the POST data with no success. This doesn't appear to be a feature in V2 of the API https://docs.jumpcloud.com/2.0/commands.
What I'm trying to do is, given a specific command ID, I want to run that command.
How to get a list of all jumpcloud users?
How do I get a list of all jumpcloud users using the systems_list
[1] python api? It looks like the number of records returned is limited to 100.
limit = 10 # int | The number of records to return at once. Limited to 100. (optional) (default to 10)
I get an error when requesting more than 100
{"message":"Bad Request: request parameter \"limit\" exceeds maximum value of 100"}
when i request 1 record it works, it returns info about that single record but no meta data on whether there's more records in the system. How do i get a complete list of all jumpcloud users?
[1] https://github.com/TheJumpCloud/jcapi-python/blob/master/jcapiv1/docs/SystemsApi.md#systems_list
jcapiv2/models/systemuser_attributes.py is broken
@thinkterry This file was not fully generated by Swagger and is now erroring out because of syntax issues, e.g.:
def __init__(self, =None):
"""
SystemuserAttributes - a model defined in Swagger
"""
self._ = None
if is not None:
self. =
@property
def (self):
"""
Gets the of this SystemuserAttributes.
:return: The of this SystemuserAttributes.
:rtype: str
"""
return self._
@.setter
def (self, ):
"""
Sets the of this SystemuserAttributes.
:param : The of this SystemuserAttributes.
:type: str
"""
self._ =
How to format "filter" (fix or add documentation)
I'm trying to use the SystemusersApi.systemusers_list()
method to get a list of all users in a system.
I have managed to use the filter
parameter successfully, with a string like the following: system_users_api.systemusers_list(content_type='application/json', accept='application/json', filter='firstname:David')
. This successfully produces the expected behavior of returning all users with the first name of David.
The issue is: I came up with that string value for the filter
parameter purely by trial-and-error. Also, I can't get it to work filtering multiple fields. I've tried several JSON-based solutions and nothing seems to work. I've seen examples of what to put in the filter
parameter in the general (non-Python specific) API documentation (see this ), but I can't draw a connection to the filter
parameter in the Python API. The Python API documentation pretty consistently describes the filter
parameter (unhelpfully) as simply a "A filter to apply to the query."
CommandResult object has wrong definition for timestamps
request_time
and response_time
are defined as integers in the models: https://github.com/TheJumpCloud/jcapi-python/blob/master/jcapiv1/jcapiv1/models/commandresult.py#L43
It seems the server returns strings:
Traceback (most recent call last):
File "test_jc_cmd.py", line 61, in <module>
test()
File "test_jc_cmd.py", line 27, in test
api_response = api_instance.command_results_list(content_type, accept, fields=fields, limit=limit, skip=skip, sort=sort)
File "/home/dpinte/.edm/envs/testpy3/lib/python3.5/site-packages/jcapiv1/apis/command_results_api.py", line 327, in command_results_list
(data) = self.command_results_list_with_http_info(content_type, accept, **kwargs)
File "/home/dpinte/.edm/envs/testpy3/lib/python3.5/site-packages/jcapiv1/apis/command_results_api.py", line 426, in command_results_list_with_http_info
collection_formats=collection_formats)
File "/home/dpinte/.edm/envs/testpy3/lib/python3.5/site-packages/jcapiv1/api_client.py", line 326, in call_api
_return_http_data_only, collection_formats, _preload_content, _request_timeout)
File "/home/dpinte/.edm/envs/testpy3/lib/python3.5/site-packages/jcapiv1/api_client.py", line 161, in __call_api
return_data = self.deserialize(response_data, response_type)
File "/home/dpinte/.edm/envs/testpy3/lib/python3.5/site-packages/jcapiv1/api_client.py", line 239, in deserialize
return self.__deserialize(data, response_type)
File "/home/dpinte/.edm/envs/testpy3/lib/python3.5/site-packages/jcapiv1/api_client.py", line 279, in __deserialize
return self.__deserialize_model(data, klass)
File "/home/dpinte/.edm/envs/testpy3/lib/python3.5/site-packages/jcapiv1/api_client.py", line 629, in __deserialize_model
kwargs[attr] = self.__deserialize(value, attr_type)
File "/home/dpinte/.edm/envs/testpy3/lib/python3.5/site-packages/jcapiv1/api_client.py", line 257, in __deserialize
for sub_data in data]
File "/home/dpinte/.edm/envs/testpy3/lib/python3.5/site-packages/jcapiv1/api_client.py", line 257, in <listcomp>
for sub_data in data]
File "/home/dpinte/.edm/envs/testpy3/lib/python3.5/site-packages/jcapiv1/api_client.py", line 279, in __deserialize
return self.__deserialize_model(data, klass)
File "/home/dpinte/.edm/envs/testpy3/lib/python3.5/site-packages/jcapiv1/api_client.py", line 629, in __deserialize_model
kwargs[attr] = self.__deserialize(value, attr_type)
File "/home/dpinte/.edm/envs/testpy3/lib/python3.5/site-packages/jcapiv1/api_client.py", line 271, in __deserialize
return self.__deserialize_primitive(data, klass)
File "/home/dpinte/.edm/envs/testpy3/lib/python3.5/site-packages/jcapiv1/api_client.py", line 557, in __deserialize_primitive
return klass(data)
ValueError: invalid literal for int() with base 10: '2017-12-13T23:56:55.000Z'
Unable to get complete set of Database Attributes for an Application using the applications_get api
I want to get the "databaseAttributes" of a AWS SAML2 application using the JumpCloud api - applications_get by passing a particular application_id.
The response contains only 1 parameter - position.
{'position': 1}
But when the same application is queried via postman,a detailed response is received.
GET - https://console.jumpcloud.com/api/applications/<my_application_id>
"databaseAttributes": {
"label": "USER ATTRIBUTES MAPPING:",
"readOnly": false,
"toggle": null,
"tooltip": {
"template": "Dynamic",
"variables": {
"icon": "jc-info-circle",
"message": "(Optional) Configure any user-specific attributes to be sent to the service provider. The value specified must directly reflect the JumpCloud system user property name (e.g., email, firstname, lastname). See the Knowledge Base for exact JumpCloud property names."
}
},
"type": "constantAttributes",
"value": [
{
"name": "https://aws.amazon.com/SAML/Attributes/Role",
"value": "SandboxDevelopers",
"required": false,
"visible": true,
"readOnly": false
},
{
"name": "https://aws.amazon.com/SAML/Attributes/Role",
"value": "SandboxAdministrators",
"required": false,
"visible": true,
"readOnly": false
}
],
"visible": true,
"options": null,
"dependsOnProperty": null,
"mutable": true,
"required": null,
"position": 1
},
Can some one please suggest a solution?
publish libraries to pypi
We are building a jumpcloud CLI on top of the jcapi-python libraries. Our app contains dependencies to your libraries in setup.py. The jcapi-python dependencies will install fine from a local checkout however it will fail when installing directly from pypi with error message ERROR: Packages installed from PyPI cannot depend on packages which are not also hosted on PyPI
. The problem is that the jcapi-python libraries have not been deployed to pypi. As per pip issue pypa/pip#6301 the only fix for this is to deploy your jcapi-python libraries to pypi. Would it be possible for you guys to deploy both versions (v1 and v2) of this library to pypi?
instaling from local checkout works fine:
git clone https://github.com/Sage-Bionetworks/jccli.git
cd jccli
pip install .
➜ pip freeze
certifi==2019.9.11
Click==7.0
jcapiv1==3.3.0
jcapiv2==3.3.0
jccli==0.0.5
python-dateutil==2.8.1
PyYAML==5.1.2
six==1.13.0
urllib3==1.25.6
however installing directly from pypi fails:
➜ pip install jccli
Collecting jccli
Downloading https://files.pythonhosted.org/packages/62/a2/22100582d8c3299772ea11acdff21f04753f490bf2d2908214323958fa5d/jccli-0.0.5.tar.gz
ERROR: Packages installed from PyPI cannot depend on packages which are not also hosted on PyPI.
jccli depends on jcapiv1@ git+https://github.com/TheJumpCloud/[email protected]#subdirectory=jcapiv1
Issues when using jcapiv1.SystemusersApi(jcapiv1.ApiClient(configuration)) on AWS Lambda
Hello,
I am able to use the script below successfully when deployed locally on my computer:
configuration = jcapiv1.Configuration() configuration.api_key['x-api-key'] = jumpcloud_apikey # create an instance of the API class api_instance = jcapiv1.SystemusersApi(jcapiv1.ApiClient(configuration)) content_type = 'application/json' # str | (default to application/json) accept = 'application/json' # str | (default to application/json) x_org_id = jumpcloud_org_id # str | (optional) (default to ) body = jcapiv1.Systemuserputpost( email='[email protected]', username='jdoe', firstname='John', lastname='Doe' ) api_response = api_instance.systemusers_post(content_type, accept, body=body, x_org_id=x_org_id)
When I use the script on AWS Lambda I get the following error:
{
"errorMessage": "[Errno 38] Function not implemented",
"errorType": "OSError",
"stackTrace": [
" File "/var/task/lambda_function.py", line 17, in lambda_handler\n api_instance = jcapiv1.SystemusersApi(jcapiv1.ApiClient(configuration))\n",
" File "/opt/python/lib/python3.8/site-packages/jcapiv1/api_client.py", line 69, in init\n self.pool = ThreadPool()\n",
" File "/var/lang/lib/python3.8/multiprocessing/pool.py", line 925, in init\n Pool.init(self, processes, initializer, initargs)\n",
" File "/var/lang/lib/python3.8/multiprocessing/pool.py", line 196, in init\n self._change_notifier = self._ctx.SimpleQueue()\n",
" File "/var/lang/lib/python3.8/multiprocessing/context.py", line 113, in SimpleQueue\n return SimpleQueue(ctx=self.get_context())\n",
" File "/var/lang/lib/python3.8/multiprocessing/queues.py", line 336, in init\n self._rlock = ctx.Lock()\n",
" File "/var/lang/lib/python3.8/multiprocessing/context.py", line 68, in Lock\n return Lock(ctx=self.get_context())\n",
" File "/var/lang/lib/python3.8/multiprocessing/synchronize.py", line 162, in init\n SemLock.init(self, SEMAPHORE, 1, 1, ctx=ctx)\n",
" File "/var/lang/lib/python3.8/multiprocessing/synchronize.py", line 57, in init\n sl = self._semlock = _multiprocessing.SemLock(\n"
]
}
I found some article that suggest I should use the multiprocessing library to handle this issue. I tried resolving this with that library with no success.
Any help would be greatly appreciated.
Thank you.
provide a software license
I see that you've provided a license for your jcapi repo. Would you mind providing a license for this repo as well?
groups_user_list not returning fields specified in API documentation
When running
api_response = apiv2_instance.groups_user_list( content_type, accept)
print(api_response)
each group object is returned as in the link: https://github.com/TheJumpCloud/jcapi-python/blob/master/jcapiv2/docs/UserGroup.md
{'attributes': None,
'id': 'redacted',
'name': 'redacted',
'type': 'user_group'}
However, in https://docs.jumpcloud.com/api/2.0/index.html#tag/User-Groups/operation/groups_user_list
I can see that the format should contain an "email" field amongst other things.
I have tried using
api_response = apiv2_instance.groups_user_list( content_type, accept, fields=["email", "id", "name"])
to no avail.
Am I doing something wrong, or is there an issue here? Running the snippet from the API docs in Python returns all fields as expected.
async is a reserved keyword - import fails
Hi there -
I am trying to use jcapiv2 (with python3.7) and have
from jcapiv2.rest import ApiException
and get:
File "/Users/miaferguson/Workspace/auditing/lib/python3.7/site-packages/jcapiv2/api/active_directory_api.py", line 149
async=params.get('async'),
^
SyntaxError: invalid syntax
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.