id
int64
0
843k
repository_name
stringlengths
7
55
file_path
stringlengths
9
332
class_name
stringlengths
3
290
human_written_code
stringlengths
12
4.36M
class_skeleton
stringlengths
19
2.2M
total_program_units
int64
1
9.57k
total_doc_str
int64
0
4.2k
AvgCountLine
float64
0
7.89k
AvgCountLineBlank
float64
0
300
AvgCountLineCode
float64
0
7.89k
AvgCountLineComment
float64
0
7.89k
AvgCyclomatic
float64
0
130
CommentToCodeRatio
float64
0
176
CountClassBase
float64
0
48
CountClassCoupled
float64
0
589
CountClassCoupledModified
float64
0
581
CountClassDerived
float64
0
5.37k
CountDeclInstanceMethod
float64
0
4.2k
CountDeclInstanceVariable
float64
0
299
CountDeclMethod
float64
0
4.2k
CountDeclMethodAll
float64
0
4.2k
CountLine
float64
1
115k
CountLineBlank
float64
0
9.01k
CountLineCode
float64
0
94.4k
CountLineCodeDecl
float64
0
46.1k
CountLineCodeExe
float64
0
91.3k
CountLineComment
float64
0
27k
CountStmt
float64
1
93.2k
CountStmtDecl
float64
0
46.1k
CountStmtExe
float64
0
90.2k
MaxCyclomatic
float64
0
759
MaxInheritanceTree
float64
0
16
MaxNesting
float64
0
34
SumCyclomatic
float64
0
6k
147,248
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/resource_jobs.py
platformrest.resource_jobs.ResourceJobs
class ResourceJobs(object): """ Class containing all the actions for the Resource Jobs Resource """ def __init__(self, client): self.client = client def get(self, **kwargs): """ Returns the resource jobs for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, resourceJobs.*, or resourceJobs.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated, lastExecutionRequested, resourceType * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name, resourceType * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of resource jobs (https://api.losant.com/#/definitions/resourceJobs) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "page" in kwargs: query_params["page"] = kwargs["page"] if "perPage" in kwargs: query_params["perPage"] = kwargs["perPage"] if "filterField" in kwargs: query_params["filterField"] = kwargs["filterField"] if "filter" in kwargs: query_params["filter"] = kwargs["filter"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/resource-jobs".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def post(self, **kwargs): """ Create a new resource job for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, resourceJobs.*, or resourceJobs.post. Parameters: * {string} applicationId - ID associated with the application * {hash} resourceJob - New resource job information (https://api.losant.com/#/definitions/resourceJobPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - Successfully created resource job (https://api.losant.com/#/definitions/resourceJob) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "resourceJob" in kwargs: body = kwargs["resourceJob"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/resource-jobs".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class ResourceJobs(object): ''' Class containing all the actions for the Resource Jobs Resource ''' def __init__(self, client): pass def get(self, **kwargs): ''' Returns the resource jobs for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, resourceJobs.*, or resourceJobs.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated, lastExecutionRequested, resourceType * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name, resourceType * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of resource jobs (https://api.losant.com/#/definitions/resourceJobs) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def post(self, **kwargs): ''' Create a new resource job for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, resourceJobs.*, or resourceJobs.post. Parameters: * {string} applicationId - ID associated with the application * {hash} resourceJob - New resource job information (https://api.losant.com/#/definitions/resourceJobPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - Successfully created resource job (https://api.losant.com/#/definitions/resourceJob) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass
4
3
37
5
17
15
7
0.9
1
0
0
0
3
1
3
3
116
19
51
15
47
46
51
15
47
12
1
1
20
147,249
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/instance_notification_rule.py
platformrest.instance_notification_rule.InstanceNotificationRule
class InstanceNotificationRule(object): """ Class containing all the actions for the Instance Notification Rule Resource """ def __init__(self, client): self.client = client def delete(self, **kwargs): """ Deletes a notification rule Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceNotificationRule.*, or instanceNotificationRule.delete. Parameters: * {string} instanceId - ID associated with the instance * {string} notificationRuleId - ID associated with the notification rule * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If notification rule was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if notification rule was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "notificationRuleId" in kwargs: path_params["notificationRuleId"] = kwargs["notificationRuleId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/notification-rules/{notificationRuleId}".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body) def evaluate(self, **kwargs): """ Queues the evaluation of a notification rule Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceNotificationRule.*, or instanceNotificationRule.evaluate. Parameters: * {string} instanceId - ID associated with the instance * {string} notificationRuleId - ID associated with the notification rule * {hash} evaluationOptions - The options for the evaluation (https://api.losant.com/#/definitions/notificationRuleEvaluationOptions) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If the evaluation was successfully queued (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if notification rule was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "notificationRuleId" in kwargs: path_params["notificationRuleId"] = kwargs["notificationRuleId"] if "evaluationOptions" in kwargs: body = kwargs["evaluationOptions"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/notification-rules/{notificationRuleId}/evaluate".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Retrieves information on a notification rule Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceNotificationRule.*, or instanceNotificationRule.get. Parameters: * {string} instanceId - ID associated with the instance * {string} notificationRuleId - ID associated with the notification rule * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Notification rule information (https://api.losant.com/#/definitions/notificationRule) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if notification rule was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "notificationRuleId" in kwargs: path_params["notificationRuleId"] = kwargs["notificationRuleId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/notification-rules/{notificationRuleId}".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def logs(self, **kwargs): """ Retrieves information on notification rule deliveries Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceNotificationRule.*, or instanceNotificationRule.logs. Parameters: * {string} instanceId - ID associated with the instance * {string} notificationRuleId - ID associated with the notification rule * {string} limit - Max log entries to return (ordered by time descending) * {string} since - Look for log entries since this time (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Notification delivery information (https://api.losant.com/#/definitions/notificationRuleDeliveryLogs) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if notification rule was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "notificationRuleId" in kwargs: path_params["notificationRuleId"] = kwargs["notificationRuleId"] if "limit" in kwargs: query_params["limit"] = kwargs["limit"] if "since" in kwargs: query_params["since"] = kwargs["since"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/notification-rules/{notificationRuleId}/logs".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def patch(self, **kwargs): """ Updates information about a notification rule Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceNotificationRule.*, or instanceNotificationRule.patch. Parameters: * {string} instanceId - ID associated with the instance * {string} notificationRuleId - ID associated with the notification rule * {hash} notificationRule - Object containing new properties of the notification rule (https://api.losant.com/#/definitions/notificationRulePatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated notification rule information (https://api.losant.com/#/definitions/notificationRule) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if notification rule was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "notificationRuleId" in kwargs: path_params["notificationRuleId"] = kwargs["notificationRuleId"] if "notificationRule" in kwargs: body = kwargs["notificationRule"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/notification-rules/{notificationRuleId}".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body)
class InstanceNotificationRule(object): ''' Class containing all the actions for the Instance Notification Rule Resource ''' def __init__(self, client): pass def delete(self, **kwargs): ''' Deletes a notification rule Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceNotificationRule.*, or instanceNotificationRule.delete. Parameters: * {string} instanceId - ID associated with the instance * {string} notificationRuleId - ID associated with the notification rule * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If notification rule was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if notification rule was not found (https://api.losant.com/#/definitions/error) ''' pass def evaluate(self, **kwargs): ''' Queues the evaluation of a notification rule Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceNotificationRule.*, or instanceNotificationRule.evaluate. Parameters: * {string} instanceId - ID associated with the instance * {string} notificationRuleId - ID associated with the notification rule * {hash} evaluationOptions - The options for the evaluation (https://api.losant.com/#/definitions/notificationRuleEvaluationOptions) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If the evaluation was successfully queued (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if notification rule was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Retrieves information on a notification rule Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceNotificationRule.*, or instanceNotificationRule.get. Parameters: * {string} instanceId - ID associated with the instance * {string} notificationRuleId - ID associated with the notification rule * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Notification rule information (https://api.losant.com/#/definitions/notificationRule) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if notification rule was not found (https://api.losant.com/#/definitions/error) ''' pass def logs(self, **kwargs): ''' Retrieves information on notification rule deliveries Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceNotificationRule.*, or instanceNotificationRule.logs. Parameters: * {string} instanceId - ID associated with the instance * {string} notificationRuleId - ID associated with the notification rule * {string} limit - Max log entries to return (ordered by time descending) * {string} since - Look for log entries since this time (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Notification delivery information (https://api.losant.com/#/definitions/notificationRuleDeliveryLogs) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if notification rule was not found (https://api.losant.com/#/definitions/error) ''' pass def patch(self, **kwargs): ''' Updates information about a notification rule Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceNotificationRule.*, or instanceNotificationRule.patch. Parameters: * {string} instanceId - ID associated with the instance * {string} notificationRuleId - ID associated with the notification rule * {hash} notificationRule - Object containing new properties of the notification rule (https://api.losant.com/#/definitions/notificationRulePatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated notification rule information (https://api.losant.com/#/definitions/notificationRule) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if notification rule was not found (https://api.losant.com/#/definitions/error) ''' pass
7
6
42
7
18
17
7
0.99
1
0
0
0
6
1
6
6
257
46
106
33
99
105
106
33
99
9
1
1
40
147,250
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/instance_orgs.py
platformrest.instance_orgs.InstanceOrgs
class InstanceOrgs(object): """ Class containing all the actions for the Instance Orgs Resource """ def __init__(self, client): self.client = client def get(self, **kwargs): """ Returns the organizations associated with the current instance Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrgs.*, or instanceOrgs.get. Parameters: * {string} instanceId - ID associated with the instance * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} summaryInclude - Comma-separated list of summary fields to include in org summary * {hash} query - Organization filter JSON object which overrides all other filter params. (https://api.losant.com/#/definitions/advancedInstanceOrgQuery) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A collection of organizations (https://api.losant.com/#/definitions/instanceOrgs) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "page" in kwargs: query_params["page"] = kwargs["page"] if "perPage" in kwargs: query_params["perPage"] = kwargs["perPage"] if "filterField" in kwargs: query_params["filterField"] = kwargs["filterField"] if "filter" in kwargs: query_params["filter"] = kwargs["filter"] if "summaryInclude" in kwargs: query_params["summaryInclude"] = kwargs["summaryInclude"] if "query" in kwargs: query_params["query"] = json.dumps(kwargs["query"]) if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def post(self, **kwargs): """ Create a new organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgs.*, or instanceOrgs.post. Parameters: * {string} instanceId - ID associated with the instance * {string} summaryInclude - Comma-separated list of summary fields to include in org summary * {hash} orgConfig - Object containing configurations for the new organization (https://api.losant.com/#/definitions/instanceOrgPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The newly created organization (https://api.losant.com/#/definitions/org) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "summaryInclude" in kwargs: query_params["summaryInclude"] = kwargs["summaryInclude"] if "orgConfig" in kwargs: body = kwargs["orgConfig"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class InstanceOrgs(object): ''' Class containing all the actions for the Instance Orgs Resource ''' def __init__(self, client): pass def get(self, **kwargs): ''' Returns the organizations associated with the current instance Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrgs.*, or instanceOrgs.get. Parameters: * {string} instanceId - ID associated with the instance * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} summaryInclude - Comma-separated list of summary fields to include in org summary * {hash} query - Organization filter JSON object which overrides all other filter params. (https://api.losant.com/#/definitions/advancedInstanceOrgQuery) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A collection of organizations (https://api.losant.com/#/definitions/instanceOrgs) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) ''' pass def post(self, **kwargs): ''' Create a new organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgs.*, or instanceOrgs.post. Parameters: * {string} instanceId - ID associated with the instance * {string} summaryInclude - Comma-separated list of summary fields to include in org summary * {hash} orgConfig - Object containing configurations for the new organization (https://api.losant.com/#/definitions/instanceOrgPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The newly created organization (https://api.losant.com/#/definitions/org) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) ''' pass
4
3
39
5
19
15
8
0.82
1
0
0
0
3
1
3
3
123
19
57
15
53
47
57
15
53
14
1
1
23
147,251
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/application_certificate.py
platformrest.application_certificate.ApplicationCertificate
class ApplicationCertificate(object): """ Class containing all the actions for the Application Certificate Resource """ def __init__(self, client): self.client = client def delete(self, **kwargs): """ Deletes an application certificate Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, applicationCertificate.*, or applicationCertificate.delete. Parameters: * {string} applicationId - ID associated with the application * {string} applicationCertificateId - ID associated with the application certificate * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If application certificate was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application certificate was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "applicationCertificateId" in kwargs: path_params["applicationCertificateId"] = kwargs["applicationCertificateId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/certificates/{applicationCertificateId}".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Retrieves information on an application certificate Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, applicationCertificate.*, or applicationCertificate.get. Parameters: * {string} applicationId - ID associated with the application * {string} applicationCertificateId - ID associated with the application certificate * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Application certificate information (https://api.losant.com/#/definitions/applicationCertificate) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application certificate was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "applicationCertificateId" in kwargs: path_params["applicationCertificateId"] = kwargs["applicationCertificateId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/certificates/{applicationCertificateId}".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def patch(self, **kwargs): """ Updates information about an application certificate Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, applicationCertificate.*, or applicationCertificate.patch. Parameters: * {string} applicationId - ID associated with the application * {string} applicationCertificateId - ID associated with the application certificate * {hash} applicationCertificate - Object containing new properties of the application certificate (https://api.losant.com/#/definitions/applicationCertificatePatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated application certificate information (https://api.losant.com/#/definitions/applicationCertificate) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application certificate was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "applicationCertificateId" in kwargs: path_params["applicationCertificateId"] = kwargs["applicationCertificateId"] if "applicationCertificate" in kwargs: body = kwargs["applicationCertificate"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/certificates/{applicationCertificateId}".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body)
class ApplicationCertificate(object): ''' Class containing all the actions for the Application Certificate Resource ''' def __init__(self, client): pass def delete(self, **kwargs): ''' Deletes an application certificate Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, applicationCertificate.*, or applicationCertificate.delete. Parameters: * {string} applicationId - ID associated with the application * {string} applicationCertificateId - ID associated with the application certificate * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If application certificate was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application certificate was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Retrieves information on an application certificate Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, applicationCertificate.*, or applicationCertificate.get. Parameters: * {string} applicationId - ID associated with the application * {string} applicationCertificateId - ID associated with the application certificate * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Application certificate information (https://api.losant.com/#/definitions/applicationCertificate) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application certificate was not found (https://api.losant.com/#/definitions/error) ''' pass def patch(self, **kwargs): ''' Updates information about an application certificate Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, applicationCertificate.*, or applicationCertificate.patch. Parameters: * {string} applicationId - ID associated with the application * {string} applicationCertificateId - ID associated with the application certificate * {hash} applicationCertificate - Object containing new properties of the application certificate (https://api.losant.com/#/definitions/applicationCertificatePatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated application certificate information (https://api.losant.com/#/definitions/applicationCertificate) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application certificate was not found (https://api.losant.com/#/definitions/error) ''' pass
5
4
37
6
15
15
6
1
1
0
0
0
4
1
4
4
152
28
62
21
57
62
62
21
57
8
1
1
23
147,252
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/application_api_tokens.py
platformrest.application_api_tokens.ApplicationApiTokens
class ApplicationApiTokens(object): """ Class containing all the actions for the Application Api Tokens Resource """ def __init__(self, client): self.client = client def get(self, **kwargs): """ Returns the API tokens for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, applicationApiTokens.*, or applicationApiTokens.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: name, status, id, creationDate, lastUpdated, expirationDate * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name, status * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of API tokens (https://api.losant.com/#/definitions/apiTokens) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "page" in kwargs: query_params["page"] = kwargs["page"] if "perPage" in kwargs: query_params["perPage"] = kwargs["perPage"] if "filterField" in kwargs: query_params["filterField"] = kwargs["filterField"] if "filter" in kwargs: query_params["filter"] = kwargs["filter"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/tokens".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def post(self, **kwargs): """ Create a new API token for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, applicationApiTokens.*, or applicationApiTokens.post. Parameters: * {string} applicationId - ID associated with the application * {hash} apiToken - API token information (https://api.losant.com/#/definitions/apiTokenPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - The successfully created API token (https://api.losant.com/#/definitions/apiToken) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "apiToken" in kwargs: body = kwargs["apiToken"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/tokens".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class ApplicationApiTokens(object): ''' Class containing all the actions for the Application Api Tokens Resource ''' def __init__(self, client): pass def get(self, **kwargs): ''' Returns the API tokens for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, applicationApiTokens.*, or applicationApiTokens.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: name, status, id, creationDate, lastUpdated, expirationDate * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name, status * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of API tokens (https://api.losant.com/#/definitions/apiTokens) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) ''' pass def post(self, **kwargs): ''' Create a new API token for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, applicationApiTokens.*, or applicationApiTokens.post. Parameters: * {string} applicationId - ID associated with the application * {hash} apiToken - API token information (https://api.losant.com/#/definitions/apiTokenPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - The successfully created API token (https://api.losant.com/#/definitions/apiToken) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) ''' pass
4
3
36
5
17
14
7
0.86
1
0
0
0
3
1
3
3
114
19
51
15
47
44
51
15
47
12
1
1
20
147,253
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/application_api_token.py
platformrest.application_api_token.ApplicationApiToken
class ApplicationApiToken(object): """ Class containing all the actions for the Application Api Token Resource """ def __init__(self, client): self.client = client def delete(self, **kwargs): """ Deletes an API Token Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, applicationApiToken.*, or applicationApiToken.delete. Parameters: * {string} applicationId - ID associated with the application * {string} apiTokenId - ID associated with the API token * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If API token was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if API token was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "apiTokenId" in kwargs: path_params["apiTokenId"] = kwargs["apiTokenId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/tokens/{apiTokenId}".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Retrieves information on an API token Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, applicationApiToken.*, or applicationApiToken.get. Parameters: * {string} applicationId - ID associated with the application * {string} apiTokenId - ID associated with the API token * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - API token information (https://api.losant.com/#/definitions/apiToken) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if API token was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "apiTokenId" in kwargs: path_params["apiTokenId"] = kwargs["apiTokenId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/tokens/{apiTokenId}".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def patch(self, **kwargs): """ Updates information about an API token Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, applicationApiToken.*, or applicationApiToken.patch. Parameters: * {string} applicationId - ID associated with the application * {string} apiTokenId - ID associated with the API token * {hash} apiToken - Object containing new properties of the API token (https://api.losant.com/#/definitions/apiTokenPatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated API token information (https://api.losant.com/#/definitions/apiToken) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if API token was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "apiTokenId" in kwargs: path_params["apiTokenId"] = kwargs["apiTokenId"] if "apiToken" in kwargs: body = kwargs["apiToken"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/tokens/{apiTokenId}".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body)
class ApplicationApiToken(object): ''' Class containing all the actions for the Application Api Token Resource ''' def __init__(self, client): pass def delete(self, **kwargs): ''' Deletes an API Token Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, applicationApiToken.*, or applicationApiToken.delete. Parameters: * {string} applicationId - ID associated with the application * {string} apiTokenId - ID associated with the API token * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If API token was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if API token was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Retrieves information on an API token Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, applicationApiToken.*, or applicationApiToken.get. Parameters: * {string} applicationId - ID associated with the application * {string} apiTokenId - ID associated with the API token * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - API token information (https://api.losant.com/#/definitions/apiToken) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if API token was not found (https://api.losant.com/#/definitions/error) ''' pass def patch(self, **kwargs): ''' Updates information about an API token Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, applicationApiToken.*, or applicationApiToken.patch. Parameters: * {string} applicationId - ID associated with the application * {string} apiTokenId - ID associated with the API token * {hash} apiToken - Object containing new properties of the API token (https://api.losant.com/#/definitions/apiTokenPatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated API token information (https://api.losant.com/#/definitions/apiToken) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if API token was not found (https://api.losant.com/#/definitions/error) ''' pass
5
4
37
6
15
15
6
1
1
0
0
0
4
1
4
4
152
28
62
21
57
62
62
21
57
8
1
1
23
147,254
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/application.py
platformrest.application.Application
class Application(object): """ Class containing all the actions for the Application Resource """ def __init__(self, client): self.client = client def apply_template(self, **kwargs): """ Add resources to an application via an application template Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.applyTemplate. Parameters: * {string} applicationId - ID of the associated application * {hash} options - Object containing template import options (https://api.losant.com/#/definitions/applicationApplyTemplatePatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated application information (https://api.losant.com/#/definitions/application) * 202 - If a job was enqueued for the resources to be imported into the application (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application is not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "options" in kwargs: body = kwargs["options"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/applyTemplate".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body) def archive_data(self, **kwargs): """ Returns success when a job has been enqueued to archive this application's device data for a given day Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.archiveData. Parameters: * {string} applicationId - ID of the associated application * {string} date - The date to archive data (ms since epoch), it must be within the archive time range older than 31 days and newer than the organizations dataTTL * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - Enqueued a job to archive this applications device data (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "date" in kwargs: query_params["date"] = kwargs["date"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/archiveData".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def backfill_archive_data(self, **kwargs): """ Returns success when a job has been enqueued to backfill all current data to its archive Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.backfillArchiveData. Parameters: * {string} applicationId - ID of the associated application * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - Enqueued a job to backfill device data to this application archive location (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/backfillArchiveData".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def clone(self, **kwargs): """ Copy an application into a new application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.clone. Parameters: * {string} applicationId - ID of the associated application * {hash} options - Object containing optional clone fields (https://api.losant.com/#/definitions/applicationClonePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - if dryRun is set and successful, then return success (https://api.losant.com/#/definitions/applicationCloneDryRunResult) * 201 - If application was successfully cloned (https://api.losant.com/#/definitions/applicationCreationByTemplateResult) * 202 - If application was enqueued to be cloned (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application is not found (https://api.losant.com/#/definitions/error) * 422 - Error if too many validation errors occurred on other resources (https://api.losant.com/#/definitions/validationErrors) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "options" in kwargs: body = kwargs["options"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/clone".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def delete(self, **kwargs): """ Deletes an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.delete. Parameters: * {string} applicationId - ID of the associated application * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If application was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body) def device_counts(self, **kwargs): """ Returns device counts by day for the time range specified for this application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, application.*, or application.deviceCounts. Parameters: * {string} applicationId - ID of the associated application * {string} start - Start of range for device count query (ms since epoch) * {string} end - End of range for device count query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Device counts by day (https://api.losant.com/#/definitions/deviceCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/deviceCounts".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def export(self, **kwargs): """ Export an application and all of its resources Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.export. Parameters: * {string} applicationId - ID of the associated application * {hash} options - Object containing export application options (https://api.losant.com/#/definitions/applicationExportPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - a url to download the zip of exported resources (https://api.losant.com/#/definitions/applicationExportResult) * 202 - If application was enqueued to be exported (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application is not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "options" in kwargs: body = kwargs["options"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/export".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def full_data_tables_archive(self, **kwargs): """ Returns success when a job has been enqueued to archive all selected data tables Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.fullDataTablesArchive. Parameters: * {string} applicationId - ID of the associated application * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - Enqueued a job to archive all selected data tables of this application archive location (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/fullDataTablesArchive".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def full_events_archive(self, **kwargs): """ Returns success when a job has been enqueued to archive all current events Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.fullEventsArchive. Parameters: * {string} applicationId - ID of the associated application * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - Enqueued a job to archive all events to this application archive location (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/fullEventsArchive".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Retrieves information on an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, application.*, or application.get. Parameters: * {string} applicationId - ID of the associated application * {string} summaryExclude - Comma-separated list of summary fields to exclude from application summary * {string} summaryInclude - Comma-separated list of summary fields to include in application summary * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Application information (https://api.losant.com/#/definitions/application) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "summaryExclude" in kwargs: query_params["summaryExclude"] = kwargs["summaryExclude"] if "summaryInclude" in kwargs: query_params["summaryInclude"] = kwargs["summaryInclude"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def globals(self, **kwargs): """ Updates an application global at the given key Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, application.*, or application.patch. Parameters: * {string} applicationId - ID of the associated application * {hash} globals - Array of objects containing new application global information (https://api.losant.com/#/definitions/applicationGlobalPatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated application information (https://api.losant.com/#/definitions/application) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "globals" in kwargs: body = kwargs["globals"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/globals".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body) def import_logs(self, **kwargs): """ Retrieves information on application import logs Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, application.*, or application.importLogs. Parameters: * {string} applicationId - ID of the associated application * {string} limit - Max log entries to return (ordered by time descending) * {string} since - Look for log entries since this time (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Application log objects (https://api.losant.com/#/definitions/applicationImportExecutions) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "limit" in kwargs: query_params["limit"] = kwargs["limit"] if "since" in kwargs: query_params["since"] = kwargs["since"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/importLogs".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def mqtt_publish_message(self, **kwargs): """ Publishes the given message to the given MQTT topic Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.mqttPublishMessage. Parameters: * {string} applicationId - ID of the associated application * {hash} payload - Object containing topic and message (https://api.losant.com/#/definitions/mqttPublishBody) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Message successfully published (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "payload" in kwargs: body = kwargs["payload"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/mqttPublishMessage".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def notebook_minute_counts(self, **kwargs): """ Returns notebook execution usage by day for the time range specified for this application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, application.*, or application.notebookMinuteCounts. Parameters: * {string} applicationId - ID of the associated application * {string} start - Start of range for notebook execution query (ms since epoch) * {string} end - End of range for notebook execution query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Notebook usage information (https://api.losant.com/#/definitions/notebookMinuteCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/notebookMinuteCounts".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def patch(self, **kwargs): """ Updates information about an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, application.*, or application.patch. Parameters: * {string} applicationId - ID of the associated application * {hash} application - Object containing new application properties (https://api.losant.com/#/definitions/applicationPatch) * {string} summaryExclude - Comma-separated list of summary fields to exclude from application summary * {string} summaryInclude - Comma-separated list of summary fields to include in application summary * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated application information (https://api.losant.com/#/definitions/application) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "application" in kwargs: body = kwargs["application"] if "summaryExclude" in kwargs: query_params["summaryExclude"] = kwargs["summaryExclude"] if "summaryInclude" in kwargs: query_params["summaryInclude"] = kwargs["summaryInclude"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body) def payload_counts(self, **kwargs): """ Returns payload counts for the time range specified for this application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, application.*, or application.payloadCounts. Parameters: * {string} applicationId - ID of the associated application * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} asBytes - If the resulting stats should be returned as bytes * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Payload counts, by type and source (https://api.losant.com/#/definitions/payloadStats) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "asBytes" in kwargs: query_params["asBytes"] = kwargs["asBytes"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/payloadCounts".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def payload_counts_breakdown(self, **kwargs): """ Returns payload counts per resolution in the time range specified for this application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, application.*, or application.payloadCountsBreakdown. Parameters: * {string} applicationId - ID of the associated application * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} resolution - Resolution in milliseconds. Accepted values are: 86400000, 3600000 * {string} asBytes - If the resulting stats should be returned as bytes * {string} includeNonBillable - If non-billable payloads should be included in the result * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Sum of payload counts by date (https://api.losant.com/#/definitions/payloadCountsBreakdown) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "resolution" in kwargs: query_params["resolution"] = kwargs["resolution"] if "asBytes" in kwargs: query_params["asBytes"] = kwargs["asBytes"] if "includeNonBillable" in kwargs: query_params["includeNonBillable"] = kwargs["includeNonBillable"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/payloadCountsBreakdown".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def readme(self, **kwargs): """ Get the current application readme information Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, application.*, or application.get. Parameters: * {string} applicationId - ID of the associated application * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The application readme information (https://api.losant.com/#/definitions/applicationReadme) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/readme".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def readme_patch(self, **kwargs): """ Update the current application readme information Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, application.*, or application.patch. Parameters: * {string} applicationId - ID of the associated application * {hash} readme - Object containing new readme information (https://api.losant.com/#/definitions/applicationReadmePatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated readme information (https://api.losant.com/#/definitions/applicationReadme) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "readme" in kwargs: body = kwargs["readme"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/readme".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body) def search(self, **kwargs): """ Search across an application's resources by target identifier Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, application.*, or application.search. Parameters: * {string} applicationId - ID of the associated application * {string} filter - The partial resource name being searched for * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - An array of resource ids, names, descriptions, and types matching the search query (https://api.losant.com/#/definitions/applicationSearchResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application is not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "filter" in kwargs: query_params["filter"] = kwargs["filter"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/search".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body)
class Application(object): ''' Class containing all the actions for the Application Resource ''' def __init__(self, client): pass def apply_template(self, **kwargs): ''' Add resources to an application via an application template Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.applyTemplate. Parameters: * {string} applicationId - ID of the associated application * {hash} options - Object containing template import options (https://api.losant.com/#/definitions/applicationApplyTemplatePatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated application information (https://api.losant.com/#/definitions/application) * 202 - If a job was enqueued for the resources to be imported into the application (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application is not found (https://api.losant.com/#/definitions/error) ''' pass def archive_data(self, **kwargs): ''' Returns success when a job has been enqueued to archive this application's device data for a given day Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.archiveData. Parameters: * {string} applicationId - ID of the associated application * {string} date - The date to archive data (ms since epoch), it must be within the archive time range older than 31 days and newer than the organizations dataTTL * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - Enqueued a job to archive this applications device data (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def backfill_archive_data(self, **kwargs): ''' Returns success when a job has been enqueued to backfill all current data to its archive Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.backfillArchiveData. Parameters: * {string} applicationId - ID of the associated application * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - Enqueued a job to backfill device data to this application archive location (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def clone(self, **kwargs): ''' Copy an application into a new application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.clone. Parameters: * {string} applicationId - ID of the associated application * {hash} options - Object containing optional clone fields (https://api.losant.com/#/definitions/applicationClonePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - if dryRun is set and successful, then return success (https://api.losant.com/#/definitions/applicationCloneDryRunResult) * 201 - If application was successfully cloned (https://api.losant.com/#/definitions/applicationCreationByTemplateResult) * 202 - If application was enqueued to be cloned (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application is not found (https://api.losant.com/#/definitions/error) * 422 - Error if too many validation errors occurred on other resources (https://api.losant.com/#/definitions/validationErrors) ''' pass def delete(self, **kwargs): ''' Deletes an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.delete. Parameters: * {string} applicationId - ID of the associated application * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If application was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def device_counts(self, **kwargs): ''' Returns device counts by day for the time range specified for this application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, application.*, or application.deviceCounts. Parameters: * {string} applicationId - ID of the associated application * {string} start - Start of range for device count query (ms since epoch) * {string} end - End of range for device count query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Device counts by day (https://api.losant.com/#/definitions/deviceCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def export(self, **kwargs): ''' Export an application and all of its resources Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.export. Parameters: * {string} applicationId - ID of the associated application * {hash} options - Object containing export application options (https://api.losant.com/#/definitions/applicationExportPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - a url to download the zip of exported resources (https://api.losant.com/#/definitions/applicationExportResult) * 202 - If application was enqueued to be exported (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application is not found (https://api.losant.com/#/definitions/error) ''' pass def full_data_tables_archive(self, **kwargs): ''' Returns success when a job has been enqueued to archive all selected data tables Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.fullDataTablesArchive. Parameters: * {string} applicationId - ID of the associated application * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - Enqueued a job to archive all selected data tables of this application archive location (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def full_events_archive(self, **kwargs): ''' Returns success when a job has been enqueued to archive all current events Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.fullEventsArchive. Parameters: * {string} applicationId - ID of the associated application * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - Enqueued a job to archive all events to this application archive location (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Retrieves information on an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, application.*, or application.get. Parameters: * {string} applicationId - ID of the associated application * {string} summaryExclude - Comma-separated list of summary fields to exclude from application summary * {string} summaryInclude - Comma-separated list of summary fields to include in application summary * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Application information (https://api.losant.com/#/definitions/application) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def globals(self, **kwargs): ''' Updates an application global at the given key Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, application.*, or application.patch. Parameters: * {string} applicationId - ID of the associated application * {hash} globals - Array of objects containing new application global information (https://api.losant.com/#/definitions/applicationGlobalPatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated application information (https://api.losant.com/#/definitions/application) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def import_logs(self, **kwargs): ''' Retrieves information on application import logs Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, application.*, or application.importLogs. Parameters: * {string} applicationId - ID of the associated application * {string} limit - Max log entries to return (ordered by time descending) * {string} since - Look for log entries since this time (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Application log objects (https://api.losant.com/#/definitions/applicationImportExecutions) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def mqtt_publish_message(self, **kwargs): ''' Publishes the given message to the given MQTT topic Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, application.*, or application.mqttPublishMessage. Parameters: * {string} applicationId - ID of the associated application * {hash} payload - Object containing topic and message (https://api.losant.com/#/definitions/mqttPublishBody) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Message successfully published (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def notebook_minute_counts(self, **kwargs): ''' Returns notebook execution usage by day for the time range specified for this application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, application.*, or application.notebookMinuteCounts. Parameters: * {string} applicationId - ID of the associated application * {string} start - Start of range for notebook execution query (ms since epoch) * {string} end - End of range for notebook execution query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Notebook usage information (https://api.losant.com/#/definitions/notebookMinuteCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def patch(self, **kwargs): ''' Updates information about an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, application.*, or application.patch. Parameters: * {string} applicationId - ID of the associated application * {hash} application - Object containing new application properties (https://api.losant.com/#/definitions/applicationPatch) * {string} summaryExclude - Comma-separated list of summary fields to exclude from application summary * {string} summaryInclude - Comma-separated list of summary fields to include in application summary * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated application information (https://api.losant.com/#/definitions/application) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def payload_counts(self, **kwargs): ''' Returns payload counts for the time range specified for this application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, application.*, or application.payloadCounts. Parameters: * {string} applicationId - ID of the associated application * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} asBytes - If the resulting stats should be returned as bytes * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Payload counts, by type and source (https://api.losant.com/#/definitions/payloadStats) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def payload_counts_breakdown(self, **kwargs): ''' Returns payload counts per resolution in the time range specified for this application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, application.*, or application.payloadCountsBreakdown. Parameters: * {string} applicationId - ID of the associated application * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} resolution - Resolution in milliseconds. Accepted values are: 86400000, 3600000 * {string} asBytes - If the resulting stats should be returned as bytes * {string} includeNonBillable - If non-billable payloads should be included in the result * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Sum of payload counts by date (https://api.losant.com/#/definitions/payloadCountsBreakdown) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def readme(self, **kwargs): ''' Get the current application readme information Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, application.*, or application.get. Parameters: * {string} applicationId - ID of the associated application * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The application readme information (https://api.losant.com/#/definitions/applicationReadme) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def readme_patch(self, **kwargs): ''' Update the current application readme information Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, application.*, or application.patch. Parameters: * {string} applicationId - ID of the associated application * {hash} readme - Object containing new readme information (https://api.losant.com/#/definitions/applicationReadmePatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated readme information (https://api.losant.com/#/definitions/applicationReadme) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def search(self, **kwargs): ''' Search across an application's resources by target identifier Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, application.*, or application.search. Parameters: * {string} applicationId - ID of the associated application * {string} filter - The partial resource name being searched for * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - An array of resource ids, names, descriptions, and types matching the search query (https://api.losant.com/#/definitions/applicationSearchResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application is not found (https://api.losant.com/#/definitions/error) ''' pass
22
21
46
8
19
20
7
1.04
1
0
0
0
21
1
21
21
991
181
397
123
375
413
397
123
375
11
1
1
148
147,255
Losant/losant-rest-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/Losant_losant-rest-python/tests/platformrest_tests.py
tests.platformrest_tests.TestClient
class TestClient(unittest.TestCase): @requests_mock.Mocker() def test_basic_call_no_auth(self, mock): expected_body = {"token": "a token", "userId": "theUserId"} expected_qs = {"_links": ["true"], "_actions": [ "false"], "_embedded": ["true"]} creds = {"email": "example@losant.com", "password": "qwerqwer"} mock.post("https://api.losant.com/auth/user", json=expected_body) resp = Client().auth.authenticate_user(credentials=creds) self.assertEqual(resp, expected_body) request = mock.request_history[0] parsed_url = urlparse(request.url) self.assertEqual(expected_qs, parse_qs(parsed_url.query)) self.assertEqual(parsed_url.path, "/auth/user") self.assertEqual(parsed_url.path, "/auth/user") self.assertEqual(request.headers["Accept"], "application/json") self.assertEqual(request.headers["Content-Type"], "application/json") self.assertNotIn("Authorization", request.headers) self.assertEqual(json.loads(request.text), creds) @requests_mock.Mocker() def test_basic_call_with_auth(self, mock): expected_body = {"name": "Python Client Testing", "_type": "device", "applicationId": "anapp", "id": "adevice"} expected_qs = {"_links": ["true"], "_actions": [ "false"], "_embedded": ["true"]} mock.get( "https://api.losant.com/applications/anapp/devices/adevice", json=expected_body) resp = Client("a token").device.get( applicationId="anapp", deviceId="adevice") self.assertEqual(resp, expected_body) request = mock.request_history[0] parsed_url = urlparse(request.url) self.assertEqual(expected_qs, parse_qs(parsed_url.query)) self.assertEqual( parsed_url.path, "/applications/anapp/devices/adevice") self.assertEqual(request.headers["Accept"], "application/json") self.assertEqual(request.headers["Authorization"], "Bearer a token") self.assertIsNone(request.body) @requests_mock.Mocker() def test_failure_call(self, mock): expected_body = {"message": "Unauthorized", "type": "Unauthorized"} expected_qs = {"_links": ["true"], "_actions": [ "false"], "_embedded": ["true"]} mock.post("https://api.losant.com/auth/user", json=expected_body, status_code=401) creds = {"email": "example@losant.com", "password": "qwerqwer"} with self.assertRaises(PlatformError) as cm: Client().auth.authenticate_user(credentials=creds) the_exception = cm.exception self.assertEqual(the_exception.status, 401) self.assertEqual(the_exception.data, expected_body) request = mock.request_history[0] parsed_url = urlparse(request.url) self.assertEqual(expected_qs, parse_qs(parsed_url.query)) self.assertEqual(parsed_url.path, "/auth/user") self.assertEqual(request.headers["Accept"], "application/json") self.assertNotIn("Authorization", request.headers) self.assertEqual(json.loads(request.text), creds) @requests_mock.Mocker() def test_nested_query_param_call(self, mock): expected_body = {"count": 0, "items": []} expected_qs = { "_links": ["true"], "_actions": ["false"], "_embedded": ["true"], "tagFilter[0][key]": ["key2"], "tagFilter[1][value]": ["value1"], "tagFilter[1][key]": ["key1"], "tagFilter[2][value]": ["value2"] } mock.get("https://api.losant.com/applications/anapp/devices", json=expected_body) resp = Client("a token").devices.get(applicationId="anapp", tagFilter=[ {"key": "key2"}, {"key": "key1", "value": "value1"}, {"value": "value2"}, ]) self.assertEqual(resp, expected_body) request = mock.request_history[0] parsed_url = urlparse(request.url) self.assertEqual(expected_qs, parse_qs(parsed_url.query)) self.assertEqual(parsed_url.path, "/applications/anapp/devices") self.assertEqual(request.headers["Accept"], "application/json") self.assertEqual(request.headers["Authorization"], "Bearer a token") self.assertIsNone(request.body) @requests_mock.Mocker() def test_json_query_param_call(self, mock): expected_body = {"count": 0, "items": []} expected_qs = { "_links": ["true"], "_actions": ["false"], "_embedded": ["true"], "query": ['{"$and": [{"level": "info"}, {"state": "new"}]}'] } mock.get("https://api.losant.com/applications/anapp/events", json=expected_body) resp = Client("a token").events.get(applicationId="anapp", query={ "$and": [{"level": "info"}, {"state": "new"}] }) self.assertEqual(resp, expected_body) request = mock.request_history[0] parsed_url = urlparse(request.url) self.assertEqual(expected_qs, parse_qs(parsed_url.query)) self.assertEqual(parsed_url.path, "/applications/anapp/events") self.assertEqual(request.headers["Accept"], "application/json") self.assertEqual(request.headers["Authorization"], "Bearer a token") self.assertIsNone(request.body)
class TestClient(unittest.TestCase): @requests_mock.Mocker() def test_basic_call_no_auth(self, mock): pass @requests_mock.Mocker() def test_basic_call_with_auth(self, mock): pass @requests_mock.Mocker() def test_failure_call(self, mock): pass @requests_mock.Mocker() def test_nested_query_param_call(self, mock): pass @requests_mock.Mocker() def test_json_query_param_call(self, mock): pass
11
0
20
2
18
0
1
0
1
1
1
0
5
0
5
77
110
13
97
39
86
0
73
33
67
1
2
1
5
147,256
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/data.py
platformrest.data.Data
class Data(object): """ Class containing all the actions for the Data Resource """ def __init__(self, client): self.client = client def export(self, **kwargs): """ Creates a csv file from a query of devices and attributes over a time range. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, data.*, or data.export. Parameters: * {string} applicationId - ID associated with the application * {hash} query - The query parameters (https://api.losant.com/#/definitions/dataExport) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If command was successfully sent (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "query" in kwargs: body = kwargs["query"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data/export".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def last_value_query(self, **kwargs): """ Returns the last known data for the given attribute Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, data.*, or data.lastValueQuery. Parameters: * {string} applicationId - ID associated with the application * {hash} query - The query parameters (https://api.losant.com/#/definitions/lastValueQuery) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Last known data for the requested attribute (https://api.losant.com/#/definitions/lastValueData) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "query" in kwargs: body = kwargs["query"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data/last-value-query".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def time_series_query(self, **kwargs): """ Returns the data for the given query Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, data.*, or data.timeSeriesQuery. Parameters: * {string} applicationId - ID associated with the application * {hash} query - The query parameters (https://api.losant.com/#/definitions/timeSeriesQuery) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Data for requested time range (https://api.losant.com/#/definitions/timeSeriesData) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "query" in kwargs: body = kwargs["query"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data/time-series-query".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class Data(object): ''' Class containing all the actions for the Data Resource ''' def __init__(self, client): pass def export(self, **kwargs): ''' Creates a csv file from a query of devices and attributes over a time range. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, data.*, or data.export. Parameters: * {string} applicationId - ID associated with the application * {hash} query - The query parameters (https://api.losant.com/#/definitions/dataExport) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If command was successfully sent (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def last_value_query(self, **kwargs): ''' Returns the last known data for the given attribute Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, data.*, or data.lastValueQuery. Parameters: * {string} applicationId - ID associated with the application * {hash} query - The query parameters (https://api.losant.com/#/definitions/lastValueQuery) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Last known data for the requested attribute (https://api.losant.com/#/definitions/lastValueData) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def time_series_query(self, **kwargs): ''' Returns the data for the given query Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, data.*, or data.timeSeriesQuery. Parameters: * {string} applicationId - ID associated with the application * {hash} query - The query parameters (https://api.losant.com/#/definitions/timeSeriesQuery) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Data for requested time range (https://api.losant.com/#/definitions/timeSeriesData) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass
5
4
36
6
15
15
6
1.02
1
0
0
0
4
1
4
4
149
28
60
21
55
61
60
21
55
7
1
1
22
147,257
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/data_table.py
platformrest.data_table.DataTable
class DataTable(object): """ Class containing all the actions for the Data Table Resource """ def __init__(self, client): self.client = client def add_column(self, **kwargs): """ Adds a new column to this data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTable.*, or dataTable.addColumn. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {hash} dataTableColumn - Object containing the new column properties (https://api.losant.com/#/definitions/dataTableColumn) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated data table information (https://api.losant.com/#/definitions/dataTable) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "dataTableColumn" in kwargs: body = kwargs["dataTableColumn"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}/column".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def delete(self, **kwargs): """ Deletes a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTable.*, or dataTable.delete. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If data table was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Retrieves information on a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, dataTable.*, or dataTable.get. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Data table information (https://api.losant.com/#/definitions/dataTable) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def patch(self, **kwargs): """ Updates information about a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTable.*, or dataTable.patch. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {hash} dataTable - Object containing updated properties of the data table (https://api.losant.com/#/definitions/dataTablePatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated data table information (https://api.losant.com/#/definitions/dataTable) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "dataTable" in kwargs: body = kwargs["dataTable"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body) def remove_column(self, **kwargs): """ Removes a column from this data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTable.*, or dataTable.removeColumn. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} columnName - Name of the column to remove * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated data table information (https://api.losant.com/#/definitions/dataTable) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "columnName" in kwargs: query_params["columnName"] = kwargs["columnName"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}/column".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body)
class DataTable(object): ''' Class containing all the actions for the Data Table Resource ''' def __init__(self, client): pass def add_column(self, **kwargs): ''' Adds a new column to this data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTable.*, or dataTable.addColumn. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {hash} dataTableColumn - Object containing the new column properties (https://api.losant.com/#/definitions/dataTableColumn) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated data table information (https://api.losant.com/#/definitions/dataTable) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) ''' pass def delete(self, **kwargs): ''' Deletes a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTable.*, or dataTable.delete. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If data table was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Retrieves information on a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, dataTable.*, or dataTable.get. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Data table information (https://api.losant.com/#/definitions/dataTable) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) ''' pass def patch(self, **kwargs): ''' Updates information about a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTable.*, or dataTable.patch. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {hash} dataTable - Object containing updated properties of the data table (https://api.losant.com/#/definitions/dataTablePatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated data table information (https://api.losant.com/#/definitions/dataTable) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) ''' pass def remove_column(self, **kwargs): ''' Removes a column from this data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTable.*, or dataTable.removeColumn. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} columnName - Name of the column to remove * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated data table information (https://api.losant.com/#/definitions/dataTable) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) ''' pass
7
6
41
7
17
17
7
1
1
0
0
0
6
1
6
6
254
46
104
33
97
104
104
33
97
8
1
1
39
147,258
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/data_table_row.py
platformrest.data_table_row.DataTableRow
class DataTableRow(object): """ Class containing all the actions for the Data Table Row Resource """ def __init__(self, client): self.client = client def delete(self, **kwargs): """ Deletes a data table row Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTableRow.*, or dataTableRow.delete. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} rowId - ID associated with the data table row * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If data table row was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table row was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "rowId" in kwargs: path_params["rowId"] = kwargs["rowId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}/rows/{rowId}".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Retrieves the data table row Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, dataTableRow.*, or dataTableRow.get. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} rowId - ID associated with the data table row * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Data table row information (https://api.losant.com/#/definitions/dataTableRow) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table row was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "rowId" in kwargs: path_params["rowId"] = kwargs["rowId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}/rows/{rowId}".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def patch(self, **kwargs): """ Updates the data table row Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTableRow.*, or dataTableRow.patch. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} rowId - ID associated with the data table row * {hash} dataTableRow - Object containing updated properties for the data table row (https://api.losant.com/#/definitions/dataTableRowInsertUpdate) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated data table row information (https://api.losant.com/#/definitions/dataTableRow) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table row was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "rowId" in kwargs: path_params["rowId"] = kwargs["rowId"] if "dataTableRow" in kwargs: body = kwargs["dataTableRow"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}/rows/{rowId}".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body)
class DataTableRow(object): ''' Class containing all the actions for the Data Table Row Resource ''' def __init__(self, client): pass def delete(self, **kwargs): ''' Deletes a data table row Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTableRow.*, or dataTableRow.delete. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} rowId - ID associated with the data table row * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If data table row was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table row was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Retrieves the data table row Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, dataTableRow.*, or dataTableRow.get. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} rowId - ID associated with the data table row * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Data table row information (https://api.losant.com/#/definitions/dataTableRow) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table row was not found (https://api.losant.com/#/definitions/error) ''' pass def patch(self, **kwargs): ''' Updates the data table row Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTableRow.*, or dataTableRow.patch. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} rowId - ID associated with the data table row * {hash} dataTableRow - Object containing updated properties for the data table row (https://api.losant.com/#/definitions/dataTableRowInsertUpdate) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated data table row information (https://api.losant.com/#/definitions/dataTableRow) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table row was not found (https://api.losant.com/#/definitions/error) ''' pass
5
4
39
6
17
16
7
0.96
1
0
0
0
4
1
4
4
161
28
68
21
63
65
68
21
63
9
1
1
26
147,259
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/data_table_rows.py
platformrest.data_table_rows.DataTableRows
class DataTableRows(object): """ Class containing all the actions for the Data Table Rows Resource """ def __init__(self, client): self.client = client def delete(self, **kwargs): """ Delete rows from a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTableRows.*, or dataTableRows.delete. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {hash} query - Query to apply to filter the data table (https://api.losant.com/#/definitions/advancedQuery) * {string} limit - Limit number of rows to delete from data table * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If request successfully deletes a set of Data Table rows (https://api.losant.com/#/definitions/dataTableRowsDelete) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "query" in kwargs: body = kwargs["query"] if "limit" in kwargs: query_params["limit"] = kwargs["limit"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}/rows/delete".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def export(self, **kwargs): """ Request an export of the data table's data Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, dataTableRows.*, or dataTableRows.export. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {hash} exportData - Object containing export specifications (https://api.losant.com/#/definitions/dataTableRowsExport) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If request was successfully queued (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "exportData" in kwargs: body = kwargs["exportData"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}/rows/export".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Returns the rows for a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, dataTableRows.*, or dataTableRows.get. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} sortColumn - Column to sort the rows by * {string} sortDirection - Direction to sort the rows by. Accepted values are: asc, desc * {string} limit - How many rows to return * {string} offset - How many rows to skip * {string} includeFields - Comma-separated list of fields to include in resulting rows. When not provided, returns all fields. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of data table rows (https://api.losant.com/#/definitions/dataTableRows) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "sortColumn" in kwargs: query_params["sortColumn"] = kwargs["sortColumn"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "limit" in kwargs: query_params["limit"] = kwargs["limit"] if "offset" in kwargs: query_params["offset"] = kwargs["offset"] if "includeFields" in kwargs: query_params["includeFields"] = kwargs["includeFields"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}/rows".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def post(self, **kwargs): """ Inserts a new row(s) into a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTableRows.*, or dataTableRows.post. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {hash} dataTableRow - The row(s) to insert (https://api.losant.com/#/definitions/dataTableRowInsert) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - Successfully created data table row, or bulk insert count (https://api.losant.com/#/definitions/dataTableRowInsertResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "dataTableRow" in kwargs: body = kwargs["dataTableRow"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}/rows".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def query(self, **kwargs): """ Queries for rows from a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, dataTableRows.*, or dataTableRows.query. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} sortColumn - Column to sort the rows by * {string} sortDirection - Direction to sort the rows by. Accepted values are: asc, desc * {string} limit - How many rows to return * {string} offset - How many rows to skip * {string} includeFields - Comma-separated list of fields to include in resulting rows. When not provided, returns all fields. * {hash} query - Query to apply to filter the data table (https://api.losant.com/#/definitions/advancedQuery) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of data table rows (https://api.losant.com/#/definitions/dataTableRows) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "sortColumn" in kwargs: query_params["sortColumn"] = kwargs["sortColumn"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "limit" in kwargs: query_params["limit"] = kwargs["limit"] if "offset" in kwargs: query_params["offset"] = kwargs["offset"] if "includeFields" in kwargs: query_params["includeFields"] = kwargs["includeFields"] if "query" in kwargs: body = kwargs["query"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}/rows/query".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def truncate(self, **kwargs): """ Delete all data in the data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTableRows.*, or dataTableRows.truncate. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If request successfully deleted **all** rows in the data table, this will **not** send workflow data table deletion triggers (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTableId" in kwargs: path_params["dataTableId"] = kwargs["dataTableId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables/{dataTableId}/rows/truncate".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class DataTableRows(object): ''' Class containing all the actions for the Data Table Rows Resource ''' def __init__(self, client): pass def delete(self, **kwargs): ''' Delete rows from a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTableRows.*, or dataTableRows.delete. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {hash} query - Query to apply to filter the data table (https://api.losant.com/#/definitions/advancedQuery) * {string} limit - Limit number of rows to delete from data table * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If request successfully deletes a set of Data Table rows (https://api.losant.com/#/definitions/dataTableRowsDelete) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) ''' pass def export(self, **kwargs): ''' Request an export of the data table's data Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, dataTableRows.*, or dataTableRows.export. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {hash} exportData - Object containing export specifications (https://api.losant.com/#/definitions/dataTableRowsExport) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If request was successfully queued (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Returns the rows for a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, dataTableRows.*, or dataTableRows.get. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} sortColumn - Column to sort the rows by * {string} sortDirection - Direction to sort the rows by. Accepted values are: asc, desc * {string} limit - How many rows to return * {string} offset - How many rows to skip * {string} includeFields - Comma-separated list of fields to include in resulting rows. When not provided, returns all fields. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of data table rows (https://api.losant.com/#/definitions/dataTableRows) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) ''' pass def post(self, **kwargs): ''' Inserts a new row(s) into a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTableRows.*, or dataTableRows.post. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {hash} dataTableRow - The row(s) to insert (https://api.losant.com/#/definitions/dataTableRowInsert) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - Successfully created data table row, or bulk insert count (https://api.losant.com/#/definitions/dataTableRowInsertResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) ''' pass def query(self, **kwargs): ''' Queries for rows from a data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, dataTableRows.*, or dataTableRows.query. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} sortColumn - Column to sort the rows by * {string} sortDirection - Direction to sort the rows by. Accepted values are: asc, desc * {string} limit - How many rows to return * {string} offset - How many rows to skip * {string} includeFields - Comma-separated list of fields to include in resulting rows. When not provided, returns all fields. * {hash} query - Query to apply to filter the data table (https://api.losant.com/#/definitions/advancedQuery) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of data table rows (https://api.losant.com/#/definitions/dataTableRows) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) ''' pass def truncate(self, **kwargs): ''' Delete all data in the data table Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTableRows.*, or dataTableRows.truncate. Parameters: * {string} applicationId - ID associated with the application * {string} dataTableId - ID associated with the data table * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If request successfully deleted **all** rows in the data table, this will **not** send workflow data table deletion triggers (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error) ''' pass
8
7
47
7
21
19
8
0.93
1
0
0
0
7
1
7
7
338
55
147
39
139
136
147
39
139
13
1
1
58
147,260
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/data_tables.py
platformrest.data_tables.DataTables
class DataTables(object): """ Class containing all the actions for the Data Tables Resource """ def __init__(self, client): self.client = client def get(self, **kwargs): """ Returns the data tables for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, dataTables.*, or dataTables.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of data tables (https://api.losant.com/#/definitions/dataTables) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "page" in kwargs: query_params["page"] = kwargs["page"] if "perPage" in kwargs: query_params["perPage"] = kwargs["perPage"] if "filterField" in kwargs: query_params["filterField"] = kwargs["filterField"] if "filter" in kwargs: query_params["filter"] = kwargs["filter"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def post(self, **kwargs): """ Create a new data table for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTables.*, or dataTables.post. Parameters: * {string} applicationId - ID associated with the application * {hash} dataTable - New data table information (https://api.losant.com/#/definitions/dataTablePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - Successfully created data table (https://api.losant.com/#/definitions/dataTable) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "dataTable" in kwargs: body = kwargs["dataTable"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/data-tables".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class DataTables(object): ''' Class containing all the actions for the Data Tables Resource ''' def __init__(self, client): pass def get(self, **kwargs): ''' Returns the data tables for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, dataTables.*, or dataTables.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of data tables (https://api.losant.com/#/definitions/dataTables) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def post(self, **kwargs): ''' Create a new data table for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, dataTables.*, or dataTables.post. Parameters: * {string} applicationId - ID associated with the application * {hash} dataTable - New data table information (https://api.losant.com/#/definitions/dataTablePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - Successfully created data table (https://api.losant.com/#/definitions/dataTable) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass
4
3
37
5
17
15
7
0.9
1
0
0
0
3
1
3
3
116
19
51
15
47
46
51
15
47
12
1
1
20
147,261
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/device.py
platformrest.device.Device
class Device(object): """ Class containing all the actions for the Device Resource """ def __init__(self, client): self.client = client def delete(self, **kwargs): """ Deletes a device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, device.*, or device.delete. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If device was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body) def export(self, **kwargs): """ Creates a device data export. Defaults to all data. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.export. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} start - Start time of export (ms since epoch - 0 means now, negative is relative to now) * {string} end - End time of export (ms since epoch - 0 means now, negative is relative to now) * {string} email - Email address to send export to. Defaults to current user's email. * {string} callbackUrl - Callback URL to call with export result * {string} includeBlobData - If set will export any blob attributes in base64 form, otherwise they will be downloadable links which will expire. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If generation of export was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "email" in kwargs: query_params["email"] = kwargs["email"] if "callbackUrl" in kwargs: query_params["callbackUrl"] = kwargs["callbackUrl"] if "includeBlobData" in kwargs: query_params["includeBlobData"] = kwargs["includeBlobData"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}/export".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Retrieves information on a device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.get. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} excludeConnectionInfo - If set, do not return connection info * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Device information (https://api.losant.com/#/definitions/device) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "excludeConnectionInfo" in kwargs: query_params["excludeConnectionInfo"] = kwargs["excludeConnectionInfo"] if "tagsAsObject" in kwargs: query_params["tagsAsObject"] = kwargs["tagsAsObject"] if "attributesAsObject" in kwargs: query_params["attributesAsObject"] = kwargs["attributesAsObject"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def get_command(self, **kwargs): """ Retrieve the last known commands(s) sent to the device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getCommand. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} limit - Maximum number of command entries to return * {string} since - (deprecated) Look for command entries since this time (ms since epoch) * {string} sortDirection - Direction to sort the command entries (by time). Accepted values are: asc, desc * {string} duration - Duration of time range to query in milliseconds * {string} start - Start of time range to query in milliseconds since epoch * {string} end - End of time range to query in milliseconds since epoch * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Recent device commands (https://api.losant.com/#/definitions/deviceCommands) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "limit" in kwargs: query_params["limit"] = kwargs["limit"] if "since" in kwargs: query_params["since"] = kwargs["since"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "duration" in kwargs: query_params["duration"] = kwargs["duration"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}/command".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def get_composite_state(self, **kwargs): """ Retrieve the composite last complete state of the device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getCompositeState. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} start - Start of time range to look at to build composite state * {string} end - End of time range to look at to build composite state * {string} attributes - Comma-separated list of attributes to include. When not provided, returns all attributes. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Composite last state of the device (https://api.losant.com/#/definitions/compositeDeviceState) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "attributes" in kwargs: query_params["attributes"] = kwargs["attributes"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}/compositeState".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def get_log_entries(self, **kwargs): """ Retrieve the recent log entries about the device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getLogEntries. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} limit - Maximum number of log entries to return * {string} since - (deprecated) Look for log entries since this time (ms since epoch) * {string} sortDirection - Direction to sort the log entries (by time). Accepted values are: asc, desc * {string} duration - Duration of time range to query in milliseconds * {string} start - Start of time range to query in milliseconds since epoch * {string} end - End of time range to query in milliseconds since epoch * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Recent log entries (https://api.losant.com/#/definitions/deviceLog) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "limit" in kwargs: query_params["limit"] = kwargs["limit"] if "since" in kwargs: query_params["since"] = kwargs["since"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "duration" in kwargs: query_params["duration"] = kwargs["duration"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}/logs".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def get_state(self, **kwargs): """ Retrieve the last known state(s) of the device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getState. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} limit - Maximum number of state entries to return * {string} since - (deprecated) Look for state entries since this time (ms since epoch) * {string} sortDirection - Direction to sort the state entries (by time). Accepted values are: asc, desc * {string} duration - Duration of time range to query in milliseconds * {string} start - Start of time range to query in milliseconds since epoch * {string} end - End of time range to query in milliseconds since epoch * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Recent device states (https://api.losant.com/#/definitions/deviceStates) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "limit" in kwargs: query_params["limit"] = kwargs["limit"] if "since" in kwargs: query_params["since"] = kwargs["since"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "duration" in kwargs: query_params["duration"] = kwargs["duration"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}/state".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def patch(self, **kwargs): """ Updates information about a device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, device.*, or device.patch. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {hash} device - Object containing new properties of the device (https://api.losant.com/#/definitions/devicePatch) * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated device information (https://api.losant.com/#/definitions/device) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "device" in kwargs: body = kwargs["device"] if "tagsAsObject" in kwargs: query_params["tagsAsObject"] = kwargs["tagsAsObject"] if "attributesAsObject" in kwargs: query_params["attributesAsObject"] = kwargs["attributesAsObject"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body) def payload_counts(self, **kwargs): """ Returns payload counts for the time range specified for this device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.payloadCounts. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Payload counts, by type (https://api.losant.com/#/definitions/devicePayloadCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}/payloadCounts".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def payload_counts_breakdown(self, **kwargs): """ Returns payload counts per resolution in the time range specified for this device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.payloadCountsBreakdown. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} resolution - Resolution in milliseconds. Accepted values are: 86400000, 3600000 * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Sum of payload counts by date (https://api.losant.com/#/definitions/payloadCountsBreakdown) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "resolution" in kwargs: query_params["resolution"] = kwargs["resolution"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}/payloadCountsBreakdown".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def remove_data(self, **kwargs): """ Removes all device data for the specified time range. Defaults to all data. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, device.*, or device.removeData. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} start - Start time of export (ms since epoch - 0 means now, negative is relative to now) * {string} end - End time of export (ms since epoch - 0 means now, negative is relative to now) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If data removal was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}/data".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body) def send_command(self, **kwargs): """ Send a command to a device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Device, all.Organization, all.User, device.*, or device.sendCommand. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {hash} deviceCommand - Command to send to the device (https://api.losant.com/#/definitions/deviceCommand) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If command was successfully sent (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "deviceCommand" in kwargs: body = kwargs["deviceCommand"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}/command".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def send_state(self, **kwargs): """ Send the current state of the device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Device, all.Organization, all.User, device.*, or device.sendState. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {hash} deviceState - A single device state object, or an array of device state objects (https://api.losant.com/#/definitions/deviceStateOrStates) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If state was successfully received (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "deviceState" in kwargs: body = kwargs["deviceState"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}/state".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def set_connection_status(self, **kwargs): """ Set the current connection status of the device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Device, all.Organization, all.User, device.*, or device.setConnectionStatus. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {hash} connectionStatus - The current connection status of the device (https://api.losant.com/#/definitions/deviceConnectionStatus) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If connection status was successfully applied (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceId" in kwargs: path_params["deviceId"] = kwargs["deviceId"] if "connectionStatus" in kwargs: body = kwargs["connectionStatus"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/{deviceId}/setConnectionStatus".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class Device(object): ''' Class containing all the actions for the Device Resource ''' def __init__(self, client): pass def delete(self, **kwargs): ''' Deletes a device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, device.*, or device.delete. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If device was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass def export(self, **kwargs): ''' Creates a device data export. Defaults to all data. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.export. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} start - Start time of export (ms since epoch - 0 means now, negative is relative to now) * {string} end - End time of export (ms since epoch - 0 means now, negative is relative to now) * {string} email - Email address to send export to. Defaults to current user's email. * {string} callbackUrl - Callback URL to call with export result * {string} includeBlobData - If set will export any blob attributes in base64 form, otherwise they will be downloadable links which will expire. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If generation of export was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Retrieves information on a device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.get. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} excludeConnectionInfo - If set, do not return connection info * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Device information (https://api.losant.com/#/definitions/device) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass def get_command(self, **kwargs): ''' Retrieve the last known commands(s) sent to the device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getCommand. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} limit - Maximum number of command entries to return * {string} since - (deprecated) Look for command entries since this time (ms since epoch) * {string} sortDirection - Direction to sort the command entries (by time). Accepted values are: asc, desc * {string} duration - Duration of time range to query in milliseconds * {string} start - Start of time range to query in milliseconds since epoch * {string} end - End of time range to query in milliseconds since epoch * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Recent device commands (https://api.losant.com/#/definitions/deviceCommands) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass def get_composite_state(self, **kwargs): ''' Retrieve the composite last complete state of the device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getCompositeState. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} start - Start of time range to look at to build composite state * {string} end - End of time range to look at to build composite state * {string} attributes - Comma-separated list of attributes to include. When not provided, returns all attributes. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Composite last state of the device (https://api.losant.com/#/definitions/compositeDeviceState) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass def get_log_entries(self, **kwargs): ''' Retrieve the recent log entries about the device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getLogEntries. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} limit - Maximum number of log entries to return * {string} since - (deprecated) Look for log entries since this time (ms since epoch) * {string} sortDirection - Direction to sort the log entries (by time). Accepted values are: asc, desc * {string} duration - Duration of time range to query in milliseconds * {string} start - Start of time range to query in milliseconds since epoch * {string} end - End of time range to query in milliseconds since epoch * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Recent log entries (https://api.losant.com/#/definitions/deviceLog) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass def get_state(self, **kwargs): ''' Retrieve the last known state(s) of the device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getState. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} limit - Maximum number of state entries to return * {string} since - (deprecated) Look for state entries since this time (ms since epoch) * {string} sortDirection - Direction to sort the state entries (by time). Accepted values are: asc, desc * {string} duration - Duration of time range to query in milliseconds * {string} start - Start of time range to query in milliseconds since epoch * {string} end - End of time range to query in milliseconds since epoch * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Recent device states (https://api.losant.com/#/definitions/deviceStates) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass def patch(self, **kwargs): ''' Updates information about a device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, device.*, or device.patch. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {hash} device - Object containing new properties of the device (https://api.losant.com/#/definitions/devicePatch) * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated device information (https://api.losant.com/#/definitions/device) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass def payload_counts(self, **kwargs): ''' Returns payload counts for the time range specified for this device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.payloadCounts. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Payload counts, by type (https://api.losant.com/#/definitions/devicePayloadCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass def payload_counts_breakdown(self, **kwargs): ''' Returns payload counts per resolution in the time range specified for this device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.payloadCountsBreakdown. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} resolution - Resolution in milliseconds. Accepted values are: 86400000, 3600000 * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Sum of payload counts by date (https://api.losant.com/#/definitions/payloadCountsBreakdown) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass def remove_data(self, **kwargs): ''' Removes all device data for the specified time range. Defaults to all data. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, device.*, or device.removeData. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {string} start - Start time of export (ms since epoch - 0 means now, negative is relative to now) * {string} end - End time of export (ms since epoch - 0 means now, negative is relative to now) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If data removal was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass def send_command(self, **kwargs): ''' Send a command to a device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Device, all.Organization, all.User, device.*, or device.sendCommand. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {hash} deviceCommand - Command to send to the device (https://api.losant.com/#/definitions/deviceCommand) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If command was successfully sent (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass def send_state(self, **kwargs): ''' Send the current state of the device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Device, all.Organization, all.User, device.*, or device.sendState. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {hash} deviceState - A single device state object, or an array of device state objects (https://api.losant.com/#/definitions/deviceStateOrStates) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If state was successfully received (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass def set_connection_status(self, **kwargs): ''' Set the current connection status of the device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Device, all.Organization, all.User, device.*, or device.setConnectionStatus. Parameters: * {string} applicationId - ID associated with the application * {string} deviceId - ID associated with the device * {hash} connectionStatus - The current connection status of the device (https://api.losant.com/#/definitions/deviceConnectionStatus) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If connection status was successfully applied (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device was not found (https://api.losant.com/#/definitions/error) ''' pass
16
15
52
7
23
21
9
0.92
1
0
0
0
15
1
15
15
803
127
353
87
337
323
353
87
337
13
1
1
141
147,262
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/device_recipe.py
platformrest.device_recipe.DeviceRecipe
class DeviceRecipe(object): """ Class containing all the actions for the Device Recipe Resource """ def __init__(self, client): self.client = client def bulk_create(self, **kwargs): """ Bulk creates devices using this recipe from a CSV Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, deviceRecipe.*, or deviceRecipe.bulkCreate. Parameters: * {string} applicationId - ID associated with the application * {string} deviceRecipeId - ID associated with the device recipe * {hash} bulkInfo - Object containing bulk creation info (https://api.losant.com/#/definitions/deviceRecipeBulkCreatePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - If devices were successfully created (https://api.losant.com/#/definitions/deviceRecipeBulkCreate) * 202 - If devices were enqueued to be created (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device recipe was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceRecipeId" in kwargs: path_params["deviceRecipeId"] = kwargs["deviceRecipeId"] if "bulkInfo" in kwargs: body = kwargs["bulkInfo"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/device-recipes/{deviceRecipeId}/bulkCreate".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def delete(self, **kwargs): """ Deletes a device recipe Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, deviceRecipe.*, or deviceRecipe.delete. Parameters: * {string} applicationId - ID associated with the application * {string} deviceRecipeId - ID associated with the device recipe * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If device recipe was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device recipe was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceRecipeId" in kwargs: path_params["deviceRecipeId"] = kwargs["deviceRecipeId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/device-recipes/{deviceRecipeId}".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Retrieves information on a device recipe Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, deviceRecipe.*, or deviceRecipe.get. Parameters: * {string} applicationId - ID associated with the application * {string} deviceRecipeId - ID associated with the device recipe * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Device recipe information (https://api.losant.com/#/definitions/deviceRecipe) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device recipe was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceRecipeId" in kwargs: path_params["deviceRecipeId"] = kwargs["deviceRecipeId"] if "tagsAsObject" in kwargs: query_params["tagsAsObject"] = kwargs["tagsAsObject"] if "attributesAsObject" in kwargs: query_params["attributesAsObject"] = kwargs["attributesAsObject"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/device-recipes/{deviceRecipeId}".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def patch(self, **kwargs): """ Updates information about a device recipe Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, deviceRecipe.*, or deviceRecipe.patch. Parameters: * {string} applicationId - ID associated with the application * {string} deviceRecipeId - ID associated with the device recipe * {hash} deviceRecipe - Object containing new properties of the device recipe (https://api.losant.com/#/definitions/deviceRecipePatch) * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated device recipe information (https://api.losant.com/#/definitions/deviceRecipe) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device recipe was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceRecipeId" in kwargs: path_params["deviceRecipeId"] = kwargs["deviceRecipeId"] if "deviceRecipe" in kwargs: body = kwargs["deviceRecipe"] if "tagsAsObject" in kwargs: query_params["tagsAsObject"] = kwargs["tagsAsObject"] if "attributesAsObject" in kwargs: query_params["attributesAsObject"] = kwargs["attributesAsObject"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/device-recipes/{deviceRecipeId}".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body)
class DeviceRecipe(object): ''' Class containing all the actions for the Device Recipe Resource ''' def __init__(self, client): pass def bulk_create(self, **kwargs): ''' Bulk creates devices using this recipe from a CSV Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, deviceRecipe.*, or deviceRecipe.bulkCreate. Parameters: * {string} applicationId - ID associated with the application * {string} deviceRecipeId - ID associated with the device recipe * {hash} bulkInfo - Object containing bulk creation info (https://api.losant.com/#/definitions/deviceRecipeBulkCreatePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - If devices were successfully created (https://api.losant.com/#/definitions/deviceRecipeBulkCreate) * 202 - If devices were enqueued to be created (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device recipe was not found (https://api.losant.com/#/definitions/error) ''' pass def delete(self, **kwargs): ''' Deletes a device recipe Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, deviceRecipe.*, or deviceRecipe.delete. Parameters: * {string} applicationId - ID associated with the application * {string} deviceRecipeId - ID associated with the device recipe * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If device recipe was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device recipe was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Retrieves information on a device recipe Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, deviceRecipe.*, or deviceRecipe.get. Parameters: * {string} applicationId - ID associated with the application * {string} deviceRecipeId - ID associated with the device recipe * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Device recipe information (https://api.losant.com/#/definitions/deviceRecipe) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device recipe was not found (https://api.losant.com/#/definitions/error) ''' pass def patch(self, **kwargs): ''' Updates information about a device recipe Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, deviceRecipe.*, or deviceRecipe.patch. Parameters: * {string} applicationId - ID associated with the application * {string} deviceRecipeId - ID associated with the device recipe * {hash} deviceRecipe - Object containing new properties of the device recipe (https://api.losant.com/#/definitions/deviceRecipePatch) * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated device recipe information (https://api.losant.com/#/definitions/deviceRecipe) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if device recipe was not found (https://api.losant.com/#/definitions/error) ''' pass
6
5
42
6
18
17
7
0.97
1
0
0
0
5
1
5
5
216
37
91
27
85
88
91
27
85
10
1
1
35
147,263
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/device_recipes.py
platformrest.device_recipes.DeviceRecipes
class DeviceRecipes(object): """ Class containing all the actions for the Device Recipes Resource """ def __init__(self, client): self.client = client def get(self, **kwargs): """ Returns the device recipes for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, deviceRecipes.*, or deviceRecipes.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of device recipes (https://api.losant.com/#/definitions/deviceRecipes) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "page" in kwargs: query_params["page"] = kwargs["page"] if "perPage" in kwargs: query_params["perPage"] = kwargs["perPage"] if "filterField" in kwargs: query_params["filterField"] = kwargs["filterField"] if "filter" in kwargs: query_params["filter"] = kwargs["filter"] if "tagsAsObject" in kwargs: query_params["tagsAsObject"] = kwargs["tagsAsObject"] if "attributesAsObject" in kwargs: query_params["attributesAsObject"] = kwargs["attributesAsObject"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/device-recipes".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def post(self, **kwargs): """ Create a new device recipe for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, deviceRecipes.*, or deviceRecipes.post. Parameters: * {string} applicationId - ID associated with the application * {hash} deviceRecipe - New device recipe information (https://api.losant.com/#/definitions/deviceRecipePost) * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - Successfully created device recipe (https://api.losant.com/#/definitions/deviceRecipe) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deviceRecipe" in kwargs: body = kwargs["deviceRecipe"] if "tagsAsObject" in kwargs: query_params["tagsAsObject"] = kwargs["tagsAsObject"] if "attributesAsObject" in kwargs: query_params["attributesAsObject"] = kwargs["attributesAsObject"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/device-recipes".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class DeviceRecipes(object): ''' Class containing all the actions for the Device Recipes Resource ''' def __init__(self, client): pass def get(self, **kwargs): ''' Returns the device recipes for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, deviceRecipes.*, or deviceRecipes.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of device recipes (https://api.losant.com/#/definitions/deviceRecipes) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def post(self, **kwargs): ''' Create a new device recipe for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, deviceRecipes.*, or deviceRecipes.post. Parameters: * {string} applicationId - ID associated with the application * {hash} deviceRecipe - New device recipe information (https://api.losant.com/#/definitions/deviceRecipePost) * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - Successfully created device recipe (https://api.losant.com/#/definitions/deviceRecipe) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass
4
3
41
5
19
16
8
0.85
1
0
0
0
3
1
3
3
128
19
59
15
55
50
59
15
55
14
1
1
24
147,264
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/devices.py
platformrest.devices.Devices
class Devices(object): """ Class containing all the actions for the Devices Resource """ def __init__(self, client): self.client = client def attribute_names(self, **kwargs): """ Gets the attribute names that match the given query. Maximum 1K returned. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.attributeNames. Parameters: * {string} applicationId - ID associated with the application * {hash} query - Device filter JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery) * {hash} dataType - Filter the devices by the given attribute data type or types (https://api.losant.com/#/definitions/deviceAttributeDataTypeFilter) * {string} startsWith - Filter attributes down to those that have names starting with the given string. Case insensitive. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The matching attribute names (https://api.losant.com/#/definitions/attributeNamesResponse) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "query" in kwargs: query_params["query"] = json.dumps(kwargs["query"]) if "dataType" in kwargs: query_params["dataType"] = kwargs["dataType"] if "startsWith" in kwargs: query_params["startsWith"] = kwargs["startsWith"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/attributeNames".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def delete(self, **kwargs): """ Delete devices Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, devices.*, or devices.delete. Parameters: * {string} applicationId - ID associated with the application * {hash} options - Object containing device deletion options (https://api.losant.com/#/definitions/devicesDeleteOrRestorePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Object indicating number of devices deleted or failed (https://api.losant.com/#/definitions/bulkDeleteResponse) * 202 - If a job was enqueued for the devices to be deleted (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "options" in kwargs: body = kwargs["options"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/delete".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def device_names(self, **kwargs): """ Gets the device names that match the given query. Maximum 1K returned. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.deviceNames. Parameters: * {string} applicationId - ID associated with the application * {hash} query - Device filter JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery) * {string} startsWith - Filter devices down to those that have names starting with the given string. Case insensitive. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The matching device names (https://api.losant.com/#/definitions/deviceNamesResponse) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "query" in kwargs: query_params["query"] = json.dumps(kwargs["query"]) if "startsWith" in kwargs: query_params["startsWith"] = kwargs["startsWith"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/deviceNames".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def export(self, **kwargs): """ Creates an export of all device metadata Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.export. Parameters: * {string} applicationId - ID associated with the application * {string} email - Email address to send export to. Defaults to current user's email. * {string} callbackUrl - Callback URL to call with export result * {hash} options - Object containing device query and optionally email or callback (https://api.losant.com/#/definitions/devicesExportPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If generation of export was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "email" in kwargs: query_params["email"] = kwargs["email"] if "callbackUrl" in kwargs: query_params["callbackUrl"] = kwargs["callbackUrl"] if "options" in kwargs: body = kwargs["options"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/export".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Returns the devices for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated, connectionStatus, deletedAt * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {hash} deviceClass - Filter the devices by the given device class or classes (https://api.losant.com/#/definitions/deviceClassFilter) * {hash} tagFilter - Array of tag pairs to filter by (https://api.losant.com/#/definitions/deviceTagFilter) * {string} excludeConnectionInfo - If set, do not return connection info * {string} parentId - Filter devices as children of a given system id * {hash} query - Device filter JSON object which overrides the filterField, filter, deviceClass, tagFilter, and parentId parameters. (https://api.losant.com/#/definitions/advancedDeviceQuery) * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} queryDeleted - If true, endpoint will return recently deleted devices instead * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of devices (https://api.losant.com/#/definitions/devices) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "page" in kwargs: query_params["page"] = kwargs["page"] if "perPage" in kwargs: query_params["perPage"] = kwargs["perPage"] if "filterField" in kwargs: query_params["filterField"] = kwargs["filterField"] if "filter" in kwargs: query_params["filter"] = kwargs["filter"] if "deviceClass" in kwargs: query_params["deviceClass"] = kwargs["deviceClass"] if "tagFilter" in kwargs: query_params["tagFilter"] = kwargs["tagFilter"] if "excludeConnectionInfo" in kwargs: query_params["excludeConnectionInfo"] = kwargs["excludeConnectionInfo"] if "parentId" in kwargs: query_params["parentId"] = kwargs["parentId"] if "query" in kwargs: query_params["query"] = json.dumps(kwargs["query"]) if "tagsAsObject" in kwargs: query_params["tagsAsObject"] = kwargs["tagsAsObject"] if "attributesAsObject" in kwargs: query_params["attributesAsObject"] = kwargs["attributesAsObject"] if "queryDeleted" in kwargs: query_params["queryDeleted"] = kwargs["queryDeleted"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def get_composite_state(self, **kwargs): """ Retrieve the composite last complete state of the matching devices Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.getCompositeState. Parameters: * {string} applicationId - ID associated with the application * {string} start - Start of time range to look at to build composite state * {string} end - End of time range to look at to build composite state * {string} attributes - Comma-separated list of attributes to include. When not provided, returns all attributes. * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated, connectionStatus * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {hash} query - Device advanced query JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of composite last state of the devices (https://api.losant.com/#/definitions/compositeDevicesState) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "attributes" in kwargs: query_params["attributes"] = kwargs["attributes"] if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "page" in kwargs: query_params["page"] = kwargs["page"] if "perPage" in kwargs: query_params["perPage"] = kwargs["perPage"] if "query" in kwargs: query_params["query"] = json.dumps(kwargs["query"]) if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/compositeState".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def patch(self, **kwargs): """ Update the fields of one or more devices Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, devices.*, or devices.patch. Parameters: * {string} applicationId - ID associated with the application * {hash} patchInfo - Object containing device query or IDs and update operations (https://api.losant.com/#/definitions/devicesPatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Object including an update log link and the number of devices updated, failed, and skipped (https://api.losant.com/#/definitions/devicesUpdated) * 202 - Successfully queued bulk update job (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "patchInfo" in kwargs: body = kwargs["patchInfo"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body) def payload_counts(self, **kwargs): """ Creates an export of payload count information for the matching devices Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.payloadCounts. Parameters: * {string} applicationId - ID associated with the application * {hash} options - Object containing export configuration (https://api.losant.com/#/definitions/devicesExportPayloadCountPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If generation of export was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "options" in kwargs: body = kwargs["options"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/payloadCounts".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def post(self, **kwargs): """ Create a new device for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, devices.*, or devices.post. Parameters: * {string} applicationId - ID associated with the application * {hash} device - New device information (https://api.losant.com/#/definitions/devicePost) * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - Successfully created device (https://api.losant.com/#/definitions/device) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "device" in kwargs: body = kwargs["device"] if "tagsAsObject" in kwargs: query_params["tagsAsObject"] = kwargs["tagsAsObject"] if "attributesAsObject" in kwargs: query_params["attributesAsObject"] = kwargs["attributesAsObject"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def remove_data(self, **kwargs): """ Removes all device data for the specified time range. Defaults to all data. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, devices.*, or devices.removeData. Parameters: * {string} applicationId - ID associated with the application * {hash} options - Object defining the device data to delete and devices to delete from (https://api.losant.com/#/definitions/devicesRemoveDataPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If a job was enqueued for device data to be removed (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "options" in kwargs: body = kwargs["options"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/removeData".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def restore(self, **kwargs): """ Restore deleted devices Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, devices.*, or devices.restore. Parameters: * {string} applicationId - ID associated with the application * {hash} options - Object containing device restoration options (https://api.losant.com/#/definitions/devicesDeleteOrRestorePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Object indicating number of devices restored or failed (https://api.losant.com/#/definitions/bulkRestoreResponse) * 202 - If a job was enqueued for the devices to be restored (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "options" in kwargs: body = kwargs["options"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/restore".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def send_command(self, **kwargs): """ Send a command to multiple devices Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Device, all.Organization, all.User, devices.*, or devices.sendCommand. Parameters: * {string} applicationId - ID associated with the application * {hash} multiDeviceCommand - Command to send to the device (https://api.losant.com/#/definitions/multiDeviceCommand) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If command was successfully sent (https://api.losant.com/#/definitions/success) * 202 - If command was queued to be sent (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "multiDeviceCommand" in kwargs: body = kwargs["multiDeviceCommand"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/command".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def tag_keys(self, **kwargs): """ Gets the unique tag keys for devices that match the given query. Maximum 1K returned. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.tagKeys. Parameters: * {string} applicationId - ID associated with the application * {hash} query - Device filter JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery) * {string} startsWith - Filter keys down to those that start with the given string. Case insensitive. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The matching tag keys (https://api.losant.com/#/definitions/tagKeysResponse) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "query" in kwargs: query_params["query"] = json.dumps(kwargs["query"]) if "startsWith" in kwargs: query_params["startsWith"] = kwargs["startsWith"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/tagKeys".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def tag_values(self, **kwargs): """ Gets the unique tag values for the given key for devices that match the given query. Maximum 1K returned. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.tagValues. Parameters: * {string} applicationId - ID associated with the application * {hash} query - Device filter JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery) * {string} key - The tag key to get the values for * {string} startsWith - Filter values down to those that start with the given string. Case insensitive. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The matching tag values (https://api.losant.com/#/definitions/tagValuesResponse) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "query" in kwargs: query_params["query"] = json.dumps(kwargs["query"]) if "key" in kwargs: query_params["key"] = kwargs["key"] if "startsWith" in kwargs: query_params["startsWith"] = kwargs["startsWith"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/devices/tagValues".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body)
class Devices(object): ''' Class containing all the actions for the Devices Resource ''' def __init__(self, client): pass def attribute_names(self, **kwargs): ''' Gets the attribute names that match the given query. Maximum 1K returned. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.attributeNames. Parameters: * {string} applicationId - ID associated with the application * {hash} query - Device filter JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery) * {hash} dataType - Filter the devices by the given attribute data type or types (https://api.losant.com/#/definitions/deviceAttributeDataTypeFilter) * {string} startsWith - Filter attributes down to those that have names starting with the given string. Case insensitive. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The matching attribute names (https://api.losant.com/#/definitions/attributeNamesResponse) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def delete(self, **kwargs): ''' Delete devices Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, devices.*, or devices.delete. Parameters: * {string} applicationId - ID associated with the application * {hash} options - Object containing device deletion options (https://api.losant.com/#/definitions/devicesDeleteOrRestorePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Object indicating number of devices deleted or failed (https://api.losant.com/#/definitions/bulkDeleteResponse) * 202 - If a job was enqueued for the devices to be deleted (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def device_names(self, **kwargs): ''' Gets the device names that match the given query. Maximum 1K returned. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.deviceNames. Parameters: * {string} applicationId - ID associated with the application * {hash} query - Device filter JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery) * {string} startsWith - Filter devices down to those that have names starting with the given string. Case insensitive. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The matching device names (https://api.losant.com/#/definitions/deviceNamesResponse) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def export(self, **kwargs): ''' Creates an export of all device metadata Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.export. Parameters: * {string} applicationId - ID associated with the application * {string} email - Email address to send export to. Defaults to current user's email. * {string} callbackUrl - Callback URL to call with export result * {hash} options - Object containing device query and optionally email or callback (https://api.losant.com/#/definitions/devicesExportPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If generation of export was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Returns the devices for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated, connectionStatus, deletedAt * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {hash} deviceClass - Filter the devices by the given device class or classes (https://api.losant.com/#/definitions/deviceClassFilter) * {hash} tagFilter - Array of tag pairs to filter by (https://api.losant.com/#/definitions/deviceTagFilter) * {string} excludeConnectionInfo - If set, do not return connection info * {string} parentId - Filter devices as children of a given system id * {hash} query - Device filter JSON object which overrides the filterField, filter, deviceClass, tagFilter, and parentId parameters. (https://api.losant.com/#/definitions/advancedDeviceQuery) * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} queryDeleted - If true, endpoint will return recently deleted devices instead * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of devices (https://api.losant.com/#/definitions/devices) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def get_composite_state(self, **kwargs): ''' Retrieve the composite last complete state of the matching devices Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.getCompositeState. Parameters: * {string} applicationId - ID associated with the application * {string} start - Start of time range to look at to build composite state * {string} end - End of time range to look at to build composite state * {string} attributes - Comma-separated list of attributes to include. When not provided, returns all attributes. * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated, connectionStatus * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {hash} query - Device advanced query JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of composite last state of the devices (https://api.losant.com/#/definitions/compositeDevicesState) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def patch(self, **kwargs): ''' Update the fields of one or more devices Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, devices.*, or devices.patch. Parameters: * {string} applicationId - ID associated with the application * {hash} patchInfo - Object containing device query or IDs and update operations (https://api.losant.com/#/definitions/devicesPatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Object including an update log link and the number of devices updated, failed, and skipped (https://api.losant.com/#/definitions/devicesUpdated) * 202 - Successfully queued bulk update job (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def payload_counts(self, **kwargs): ''' Creates an export of payload count information for the matching devices Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.payloadCounts. Parameters: * {string} applicationId - ID associated with the application * {hash} options - Object containing export configuration (https://api.losant.com/#/definitions/devicesExportPayloadCountPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If generation of export was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def post(self, **kwargs): ''' Create a new device for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, devices.*, or devices.post. Parameters: * {string} applicationId - ID associated with the application * {hash} device - New device information (https://api.losant.com/#/definitions/devicePost) * {string} tagsAsObject - Return tags as an object map instead of an array * {string} attributesAsObject - Return attributes as an object map instead of an array * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - Successfully created device (https://api.losant.com/#/definitions/device) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def remove_data(self, **kwargs): ''' Removes all device data for the specified time range. Defaults to all data. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, devices.*, or devices.removeData. Parameters: * {string} applicationId - ID associated with the application * {hash} options - Object defining the device data to delete and devices to delete from (https://api.losant.com/#/definitions/devicesRemoveDataPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 202 - If a job was enqueued for device data to be removed (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def restore(self, **kwargs): ''' Restore deleted devices Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, devices.*, or devices.restore. Parameters: * {string} applicationId - ID associated with the application * {hash} options - Object containing device restoration options (https://api.losant.com/#/definitions/devicesDeleteOrRestorePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Object indicating number of devices restored or failed (https://api.losant.com/#/definitions/bulkRestoreResponse) * 202 - If a job was enqueued for the devices to be restored (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def send_command(self, **kwargs): ''' Send a command to multiple devices Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Device, all.Organization, all.User, devices.*, or devices.sendCommand. Parameters: * {string} applicationId - ID associated with the application * {hash} multiDeviceCommand - Command to send to the device (https://api.losant.com/#/definitions/multiDeviceCommand) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If command was successfully sent (https://api.losant.com/#/definitions/success) * 202 - If command was queued to be sent (https://api.losant.com/#/definitions/jobEnqueuedResult) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def tag_keys(self, **kwargs): ''' Gets the unique tag keys for devices that match the given query. Maximum 1K returned. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.tagKeys. Parameters: * {string} applicationId - ID associated with the application * {hash} query - Device filter JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery) * {string} startsWith - Filter keys down to those that start with the given string. Case insensitive. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The matching tag keys (https://api.losant.com/#/definitions/tagKeysResponse) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def tag_values(self, **kwargs): ''' Gets the unique tag values for the given key for devices that match the given query. Maximum 1K returned. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.tagValues. Parameters: * {string} applicationId - ID associated with the application * {hash} query - Device filter JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery) * {string} key - The tag key to get the values for * {string} startsWith - Filter values down to those that start with the given string. Case insensitive. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The matching tag values (https://api.losant.com/#/definitions/tagValuesResponse) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass
16
15
50
7
22
21
9
0.96
1
0
0
0
15
1
15
15
771
127
329
87
313
315
329
87
313
20
1
1
129
147,265
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/edge_deployment.py
platformrest.edge_deployment.EdgeDeployment
class EdgeDeployment(object): """ Class containing all the actions for the Edge Deployment Resource """ def __init__(self, client): self.client = client def get(self, **kwargs): """ Retrieves information on an edge deployment Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, edgeDeployment.*, or edgeDeployment.get. Parameters: * {string} applicationId - ID associated with the application * {string} edgeDeploymentId - ID associated with the edge deployment * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Edge deployment information (https://api.losant.com/#/definitions/edgeDeployment) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if edge deployment was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "edgeDeploymentId" in kwargs: path_params["edgeDeploymentId"] = kwargs["edgeDeploymentId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/edge/deployments/{edgeDeploymentId}".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body)
class EdgeDeployment(object): ''' Class containing all the actions for the Edge Deployment Resource ''' def __init__(self, client): pass def get(self, **kwargs): ''' Retrieves information on an edge deployment Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, edgeDeployment.*, or edgeDeployment.get. Parameters: * {string} applicationId - ID associated with the application * {string} edgeDeploymentId - ID associated with the edge deployment * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Edge deployment information (https://api.losant.com/#/definitions/edgeDeployment) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if edge deployment was not found (https://api.losant.com/#/definitions/error) ''' pass
3
2
25
4
11
10
4
0.95
1
0
0
0
2
1
2
2
53
10
22
9
19
21
22
9
19
7
1
1
8
147,266
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/edge_deployments.py
platformrest.edge_deployments.EdgeDeployments
class EdgeDeployments(object): """ Class containing all the actions for the Edge Deployments Resource """ def __init__(self, client): self.client = client def get(self, **kwargs): """ Returns the edge deployments for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, edgeDeployments.*, or edgeDeployments.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: id, deviceId, flowId, desiredVersion, currentVersion, creationDate, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} deviceId - Filter deployments to the given Device ID * {string} version - Filter deployments to the given Workflow Version (matches against both current and desired) * {undefined} filterEmpty - Filter out deployments where both the current and desired version are null. * {string} flowId - Filter deployments to the given Workflow ID * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of edge deployments (https://api.losant.com/#/definitions/edgeDeployments) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "page" in kwargs: query_params["page"] = kwargs["page"] if "perPage" in kwargs: query_params["perPage"] = kwargs["perPage"] if "deviceId" in kwargs: query_params["deviceId"] = kwargs["deviceId"] if "version" in kwargs: query_params["version"] = kwargs["version"] if "filterEmpty" in kwargs: query_params["filterEmpty"] = kwargs["filterEmpty"] if "flowId" in kwargs: query_params["flowId"] = kwargs["flowId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/edge/deployments".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def release(self, **kwargs): """ Deploy an edge workflow version to one or more edge devices. Version can be blank, if removal is desired. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, edgeDeployments.*, or edgeDeployments.release. Parameters: * {string} applicationId - ID associated with the application * {hash} deployment - Deployment release information (https://api.losant.com/#/definitions/edgeDeploymentRelease) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - If deployment release has been initiated successfully (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deployment" in kwargs: body = kwargs["deployment"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/edge/deployments/release".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def remove(self, **kwargs): """ Remove all edge deployments from a device, remove all edge deployments of a workflow, or remove a specific workflow from a specific device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, edgeDeployments.*, or edgeDeployments.remove. Parameters: * {string} applicationId - ID associated with the application * {hash} deployment - Deployment removal information (https://api.losant.com/#/definitions/edgeDeploymentRemove) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - If deployment removal has been initiated successfully (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deployment" in kwargs: body = kwargs["deployment"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/edge/deployments/remove".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body) def replace(self, **kwargs): """ Replace deployments of an edge workflow version with a new version. New version can be blank, if removal is desired. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, edgeDeployments.*, or edgeDeployments.replace. Parameters: * {string} applicationId - ID associated with the application * {hash} deployment - Deployment replacement information (https://api.losant.com/#/definitions/edgeDeploymentReplace) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - If deployment replacement has been initiated successfully (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "deployment" in kwargs: body = kwargs["deployment"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/edge/deployments/replace".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class EdgeDeployments(object): ''' Class containing all the actions for the Edge Deployments Resource ''' def __init__(self, client): pass def get(self, **kwargs): ''' Returns the edge deployments for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, edgeDeployments.*, or edgeDeployments.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: id, deviceId, flowId, desiredVersion, currentVersion, creationDate, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} deviceId - Filter deployments to the given Device ID * {string} version - Filter deployments to the given Workflow Version (matches against both current and desired) * {undefined} filterEmpty - Filter out deployments where both the current and desired version are null. * {string} flowId - Filter deployments to the given Workflow ID * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of edge deployments (https://api.losant.com/#/definitions/edgeDeployments) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def release(self, **kwargs): ''' Deploy an edge workflow version to one or more edge devices. Version can be blank, if removal is desired. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, edgeDeployments.*, or edgeDeployments.release. Parameters: * {string} applicationId - ID associated with the application * {hash} deployment - Deployment release information (https://api.losant.com/#/definitions/edgeDeploymentRelease) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - If deployment release has been initiated successfully (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def remove(self, **kwargs): ''' Remove all edge deployments from a device, remove all edge deployments of a workflow, or remove a specific workflow from a specific device Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, edgeDeployments.*, or edgeDeployments.remove. Parameters: * {string} applicationId - ID associated with the application * {hash} deployment - Deployment removal information (https://api.losant.com/#/definitions/edgeDeploymentRemove) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - If deployment removal has been initiated successfully (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def replace(self, **kwargs): ''' Replace deployments of an edge workflow version with a new version. New version can be blank, if removal is desired. Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, edgeDeployments.*, or edgeDeployments.replace. Parameters: * {string} applicationId - ID associated with the application * {hash} deployment - Deployment replacement information (https://api.losant.com/#/definitions/edgeDeploymentReplace) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - If deployment replacement has been initiated successfully (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass
6
5
42
6
18
17
7
0.95
1
0
0
0
5
1
5
5
218
37
93
27
87
88
93
27
87
14
1
1
36
147,267
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/instance_org_members.py
platformrest.instance_org_members.InstanceOrgMembers
class InstanceOrgMembers(object): """ Class containing all the actions for the Instance Org Members Resource """ def __init__(self, client): self.client = client def get(self, **kwargs): """ Returns a collection of instance organization members Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrgMembers.*, or instanceOrgMembers.get. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} sortField - Field to sort the results by. Accepted values are: email, role * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: email, role * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A collection of instance organization members (https://api.losant.com/#/definitions/instanceOrgMembers) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "filterField" in kwargs: query_params["filterField"] = kwargs["filterField"] if "filter" in kwargs: query_params["filter"] = kwargs["filter"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/members".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def post(self, **kwargs): """ Creates a new organization member Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgMembers.*, or instanceOrgMembers.post. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {hash} member - Object containing new member info (https://api.losant.com/#/definitions/instanceOrgMemberPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The newly created instance member (https://api.losant.com/#/definitions/instanceOrgMember) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "member" in kwargs: body = kwargs["member"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/members".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class InstanceOrgMembers(object): ''' Class containing all the actions for the Instance Org Members Resource ''' def __init__(self, client): pass def get(self, **kwargs): ''' Returns a collection of instance organization members Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrgMembers.*, or instanceOrgMembers.get. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} sortField - Field to sort the results by. Accepted values are: email, role * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: email, role * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A collection of instance organization members (https://api.losant.com/#/definitions/instanceOrgMembers) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance was not found (https://api.losant.com/#/definitions/error) ''' pass def post(self, **kwargs): ''' Creates a new organization member Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgMembers.*, or instanceOrgMembers.post. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {hash} member - Object containing new member info (https://api.losant.com/#/definitions/instanceOrgMemberPost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The newly created instance member (https://api.losant.com/#/definitions/instanceOrgMember) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance was not found (https://api.losant.com/#/definitions/error) ''' pass
4
3
37
5
17
15
7
0.9
1
0
0
0
3
1
3
3
116
19
51
15
47
46
51
15
47
11
1
1
20
147,268
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/instance_org_member.py
platformrest.instance_org_member.InstanceOrgMember
class InstanceOrgMember(object): """ Class containing all the actions for the Instance Org Member Resource """ def __init__(self, client): self.client = client def delete(self, **kwargs): """ Deletes an organization member Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgMember.*, or instanceOrgMember.delete. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} userId - ID associated with the organization member * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If member was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if organization or member was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "userId" in kwargs: path_params["userId"] = kwargs["userId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/members/{userId}".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Returns an organization member Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrgMember.*, or instanceOrgMember.get. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} userId - ID associated with the organization member * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A single organization member (https://api.losant.com/#/definitions/instanceOrgMember) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance, organization, or member was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "userId" in kwargs: path_params["userId"] = kwargs["userId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/members/{userId}".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def patch(self, **kwargs): """ Modifies the role of an organization member Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgMember.*, or instanceOrgMember.patch. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} userId - ID associated with the organization member * {hash} member - Object containing new member info (https://api.losant.com/#/definitions/instanceOrgMemberPatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The modified organization member (https://api.losant.com/#/definitions/instanceOrgMember) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if organization or member was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "userId" in kwargs: path_params["userId"] = kwargs["userId"] if "member" in kwargs: body = kwargs["member"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/members/{userId}".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body)
class InstanceOrgMember(object): ''' Class containing all the actions for the Instance Org Member Resource ''' def __init__(self, client): pass def delete(self, **kwargs): ''' Deletes an organization member Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgMember.*, or instanceOrgMember.delete. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} userId - ID associated with the organization member * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If member was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if organization or member was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Returns an organization member Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrgMember.*, or instanceOrgMember.get. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} userId - ID associated with the organization member * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A single organization member (https://api.losant.com/#/definitions/instanceOrgMember) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance, organization, or member was not found (https://api.losant.com/#/definitions/error) ''' pass def patch(self, **kwargs): ''' Modifies the role of an organization member Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgMember.*, or instanceOrgMember.patch. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} userId - ID associated with the organization member * {hash} member - Object containing new member info (https://api.losant.com/#/definitions/instanceOrgMemberPatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - The modified organization member (https://api.losant.com/#/definitions/instanceOrgMember) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if organization or member was not found (https://api.losant.com/#/definitions/error) ''' pass
5
4
39
6
17
16
7
0.96
1
0
0
0
4
1
4
4
161
28
68
21
63
65
68
21
63
9
1
1
26
147,269
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/instance_org_invites.py
platformrest.instance_org_invites.InstanceOrgInvites
class InstanceOrgInvites(object): """ Class containing all the actions for the Instance Org Invites Resource """ def __init__(self, client): self.client = client def get(self, **kwargs): """ Returns a collection of instance organization invites Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrgInvites.*, or instanceOrgInvites.get. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} sortField - Field to sort the results by. Accepted values are: email, role, inviteDate * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: email, role * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A collection of instance organization invitations (https://api.losant.com/#/definitions/orgInviteCollection) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "filterField" in kwargs: query_params["filterField"] = kwargs["filterField"] if "filter" in kwargs: query_params["filter"] = kwargs["filter"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/invites".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def post(self, **kwargs): """ Invites a member to an instance organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgInvites.*, or instanceOrgInvites.post. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {hash} invite - Object containing new invite info (https://api.losant.com/#/definitions/orgInvitePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - The new organization invite (https://api.losant.com/#/definitions/orgInviteCollection) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "invite" in kwargs: body = kwargs["invite"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/invites".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class InstanceOrgInvites(object): ''' Class containing all the actions for the Instance Org Invites Resource ''' def __init__(self, client): pass def get(self, **kwargs): ''' Returns a collection of instance organization invites Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrgInvites.*, or instanceOrgInvites.get. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} sortField - Field to sort the results by. Accepted values are: email, role, inviteDate * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: email, role * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A collection of instance organization invitations (https://api.losant.com/#/definitions/orgInviteCollection) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) ''' pass def post(self, **kwargs): ''' Invites a member to an instance organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgInvites.*, or instanceOrgInvites.post. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {hash} invite - Object containing new invite info (https://api.losant.com/#/definitions/orgInvitePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - The new organization invite (https://api.losant.com/#/definitions/orgInviteCollection) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) ''' pass
4
3
37
5
17
15
7
0.9
1
0
0
0
3
1
3
3
116
19
51
15
47
46
51
15
47
11
1
1
20
147,270
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/instance_org_invite.py
platformrest.instance_org_invite.InstanceOrgInvite
class InstanceOrgInvite(object): """ Class containing all the actions for the Instance Org Invite Resource """ def __init__(self, client): self.client = client def delete(self, **kwargs): """ Revokes an instance org invitation Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgInvite.*, or instanceOrgInvite.delete. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} inviteId - ID associated with the organization invite * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If an invite was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance, organization or invite was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "inviteId" in kwargs: path_params["inviteId"] = kwargs["inviteId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/invites/{inviteId}".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Returns an organization invite Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrgInvite.*, or instanceOrgInvite.get. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} inviteId - ID associated with the organization invite * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A single organization invite (https://api.losant.com/#/definitions/orgInvite) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance, organization, or invite was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "inviteId" in kwargs: path_params["inviteId"] = kwargs["inviteId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/invites/{inviteId}".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def resend_invite(self, **kwargs): """ Resend an organization invite with modified role info Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgInvite.*, or instanceOrgInvite.resendInvite. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} inviteId - ID associated with the organization invite * {hash} roleInfo - Object containing updated role info (https://api.losant.com/#/definitions/orgRoleInfo) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - The new org invite (https://api.losant.com/#/definitions/orgInvite) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance, organization, or invite was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "inviteId" in kwargs: path_params["inviteId"] = kwargs["inviteId"] if "roleInfo" in kwargs: body = kwargs["roleInfo"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/invites/{inviteId}".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class InstanceOrgInvite(object): ''' Class containing all the actions for the Instance Org Invite Resource ''' def __init__(self, client): pass def delete(self, **kwargs): ''' Revokes an instance org invitation Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgInvite.*, or instanceOrgInvite.delete. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} inviteId - ID associated with the organization invite * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If an invite was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance, organization or invite was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Returns an organization invite Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrgInvite.*, or instanceOrgInvite.get. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} inviteId - ID associated with the organization invite * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A single organization invite (https://api.losant.com/#/definitions/orgInvite) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance, organization, or invite was not found (https://api.losant.com/#/definitions/error) ''' pass def resend_invite(self, **kwargs): ''' Resend an organization invite with modified role info Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrgInvite.*, or instanceOrgInvite.resendInvite. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} inviteId - ID associated with the organization invite * {hash} roleInfo - Object containing updated role info (https://api.losant.com/#/definitions/orgRoleInfo) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - The new org invite (https://api.losant.com/#/definitions/orgInvite) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance, organization, or invite was not found (https://api.losant.com/#/definitions/error) ''' pass
5
4
39
6
17
16
7
0.96
1
0
0
0
4
1
4
4
161
28
68
21
63
65
68
21
63
9
1
1
26
147,271
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/instance_org.py
platformrest.instance_org.InstanceOrg
class InstanceOrg(object): """ Class containing all the actions for the Instance Org Resource """ def __init__(self, client): self.client = client def delete(self, **kwargs): """ Deletes an organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrg.*, or instanceOrg.delete. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If organization was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body) def device_counts(self, **kwargs): """ Returns device counts by day for the time range specified for this organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrg.*, or instanceOrg.deviceCounts. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} start - Start of range for device count query (ms since epoch) * {string} end - End of range for device count query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Device counts by day (https://api.losant.com/#/definitions/deviceCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/deviceCounts".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Retrieves information on an organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrg.*, or instanceOrg.get. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} summaryInclude - Comma-separated list of summary fields to include in org summary * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A single organization (https://api.losant.com/#/definitions/instanceOrg) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "summaryInclude" in kwargs: query_params["summaryInclude"] = kwargs["summaryInclude"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def notebook_minute_counts(self, **kwargs): """ Returns notebook execution usage by day for the time range specified for this organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrg.*, or instanceOrg.notebookMinuteCounts. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} start - Start of range for notebook execution query (ms since epoch) * {string} end - End of range for notebook execution query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Notebook usage information (https://api.losant.com/#/definitions/notebookMinuteCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/notebookMinuteCounts".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def patch(self, **kwargs): """ Updates information about an organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrg.*, or instanceOrg.patch. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} summaryInclude - Comma-separated list of summary fields to include in org summary * {hash} organization - Object containing new organization properties (https://api.losant.com/#/definitions/instanceOrgPatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated organization information (https://api.losant.com/#/definitions/instanceOrg) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "summaryInclude" in kwargs: query_params["summaryInclude"] = kwargs["summaryInclude"] if "organization" in kwargs: body = kwargs["organization"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body) def payload_counts(self, **kwargs): """ Returns payload counts for the time range specified for all applications this organization owns Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrg.*, or instanceOrg.payloadCounts. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} asBytes - If the resulting stats should be returned as bytes * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Payload counts, by type and source (https://api.losant.com/#/definitions/payloadStats) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "asBytes" in kwargs: query_params["asBytes"] = kwargs["asBytes"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/payloadCounts".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def payload_counts_breakdown(self, **kwargs): """ Returns payload counts per resolution in the time range specified for all application this organization owns Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrg.*, or instanceOrg.payloadCountsBreakdown. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} resolution - Resolution in milliseconds. Accepted values are: 86400000, 3600000 * {string} asBytes - If the resulting stats should be returned as bytes * {string} includeNonBillable - If non-billable payloads should be included in the result * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Payload counts, by type and source (https://api.losant.com/#/definitions/payloadCountsBreakdown) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "orgId" in kwargs: path_params["orgId"] = kwargs["orgId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "resolution" in kwargs: query_params["resolution"] = kwargs["resolution"] if "asBytes" in kwargs: query_params["asBytes"] = kwargs["asBytes"] if "includeNonBillable" in kwargs: query_params["includeNonBillable"] = kwargs["includeNonBillable"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/orgs/{orgId}/payloadCountsBreakdown".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body)
class InstanceOrg(object): ''' Class containing all the actions for the Instance Org Resource ''' def __init__(self, client): pass def delete(self, **kwargs): ''' Deletes an organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrg.*, or instanceOrg.delete. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If organization was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) ''' pass def device_counts(self, **kwargs): ''' Returns device counts by day for the time range specified for this organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrg.*, or instanceOrg.deviceCounts. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} start - Start of range for device count query (ms since epoch) * {string} end - End of range for device count query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Device counts by day (https://api.losant.com/#/definitions/deviceCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Retrieves information on an organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrg.*, or instanceOrg.get. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} summaryInclude - Comma-separated list of summary fields to include in org summary * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A single organization (https://api.losant.com/#/definitions/instanceOrg) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) ''' pass def notebook_minute_counts(self, **kwargs): ''' Returns notebook execution usage by day for the time range specified for this organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrg.*, or instanceOrg.notebookMinuteCounts. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} start - Start of range for notebook execution query (ms since epoch) * {string} end - End of range for notebook execution query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Notebook usage information (https://api.losant.com/#/definitions/notebookMinuteCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) ''' pass def patch(self, **kwargs): ''' Updates information about an organization Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceOrg.*, or instanceOrg.patch. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} summaryInclude - Comma-separated list of summary fields to include in org summary * {hash} organization - Object containing new organization properties (https://api.losant.com/#/definitions/instanceOrgPatch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Updated organization information (https://api.losant.com/#/definitions/instanceOrg) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) ''' pass def payload_counts(self, **kwargs): ''' Returns payload counts for the time range specified for all applications this organization owns Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrg.*, or instanceOrg.payloadCounts. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} asBytes - If the resulting stats should be returned as bytes * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Payload counts, by type and source (https://api.losant.com/#/definitions/payloadStats) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) ''' pass def payload_counts_breakdown(self, **kwargs): ''' Returns payload counts per resolution in the time range specified for all application this organization owns Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceOrg.*, or instanceOrg.payloadCountsBreakdown. Parameters: * {string} instanceId - ID associated with the instance * {string} orgId - ID associated with the organization * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} resolution - Resolution in milliseconds. Accepted values are: 86400000, 3600000 * {string} asBytes - If the resulting stats should be returned as bytes * {string} includeNonBillable - If non-billable payloads should be included in the result * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Payload counts, by type and source (https://api.losant.com/#/definitions/payloadCountsBreakdown) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if instance or organization was not found (https://api.losant.com/#/definitions/error) ''' pass
9
8
47
7
21
19
8
0.94
1
0
0
0
8
1
8
8
386
64
166
45
157
156
166
45
157
12
1
1
65
147,272
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/instance_notification_rules.py
platformrest.instance_notification_rules.InstanceNotificationRules
class InstanceNotificationRules(object): """ Class containing all the actions for the Instance Notification Rules Resource """ def __init__(self, client): self.client = client def get(self, **kwargs): """ Returns the notification rules for an instance Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceNotificationRules.*, or instanceNotificationRules.get. Parameters: * {string} instanceId - ID associated with the instance * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of notification rules (https://api.losant.com/#/definitions/notificationRules) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "page" in kwargs: query_params["page"] = kwargs["page"] if "perPage" in kwargs: query_params["perPage"] = kwargs["perPage"] if "filterField" in kwargs: query_params["filterField"] = kwargs["filterField"] if "filter" in kwargs: query_params["filter"] = kwargs["filter"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/notification-rules".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def post(self, **kwargs): """ Create a new notification rule for an instance Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceNotificationRules.*, or instanceNotificationRules.post. Parameters: * {string} instanceId - ID associated with the instance * {hash} notificationRule - Notification rule information (https://api.losant.com/#/definitions/notificationRulePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - The successfully created notification rule (https://api.losant.com/#/definitions/notificationRule) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "notificationRule" in kwargs: body = kwargs["notificationRule"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/notification-rules".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class InstanceNotificationRules(object): ''' Class containing all the actions for the Instance Notification Rules Resource ''' def __init__(self, client): pass def get(self, **kwargs): ''' Returns the notification rules for an instance Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceNotificationRules.*, or instanceNotificationRules.get. Parameters: * {string} instanceId - ID associated with the instance * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of notification rules (https://api.losant.com/#/definitions/notificationRules) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) ''' pass def post(self, **kwargs): ''' Create a new notification rule for an instance Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceNotificationRules.*, or instanceNotificationRules.post. Parameters: * {string} instanceId - ID associated with the instance * {hash} notificationRule - Notification rule information (https://api.losant.com/#/definitions/notificationRulePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - The successfully created notification rule (https://api.losant.com/#/definitions/notificationRule) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) ''' pass
4
3
36
5
17
14
7
0.86
1
0
0
0
3
1
3
3
114
19
51
15
47
44
51
15
47
12
1
1
20
147,273
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/instance_sandbox.py
platformrest.instance_sandbox.InstanceSandbox
class InstanceSandbox(object): """ Class containing all the actions for the Instance Sandbox Resource """ def __init__(self, client): self.client = client def delete(self, **kwargs): """ Deletes a sandbox user account Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceSandbox.*, or instanceSandbox.delete. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If a sandbox was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "instanceSandboxId" in kwargs: path_params["instanceSandboxId"] = kwargs["instanceSandboxId"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/sandboxes/{instanceSandboxId}".format(**path_params) return self.client.request("DELETE", path, params=query_params, headers=headers, body=body) def device_counts(self, **kwargs): """ Returns device counts by day for the time range specified for all applications the sandbox user owns Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceSandbox.*, or instanceSandbox.deviceCounts. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} start - Start of range for device count query (ms since epoch) * {string} end - End of range for device count query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Device counts by day (https://api.losant.com/#/definitions/deviceCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "instanceSandboxId" in kwargs: path_params["instanceSandboxId"] = kwargs["instanceSandboxId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/sandboxes/{instanceSandboxId}/deviceCounts".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def get(self, **kwargs): """ Returns a sandbox user Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceSandbox.*, or instanceSandbox.get. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} summaryExclude - Comma-separated list of summary fields to exclude from user summary * {string} summaryInclude - Comma-separated list of summary fields to include in user summary * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A single sandbox user (https://api.losant.com/#/definitions/instanceSandbox) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "instanceSandboxId" in kwargs: path_params["instanceSandboxId"] = kwargs["instanceSandboxId"] if "summaryExclude" in kwargs: query_params["summaryExclude"] = kwargs["summaryExclude"] if "summaryInclude" in kwargs: query_params["summaryInclude"] = kwargs["summaryInclude"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/sandboxes/{instanceSandboxId}".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def notebook_minute_counts(self, **kwargs): """ Returns notebook execution usage by day for the time range specified for all applications the sandbox user owns Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceSandbox.*, or instanceSandbox.notebookMinuteCounts. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} start - Start of range for notebook execution query (ms since epoch) * {string} end - End of range for notebook execution query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Notebook usage information (https://api.losant.com/#/definitions/notebookMinuteCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "instanceSandboxId" in kwargs: path_params["instanceSandboxId"] = kwargs["instanceSandboxId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/sandboxes/{instanceSandboxId}/notebookMinuteCounts".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def payload_counts(self, **kwargs): """ Returns payload counts for the time range specified for all applications the sandbox user owns Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceSandbox.*, or instanceSandbox.payloadCounts. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} asBytes - If the resulting stats should be returned as bytes * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Payload counts, by type and source (https://api.losant.com/#/definitions/payloadStats) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "instanceSandboxId" in kwargs: path_params["instanceSandboxId"] = kwargs["instanceSandboxId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "asBytes" in kwargs: query_params["asBytes"] = kwargs["asBytes"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/sandboxes/{instanceSandboxId}/payloadCounts".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def payload_counts_breakdown(self, **kwargs): """ Returns payload counts per resolution in the time range specified for all applications the sandbox user owns Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceSandbox.*, or instanceSandbox.payloadCountsBreakdown. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} resolution - Resolution in milliseconds. Accepted values are: 86400000, 3600000 * {string} asBytes - If the resulting stats should be returned as bytes * {string} includeNonBillable - If non-billable payloads should be included in the result * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Sum of payload counts by date (https://api.losant.com/#/definitions/payloadCountsBreakdown) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "instanceSandboxId" in kwargs: path_params["instanceSandboxId"] = kwargs["instanceSandboxId"] if "start" in kwargs: query_params["start"] = kwargs["start"] if "end" in kwargs: query_params["end"] = kwargs["end"] if "resolution" in kwargs: query_params["resolution"] = kwargs["resolution"] if "asBytes" in kwargs: query_params["asBytes"] = kwargs["asBytes"] if "includeNonBillable" in kwargs: query_params["includeNonBillable"] = kwargs["includeNonBillable"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/sandboxes/{instanceSandboxId}/payloadCountsBreakdown".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def undelete(self, **kwargs): """ Restores a sandbox user account Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceSandbox.*, or instanceSandbox.undelete. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} summaryExclude - Comma-separated list of summary fields to exclude from user summary * {string} summaryInclude - Comma-separated list of summary fields to include in user summary * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A single restored sandbox user (https://api.losant.com/#/definitions/instanceSandbox) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "instanceSandboxId" in kwargs: path_params["instanceSandboxId"] = kwargs["instanceSandboxId"] if "summaryExclude" in kwargs: query_params["summaryExclude"] = kwargs["summaryExclude"] if "summaryInclude" in kwargs: query_params["summaryInclude"] = kwargs["summaryInclude"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/sandboxes/{instanceSandboxId}/undelete".format(**path_params) return self.client.request("PATCH", path, params=query_params, headers=headers, body=body)
class InstanceSandbox(object): ''' Class containing all the actions for the Instance Sandbox Resource ''' def __init__(self, client): pass def delete(self, **kwargs): ''' Deletes a sandbox user account Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceSandbox.*, or instanceSandbox.delete. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - If a sandbox was successfully deleted (https://api.losant.com/#/definitions/success) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) ''' pass def device_counts(self, **kwargs): ''' Returns device counts by day for the time range specified for all applications the sandbox user owns Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceSandbox.*, or instanceSandbox.deviceCounts. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} start - Start of range for device count query (ms since epoch) * {string} end - End of range for device count query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Device counts by day (https://api.losant.com/#/definitions/deviceCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) ''' pass def get(self, **kwargs): ''' Returns a sandbox user Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceSandbox.*, or instanceSandbox.get. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} summaryExclude - Comma-separated list of summary fields to exclude from user summary * {string} summaryInclude - Comma-separated list of summary fields to include in user summary * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A single sandbox user (https://api.losant.com/#/definitions/instanceSandbox) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) ''' pass def notebook_minute_counts(self, **kwargs): ''' Returns notebook execution usage by day for the time range specified for all applications the sandbox user owns Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceSandbox.*, or instanceSandbox.notebookMinuteCounts. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} start - Start of range for notebook execution query (ms since epoch) * {string} end - End of range for notebook execution query (ms since epoch) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Notebook usage information (https://api.losant.com/#/definitions/notebookMinuteCounts) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) ''' pass def payload_counts(self, **kwargs): ''' Returns payload counts for the time range specified for all applications the sandbox user owns Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceSandbox.*, or instanceSandbox.payloadCounts. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} asBytes - If the resulting stats should be returned as bytes * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Payload counts, by type and source (https://api.losant.com/#/definitions/payloadStats) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) ''' pass def payload_counts_breakdown(self, **kwargs): ''' Returns payload counts per resolution in the time range specified for all applications the sandbox user owns Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceSandbox.*, or instanceSandbox.payloadCountsBreakdown. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} start - Start of range for payload count query (ms since epoch) * {string} end - End of range for payload count query (ms since epoch) * {string} resolution - Resolution in milliseconds. Accepted values are: 86400000, 3600000 * {string} asBytes - If the resulting stats should be returned as bytes * {string} includeNonBillable - If non-billable payloads should be included in the result * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Sum of payload counts by date (https://api.losant.com/#/definitions/payloadCountsBreakdown) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) ''' pass def undelete(self, **kwargs): ''' Restores a sandbox user account Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.User, instanceSandbox.*, or instanceSandbox.undelete. Parameters: * {string} instanceId - ID associated with the instance * {string} instanceSandboxId - ID associated with the sandbox user * {string} summaryExclude - Comma-separated list of summary fields to exclude from user summary * {string} summaryInclude - Comma-separated list of summary fields to include in user summary * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - A single restored sandbox user (https://api.losant.com/#/definitions/instanceSandbox) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if sandbox or instance was not found (https://api.losant.com/#/definitions/error) ''' pass
9
8
47
7
21
20
8
0.93
1
0
0
0
8
1
8
8
389
64
168
45
159
157
168
45
159
12
1
1
66
147,274
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/instance_sandboxes.py
platformrest.instance_sandboxes.InstanceSandboxes
class InstanceSandboxes(object): """ Class containing all the actions for the Instance Sandboxes Resource """ def __init__(self, client): self.client = client def get(self, **kwargs): """ Returns a collection of instance sandboxes Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceSandboxes.*, or instanceSandboxes.get. Parameters: * {string} instanceId - ID associated with the instance * {string} summaryExclude - Comma-separated list of summary fields to exclude from user summary * {string} summaryInclude - Comma-separated list of summary fields to include in user summary * {string} sortField - Field to sort the results by. Accepted values are: firstName, lastName, email, id, creationDate, lastSuccessfulLogin, lastFailedLogin, failedLoginCount, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} startingAfterId - Exclusive ID from which to begin querying * {string} endingBeforeId - Exclusive ID at which to end querying * {string} limit - How many items to return * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: firstName, lastName, email * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} includeDeleted - If the result of the request should also include deleted sandboxes. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of instance sandboxes (https://api.losant.com/#/definitions/instanceSandboxes) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "instanceId" in kwargs: path_params["instanceId"] = kwargs["instanceId"] if "summaryExclude" in kwargs: query_params["summaryExclude"] = kwargs["summaryExclude"] if "summaryInclude" in kwargs: query_params["summaryInclude"] = kwargs["summaryInclude"] if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "startingAfterId" in kwargs: query_params["startingAfterId"] = kwargs["startingAfterId"] if "endingBeforeId" in kwargs: query_params["endingBeforeId"] = kwargs["endingBeforeId"] if "limit" in kwargs: query_params["limit"] = kwargs["limit"] if "filterField" in kwargs: query_params["filterField"] = kwargs["filterField"] if "filter" in kwargs: query_params["filter"] = kwargs["filter"] if "includeDeleted" in kwargs: query_params["includeDeleted"] = kwargs["includeDeleted"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances/{instanceId}/sandboxes".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body)
class InstanceSandboxes(object): ''' Class containing all the actions for the Instance Sandboxes Resource ''' def __init__(self, client): pass def get(self, **kwargs): ''' Returns a collection of instance sandboxes Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Instance, all.Instance.read, all.User, all.User.read, instanceSandboxes.*, or instanceSandboxes.get. Parameters: * {string} instanceId - ID associated with the instance * {string} summaryExclude - Comma-separated list of summary fields to exclude from user summary * {string} summaryInclude - Comma-separated list of summary fields to include in user summary * {string} sortField - Field to sort the results by. Accepted values are: firstName, lastName, email, id, creationDate, lastSuccessfulLogin, lastFailedLogin, failedLoginCount, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} startingAfterId - Exclusive ID from which to begin querying * {string} endingBeforeId - Exclusive ID at which to end querying * {string} limit - How many items to return * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: firstName, lastName, email * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} includeDeleted - If the result of the request should also include deleted sandboxes. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of instance sandboxes (https://api.losant.com/#/definitions/instanceSandboxes) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) ''' pass
3
2
38
4
20
14
9
0.72
1
0
0
0
2
1
2
2
79
10
40
9
37
29
40
9
37
16
1
1
17
147,275
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/files.py
platformrest.files.Files
class Files(object): """ Class containing all the actions for the Files Resource """ def __init__(self, client): self.client = client def get(self, **kwargs): """ Returns the files for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, files.*, or files.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: lastUpdated, type, name, creationDate * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} type - Limit by the type (file or directory) of the file * {string} status - Limit the result to only files of this status. Accepted values are: completed, pending * {string} directory - Get files that are inside of this directory * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of files (https://api.losant.com/#/definitions/files) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "page" in kwargs: query_params["page"] = kwargs["page"] if "perPage" in kwargs: query_params["perPage"] = kwargs["perPage"] if "filterField" in kwargs: query_params["filterField"] = kwargs["filterField"] if "filter" in kwargs: query_params["filter"] = kwargs["filter"] if "type" in kwargs: query_params["type"] = kwargs["type"] if "status" in kwargs: query_params["status"] = kwargs["status"] if "directory" in kwargs: query_params["directory"] = kwargs["directory"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/files".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body) def post(self, **kwargs): """ Create a new file for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, files.*, or files.post. Parameters: * {string} applicationId - ID associated with the application * {hash} file - New file information (https://api.losant.com/#/definitions/filePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - Successfully created file and returned a post url to respond with (https://api.losant.com/#/definitions/fileUploadPostResponse) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "applicationId" in kwargs: path_params["applicationId"] = kwargs["applicationId"] if "file" in kwargs: body = kwargs["file"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/applications/{applicationId}/files".format(**path_params) return self.client.request("POST", path, params=query_params, headers=headers, body=body)
class Files(object): ''' Class containing all the actions for the Files Resource ''' def __init__(self, client): pass def get(self, **kwargs): ''' Returns the files for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.cli, all.User.read, files.*, or files.get. Parameters: * {string} applicationId - ID associated with the application * {string} sortField - Field to sort the results by. Accepted values are: lastUpdated, type, name, creationDate * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} type - Limit by the type (file or directory) of the file * {string} status - Limit the result to only files of this status. Accepted values are: completed, pending * {string} directory - Get files that are inside of this directory * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of files (https://api.losant.com/#/definitions/files) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass def post(self, **kwargs): ''' Create a new file for an application Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.cli, all.Organization, all.User, all.User.cli, files.*, or files.post. Parameters: * {string} applicationId - ID associated with the application * {hash} file - New file information (https://api.losant.com/#/definitions/filePost) * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 201 - Successfully created file and returned a post url to respond with (https://api.losant.com/#/definitions/fileUploadPostResponse) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) * 404 - Error if application was not found (https://api.losant.com/#/definitions/error) ''' pass
4
3
40
5
19
16
8
0.86
1
0
0
0
3
1
3
3
125
19
57
15
53
49
57
15
53
15
1
1
23
147,276
Losant/losant-rest-python
Losant_losant-rest-python/platformrest/instances.py
platformrest.instances.Instances
class Instances(object): """ Class containing all the actions for the Instances Resource """ def __init__(self, client): self.client = client def get(self, **kwargs): """ Returns a collection of instances Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.User, all.User.read, instances.*, or instances.get. Parameters: * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of instances (https://api.losant.com/#/definitions/instances) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) """ query_params = {"_actions": "false", "_links": "true", "_embedded": "true"} path_params = {} headers = {} body = None if "sortField" in kwargs: query_params["sortField"] = kwargs["sortField"] if "sortDirection" in kwargs: query_params["sortDirection"] = kwargs["sortDirection"] if "page" in kwargs: query_params["page"] = kwargs["page"] if "perPage" in kwargs: query_params["perPage"] = kwargs["perPage"] if "filterField" in kwargs: query_params["filterField"] = kwargs["filterField"] if "filter" in kwargs: query_params["filter"] = kwargs["filter"] if "losantdomain" in kwargs: headers["losantdomain"] = kwargs["losantdomain"] if "_actions" in kwargs: query_params["_actions"] = kwargs["_actions"] if "_links" in kwargs: query_params["_links"] = kwargs["_links"] if "_embedded" in kwargs: query_params["_embedded"] = kwargs["_embedded"] path = "/instances".format(**path_params) return self.client.request("GET", path, params=query_params, headers=headers, body=body)
class Instances(object): ''' Class containing all the actions for the Instances Resource ''' def __init__(self, client): pass def get(self, **kwargs): ''' Returns a collection of instances Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.User, all.User.read, instances.*, or instances.get. Parameters: * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc * {string} page - Which page of results to return * {string} perPage - How many items to return per page * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. * {string} losantdomain - Domain scope of request (rarely needed) * {boolean} _actions - Return resource actions in response * {boolean} _links - Return resource link in response * {boolean} _embedded - Return embedded resources in response Responses: * 200 - Collection of instances (https://api.losant.com/#/definitions/instances) Errors: * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) ''' pass
3
2
30
4
15
12
6
0.8
1
0
0
0
2
1
2
2
64
10
30
9
27
24
30
9
27
11
1
1
12
147,277
Loudr/asana-hub
Loudr_asana-hub/asana_hub/actions/issue.py
asana_hub.actions.issue.Issue
class Issue(Action): """Creates a new github issue and asana task.""" # name of action name = "issue" @classmethod def add_arguments(cls, parser): """Add arguments to the parser for collection in app.args. Args: parser: `argparse.ArgumentParser`. Parser. Arguments added here are server on self.args. """ parser.add_argument( '-t', '--title', action='store', nargs='?', const='', dest='title', help="[issue] task/issue title.", ) parser.add_argument( '-b', '--body', action='store', nargs='?', const='', dest='body', help="[issue] task/issue body.", ) pass def run(self): app = self.app repo, project = self.get_repo_and_project() # Collect title and body title = app.settings.apply(None, app.args.title, "task/issue title", ) assert title, "title required" body = app.settings.apply(None, app.args.body, "body/message", ) or '' # Post asana task. asana_workspace_id = project['workspace']['id'] task = app.asana.tasks.create_in_workspace( asana_workspace_id, { 'name': title, 'notes': body, # TODO: Correct assignee. 'assignee': 'me', 'projects': [project['id']] }) asana_task_id = task['id'] asana_task_url = app.make_asana_url(project['id'], asana_task_id) body = body + ("\n\n" "**Asana: #%d**\n" "%s" % ( asana_task_id, asana_task_url, )) # Create github issue issue = repo.create_issue( title=title, body=body.strip(), ) # Create asana comment (story) app.announce_issue_to_task(asana_task_id, issue) logging.info("github issue #%d created:\n%s\n", issue.number, issue.html_url) logging.info("asana task #%d created:\n%s\n", asana_task_id, asana_task_url) # Save issue and task to db. app.save_issue_data_task(issue.number, asana_task_id)
class Issue(Action): '''Creates a new github issue and asana task.''' @classmethod def add_arguments(cls, parser): '''Add arguments to the parser for collection in app.args. Args: parser: `argparse.ArgumentParser`. Parser. Arguments added here are server on self.args. ''' pass def run(self): pass
4
2
42
8
28
8
1
0.31
1
0
0
0
1
0
2
7
92
19
58
14
54
18
22
13
19
1
2
0
2
147,278
Loudr/asana-hub
Loudr_asana-hub/asana_hub/actions/pull_request.py
asana_hub.actions.pull_request.PullRequest
class PullRequest(Action): """Creates a new github pull-request for an exist issue and a branch.""" # name of action name = "pr" @classmethod def add_arguments(cls, parser): """Add arguments to the parser for collection in app.args. Args: parser: `argparse.ArgumentParser`. Parser. Arguments added here are server on self.args. """ parser.add_argument( '-i', '--issue', action='store', nargs='?', const='', dest='issue', help="[pr] issue #", ) parser.add_argument( '-br', '--branch', action='store', nargs='?', const='', dest='branch', help="[pr] branch", ) parser.add_argument( '-tbr', '--target-branch', action='store', nargs='?', const='', default='master', dest='target_branch', help="[pr] name of branch to pull changes into\n(defaults to: master)", ) def run(self): app = self.app repo, project = self.get_repo_and_project() project_id = project['id'] # Collect title and body issue = app.settings.apply(None, app.args.issue, "issue # to create PR for", ) assert issue, "issue required" issue = repo.get_issue(int(issue)) assert issue, "issue could not be found" branch = app.settings.apply(None, app.args.branch, "branch to create pull-request from [via api]", ) or '' # Get issue data to create pull request tasks list. issue_data = app.get_saved_issue_data(issue) issue_tasks = issue_data.get('tasks', []) issue_data['tasks'] = issue_tasks # pull_requests is a list of pull request numbers issue_prs = issue_data.get('pull_requests', []) issue_data['pull_requests'] = issue_prs asana_msgs = '' for task in issue_tasks: asana_msgs += '\n * [#%d](%s)' % ( task, app.make_asana_url(project_id, task) ) if asana_msgs: asana_msgs = '## Asana Tasks\n' + asana_msgs # Create pull request. pull_request = repo.create_pull( title=issue.title, head=branch, base="master", body="Fixes #%d - %s\n" "\n## Testing:\n\n" "%s" "" % ( issue.number, issue.title, asana_msgs, ) ) # Post asana task. title = "PR #%d" % pull_request.number body = "%s" % ( pull_request.html_url ) task_ids = [] for task_id in issue_tasks: task = app.asana.tasks.add_subtask( task_id, { 'name': title, 'notes': body, # TODO: Correct assignee. 'assignee': 'me', }) task_ids.append(task['id']) app.save_issue_data_task(issue.number, task['id']) # Add pull request to local data if pull_request.number not in issue_prs: issue_prs.append(pull_request.number) logging.info("github pull_request #%d created:\n%s\n", pull_request.number, pull_request.html_url)
class PullRequest(Action): '''Creates a new github pull-request for an exist issue and a branch.''' @classmethod def add_arguments(cls, parser): '''Add arguments to the parser for collection in app.args. Args: parser: `argparse.ArgumentParser`. Parser. Arguments added here are server on self.args. ''' pass def run(self): pass
4
2
59
10
42
11
3
0.28
1
1
0
0
1
0
2
7
125
22
87
20
83
24
36
19
33
5
2
1
6
147,279
Loudr/asana-hub
Loudr_asana-hub/asana_hub/actions/sync.py
asana_hub.actions.sync.Sync
class Sync(Action): """Syncs completion status of issues and their matched tasks.""" # name of action name = "sync" @classmethod def add_arguments(cls, parser): """Add arguments to the parser for collection in app.args. Args: parser: `argparse.ArgumentParser`. Parser. Arguments added here are server on self.args. """ parser.add_argument( '-c', '--create-missing-tasks', action='store_true', dest='create_missing_tasks', help="[sync] create asana tasks for issues without tasks" ) parser.add_argument( '-l', '--sync-labels', action='store_true', dest='sync_labels', help="[sync] sync labels and milestones for each issue" ) def apply_tasks_to_issue(self, issue, tasks, issue_body=None): """Applies task numbers to an issue.""" issue_body = issue_body or issue.body task_numbers = transport.format_task_numbers_with_links(tasks) if task_numbers: new_body = transport.ASANA_SECTION_RE.sub('', issue_body) new_body = new_body + "\n## Asana Tasks:\n\n%s" % task_numbers transport.issue_edit(issue, body=new_body) return new_body return issue_body def sync_labels(self, repo): """Creates a local map of github labels/milestones to asana tags.""" logging.info("syncing new github.com labels to tags") # create label tag map ltm = self.app.data.get("label-tag-map", {}) # loop over labels, if they don't have tags, make them for label in repo.get_labels(): tag_id = ltm.get(label.name, None) if tag_id is None: tag = self.app.asana.tags.create(name=label.name, workspace=self.asana_ws_id, notes="gh: %s" % label.url ) logging.info("\t%s => tag %d", label.name, tag['id']) ltm[label.name] = tag['id'] # loop over milestones, if they don't have tags, make them for ms in repo.get_milestones(state="all"): tag_id = ltm.get(_ms_label(ms.id), None) if tag_id is None: tag = self.app.asana.tags.create(name=ms.title, workspace=self.asana_ws_id, notes="gh: %s" % ms.url ) logging.info("\t%s => tag %d", ms.title, tag['id']) ltm[_ms_label(ms.id)] = tag['id'] self.app.data['label-tag-map'] = ltm return ltm def run(self): app = self.app repo, project = self.get_repo_and_project() self.asana_ws_id = asana_workspace_id = project['workspace']['id'] project_id = project['id'] # Sync project labels <-> asana tags if app.args.sync_labels: label_tag_map = self.sync_labels(repo) else: label_tag_map = {} # Iterate over the issues in the opposite state as the namespace # we are in. We simply want to toggle these guys. logging.info("collecting github.com issues") # Get the first issue, to limit syncing. first_issue = app.data.get('first-issue') for issue in repo.get_issues(state="all"): # bypass issues < `first-issue` setting. if (first_issue is not None and issue.number < first_issue): logging.debug("stopping at first-issue: %d", first_issue) break issue_number = str(issue.number) issue_body = issue.body asana_match = ASANA_ID_RE.search(issue_body) multi_match_sections = len(transport.ASANA_SECTION_RE.findall(issue_body)) > 1 status = "cached" # Collect closed and opened tasks known for this issue. closed_tasks = \ app.get_saved_issue_data(issue, 'closed').get('tasks', []) open_tasks = \ app.get_saved_issue_data(issue, 'open').get('tasks', []) recorded_tasks = set(open_tasks + closed_tasks) # Collect tasks named on github issue issue_named_tasks = set() for m_grp in ASANA_ID_RE.finditer(issue_body): issue_named_tasks.add(int(m_grp.group(1))) # Get tasks that are named but missing from cache. tasks_to_save_to_this_issue = issue_named_tasks - recorded_tasks for task_id in tasks_to_save_to_this_issue: status = "collected tasks" transport.put_setting("save_issue_data_task", issue=issue_number, task_id=task_id, namespace=issue.state) my_tasks = recorded_tasks.union(tasks_to_save_to_this_issue) my_tasks = transport.mem.list(my_tasks) # Determine if there are multiple groups of ASANA TASKS # named. if multi_match_sections: issue_body = transport.ASANA_SECTION_RE.sub('', issue_body) asana_match = None issue_body = self.apply_tasks_to_issue(issue, my_tasks, issue_body=issue_body) status = "minified issue body" # Sync tags and labels labels = set() if app.args.sync_labels: for label in issue.get_labels(): labels.add(label.name) if issue.milestone: labels.add(_ms_label(issue.milestone.id)) # If we have tasks already, this issue is cached. if recorded_tasks: # If the body is missing asana tasks, add all those we know # about. if not asana_match: # Add tasks if we have any. if recorded_tasks: issue_body = self.apply_tasks_to_issue(issue, my_tasks, issue_body=issue_body) status = "updated with asana #s" # If the section isn't formatted... let's reformat it. elif not transport.ASANA_SECTION_RE.search(issue_body): issue_body = self.apply_tasks_to_issue(issue, my_tasks, issue_body=issue_body) status = "reformatted asana tasks" # Sync tags/labels transport.put("sync_tags", tasks=my_tasks, labels=labels, label_tag_map=label_tag_map) for task in my_tasks: transport.put('update_task', task_id=task, params={'completed': bool(issue.closed_at)}) # tasks named on issue need to be synced elif asana_match and issue_named_tasks: status = "connecting tasks" self.apply_tasks_to_issue(issue, my_tasks, issue_body=issue_body) # Sync tags/labels transport.put("sync_tags", tasks=my_tasks, labels=labels, label_tag_map=label_tag_map) # Create story transport.put("create_story", task_id=task_id, text="Git Issue #%d: \n" "%s" % ( issue.number, issue.html_url, ) ) for task in my_tasks: transport.put('update_task', task_id=task, params={'completed': bool(issue.closed_at)}) elif self.args.create_missing_tasks and not issue.pull_request: # missing task # Create tasks for non-prs transport.put("create_missing_task", issue_number=issue.number, issue_state=issue.state, issue_html_url=issue.html_url, issue_body=issue.body, asana_workspace_id=asana_workspace_id, name=issue.title, # TODO: Correct assignee. assignee='me', projects=[project_id], completed=bool(issue.closed_at), tasks=my_tasks, label_tag_map=label_tag_map, labels=labels, ) status = "new task" else: status = "no task" logging.info("\t%d) %s - %s", issue.number, issue.title, status) # Flush work. app.flush()
class Sync(Action): '''Syncs completion status of issues and their matched tasks.''' @classmethod def add_arguments(cls, parser): '''Add arguments to the parser for collection in app.args. Args: parser: `argparse.ArgumentParser`. Parser. Arguments added here are server on self.args. ''' pass def apply_tasks_to_issue(self, issue, tasks, issue_body=None): '''Applies task numbers to an issue.''' pass def sync_labels(self, repo): '''Creates a local map of github labels/milestones to asana tags.''' pass def run(self): pass
6
4
58
11
39
10
7
0.26
1
4
0
0
3
1
4
9
243
47
158
38
152
41
94
35
89
18
2
4
26
147,280
Loudr/asana-hub
Loudr_asana-hub/asana_hub/json_data.py
asana_hub.json_data.JSONData
class JSONData(object): def __init__(self, filename, args, version): """ Args: filename: Filename for database. args: Program arguments. version: Version of file. """ self.args = args self.version = version self.filename = filename try: with open(self.filename, 'rb') as file: self.data = json.load(file) except IOError: self.data = {} def assert_version(self): """Asserts that the version and data file exists.""" if not self.has_key('version'): raise Exception("`asana-hub connect` must be run first.") self.data['version'] = self.version def save(self): """Save data.""" with open(self.filename, 'wb') as file: self.prune() self.data['version'] = self.version json.dump(self.data, file, sort_keys=True, indent=2) def __setitem__(self, key, value): """Set a value by key.""" self.data[key] = value def __getitem__(self, key): """Get a value by key.""" return self.data[key] def prune(self, data=None): if data is None: data = self.data empty_keys = [k for k, v in data.iteritems() if not v] for k in empty_keys: del data[k] for v in data.values(): if isinstance(v, dict): self.prune(data=v) def apply(self, key, value, prompt=None, on_load=lambda a: a, on_save=lambda a: a): """Applies a setting value to a key, if the value is not `None`. Returns without prompting if either of the following: * `value` is not `None` * already present in the dictionary Args: prompt: May either be a string to prompt via `raw_input` or a method (callable) that returns the value. on_load: lambda. Value is passed through here after loaded. on_save: lambda. Value is saved as this value. """ # Reset value if flag exists without value if value == '': value = None if key and self.data.has_key(key): del self.data[key] # If value is explicitly set from args. if value is not None: value = on_load(value) if key: self.data[key] = on_save(value) return value elif not key or not self.has_key(key): if callable(prompt): value = prompt() elif prompt is not None: value = raw_input(prompt + ": ") if value is None: if self.data.has_key(key): del self.data[key] return None self.data[key] = on_save(value) return value return on_load(self.data[key]) def assert_key(self, key): assert self.data.get(key), "%s missing from data" % key def has_key(self, *args, **kwargs): return self.data.has_key(*args, **kwargs) def get(self, key, default_value=None): try: return self.data[key] except KeyError: if default_value is not None: self.data[key] = default_value return default_value
class JSONData(object): def __init__(self, filename, args, version): ''' Args: filename: Filename for database. args: Program arguments. version: Version of file. ''' pass def assert_version(self): '''Asserts that the version and data file exists.''' pass def save(self): '''Save data.''' pass def __setitem__(self, key, value): '''Set a value by key.''' pass def __getitem__(self, key): '''Get a value by key.''' pass def prune(self, data=None): pass def apply(self, key, value, prompt=None, on_load=lambda a: a, on_save=lambda a: a): '''Applies a setting value to a key, if the value is not `None`. Returns without prompting if either of the following: * `value` is not `None` * already present in the dictionary Args: prompt: May either be a string to prompt via `raw_input` or a method (callable) that returns the value. on_load: lambda. Value is passed through here after loaded. on_save: lambda. Value is saved as this value. ''' pass def assert_key(self, key): pass def has_key(self, *args, **kwargs): pass def get(self, key, default_value=None): pass
11
6
11
2
6
3
3
0.43
1
3
0
0
10
4
10
10
121
28
65
19
53
28
63
16
52
10
1
3
27
147,281
Loudr/asana-hub
Loudr_asana-hub/asana_hub/actions/connect.py
asana_hub.actions.connect.Connect
class Connect(Action): """Connects and authenticates OAuth accounts.""" # name of action name = "connect" @classmethod def add_arguments(cls, parser): """Add arguments to the parser for collection in app.args. Args: parser: `argparse.ArgumentParser`. Parser. Arguments added here are server on self.args. """ parser.add_argument( '--project', action='store', nargs='?', const='', dest='asana_project', help="asana project id.", ) parser.add_argument( '--repo', action='store', nargs='?', const='', dest='github_repo', help="github repository id.", ) pass def run(self): app = self.app logging.info("connected ok.")
class Connect(Action): '''Connects and authenticates OAuth accounts.''' @classmethod def add_arguments(cls, parser): '''Add arguments to the parser for collection in app.args. Args: parser: `argparse.ArgumentParser`. Parser. Arguments added here are server on self.args. ''' pass def run(self): pass
4
2
16
2
11
4
1
0.38
1
0
0
0
1
0
2
7
40
7
24
6
20
9
9
5
6
1
2
0
2
147,282
Loudr/pale
Loudr_pale/pale/response.py
pale.response.PaleBaseResponse
class PaleBaseResponse(object): def __init__(self, *args): super(PaleBaseResponse, self).__init__(*args) if args: self.message = args[0] else: self.message = "i am a teapot" @property def response(self): http_status = getattr(self, 'http_status_code', 418) response_body = getattr(self, 'response_body', "i am a teapot") headers = getattr(self, 'headers', None) return (response_body, http_status, headers)
class PaleBaseResponse(object): def __init__(self, *args): pass @property def response(self): pass
4
0
6
0
6
0
2
0
1
1
0
2
2
1
2
2
14
1
13
8
9
0
11
7
8
2
1
1
3
147,283
Loudr/pale
Loudr_pale/pale/resource.py
pale.resource.ResourceList
class ResourceList(Resource): """A wrapper around a Resource object to specify that the API will return a homogeneous list of multiple Resources. This response type is used by `index`-style endpoints, where multiple items of the same type should be returned as an array. """ _description = "A generic list of Resources" def __init__(self, doc_string, item_type, **kwargs): kwargs['doc_string'] = doc_string super(ResourceList, self).__init__(**kwargs) if isinstance(item_type, Resource): self._item_resource = item_type if isinstance(item_type, types.ObjectType): self._item_resource = item_type() else: raise ValueError("""Failed to initialize ResourceList, since it was passed an `item_type` other than an Instance of a Resource or a Resource class.""") self._description = "A list of %s Resources" % self._item_resource.name def _render_serializable(self, list_of_objs, context): """Iterates through the passed in `list_of_objs` and calls the `_render_serializable` method of each object's Resource type. This will probably support heterogeneous types at some point (hence the `item_types` initialization, as opposed to just item_type), but that might be better suited to something else like a ResourceDict. This method returns a JSON-serializable list of JSON-serializable dicts. """ output = [] for obj in list_of_objs: if obj is not None: item = self._item_resource._render_serializable(obj, context) output.append(item) return output
class ResourceList(Resource): '''A wrapper around a Resource object to specify that the API will return a homogeneous list of multiple Resources. This response type is used by `index`-style endpoints, where multiple items of the same type should be returned as an array. ''' def __init__(self, doc_string, item_type, **kwargs): pass def _render_serializable(self, list_of_objs, context): '''Iterates through the passed in `list_of_objs` and calls the `_render_serializable` method of each object's Resource type. This will probably support heterogeneous types at some point (hence the `item_types` initialization, as opposed to just item_type), but that might be better suited to something else like a ResourceDict. This method returns a JSON-serializable list of JSON-serializable dicts. ''' pass
3
2
15
2
10
4
3
0.62
1
2
0
0
2
1
2
6
40
6
21
8
18
13
18
8
15
3
2
2
6
147,284
Loudr/pale
Loudr_pale/pale/resource.py
pale.resource.Resource
class Resource(object): __metaclass__ = MetaHasFields _value_type = "Base Resource" _default_fields = None @classmethod def _all_fields(cls): return tuple(cls._fields.keys()) @classmethod def _fix_up_fields(cls): """Add names to all of the Resource fields. This method will get called on class declaration because of Resource's metaclass. The functionality is based on Google's NDB implementation. `Endpoint` does something similar for `arguments`. """ cls._fields = {} if cls.__module__ == __name__ and cls.__name__ != 'DebugResource': return for name in set(dir(cls)): attr = getattr(cls, name, None) if isinstance(attr, BaseField): if name.startswith('_'): raise TypeError("Resource field %s cannot begin with an " "underscore. Underscore attributes are reserved " "for instance variables that aren't intended to " "propagate out to the HTTP caller." % name) attr._fix_up(cls, name) cls._fields[attr.name] = attr if cls._default_fields is None: cls._default_fields = tuple(cls._fields.keys()) def __init__(self, doc_string=None, fields=None): """Initialize the resource with the provided doc string and fields. In general, the doc string should never be none for individual resources, but may be none when the resource class is included as a part of a ResourceList or ResourceDict. """ self._description = doc_string if fields is not None: self._fields_to_render = fields else: self._fields_to_render = self._default_fields def _render_serializable(self, obj, context): """Renders a JSON-serializable version of the object passed in. Usually this means turning a Python object into a dict, but sometimes it might make sense to render a list, or a string, or a tuple. In this base class, we provide a default implementation that assumes some things about your application architecture, namely, that your models specified in `underlying_model` have properties with the same name as all of the `_fields` that you've specified on a resource, and that all of those fields are public. Obviously this may not be appropriate for your app, so your subclass(es) of Resource should implement this method to serialize your things in the way that works for you. Do what you need to do. The world is your oyster. """ logging.info("""Careful, you're calling ._render_serializable on the base resource, which is probably not what you actually want to be doing!""") if obj is None: logging.debug( "_render_serializable passed a None obj, returning None") return None output = {} if self._fields_to_render is None: return output for field in self._fields_to_render: renderer = self._fields[field].render output[field] = renderer(obj, field, context) return output
class Resource(object): @classmethod def _all_fields(cls): pass @classmethod def _fix_up_fields(cls): '''Add names to all of the Resource fields. This method will get called on class declaration because of Resource's metaclass. The functionality is based on Google's NDB implementation. `Endpoint` does something similar for `arguments`. ''' pass def __init__(self, doc_string=None, fields=None): '''Initialize the resource with the provided doc string and fields. In general, the doc string should never be none for individual resources, but may be none when the resource class is included as a part of a ResourceList or ResourceDict. ''' pass def _render_serializable(self, obj, context): '''Renders a JSON-serializable version of the object passed in. Usually this means turning a Python object into a dict, but sometimes it might make sense to render a list, or a string, or a tuple. In this base class, we provide a default implementation that assumes some things about your application architecture, namely, that your models specified in `underlying_model` have properties with the same name as all of the `_fields` that you've specified on a resource, and that all of those fields are public. Obviously this may not be appropriate for your app, so your subclass(es) of Resource should implement this method to serialize your things in the way that works for you. Do what you need to do. The world is your oyster. ''' pass
7
3
17
2
10
6
3
0.53
1
4
1
3
2
2
4
4
83
14
45
17
38
24
36
15
31
6
1
3
13
147,285
Loudr/pale
Loudr_pale/pale/fields/boolean.py
pale.fields.boolean.BooleanField
class BooleanField(BaseField): """A BaseField whose type is `boolean`.""" value_type = 'boolean' def __init__(self, description, **kwargs): super(BooleanField, self).__init__( self.value_type, description, **kwargs)
class BooleanField(BaseField): '''A BaseField whose type is `boolean`.''' def __init__(self, description, **kwargs): pass
2
1
5
0
5
0
1
0.14
1
1
0
0
1
0
1
5
9
1
7
3
5
1
4
3
2
1
2
0
1
147,286
Loudr/pale
Loudr_pale/tests/example_app/api/endpoints.py
tests.example_app.api.endpoints.ResourcePatchEndpoint
class ResourcePatchEndpoint(PatchEndpoint): """Patches a resource which is local to each instance of the app. """ _uri = "/resource" _route_name = "resource_patch" _resource = DebugResource("resource patch.") _returns = DebugResource("app resource.") def _handle_patch(self, context, patch): data = dict(RESOURCE) patch.apply_to_dict(data) RESOURCE.update(data) return dict(RESOURCE)
class ResourcePatchEndpoint(PatchEndpoint): '''Patches a resource which is local to each instance of the app. ''' def _handle_patch(self, context, patch): pass
2
1
5
0
5
0
1
0.2
1
1
0
0
1
0
1
16
15
3
10
7
8
2
10
7
8
1
3
0
1
147,287
Loudr/pale
Loudr_pale/pale/adapters/flask.py
pale.adapters.flask.DefaultFlaskContext
class DefaultFlaskContext(pale.context.DefaultContext): def build_args_from_request(self, request): # in flask, `request.values` is querystring args, and form args req_args = request.values.to_dict(flat=False) if request.content_type == 'application/json': json_args = request.get_json() for k,v in json_args.iteritems(): if k in req_args: logging.warning("Found duplicate argument %s. " "Preferring json argument to querystring arg.", k) req_args[k] = v return req_args def __init__(self, endpoint, request): super(DefaultFlaskContext, self).__init__() self.headers = request.headers self.cookies = request.cookies self.request = request self.body = request.data self._raw_args = self.build_args_from_request(request) self.route_kwargs = request.view_args self.current_user = None self.endpoint = endpoint
class DefaultFlaskContext(pale.context.DefaultContext): def build_args_from_request(self, request): pass def __init__(self, endpoint, request): pass
3
0
11
0
10
1
3
0.05
1
1
0
0
2
8
2
3
24
2
21
14
18
1
20
14
17
4
2
3
5
147,288
Loudr/pale
Loudr_pale/pale/fields/base.py
pale.fields.base.StaticItem
class StaticItem(object): def __init__(self, obj): self.obj = obj
class StaticItem(object): def __init__(self, obj): pass
2
0
2
0
2
0
1
0
1
0
0
0
1
1
1
1
4
1
3
3
1
0
3
3
1
1
1
0
1
147,289
Loudr/pale
Loudr_pale/pale/resource.py
pale.resource.NoContentResource
class NoContentResource(Resource): """An empty resource to represent endpoints that return No-Content.""" _description = "The shell of a Resource where content used to be" def _render_serializable(self, obj, context): return None
class NoContentResource(Resource): '''An empty resource to represent endpoints that return No-Content.''' def _render_serializable(self, obj, context): pass
2
1
2
0
2
0
1
0.25
1
0
0
0
1
0
1
5
6
1
4
3
2
1
4
3
2
1
2
0
1
147,290
Loudr/pale
Loudr_pale/tests/test_webapp2_adapter.py
tests.test_webapp2_adapter.Webapp2AdapterTests
class Webapp2AdapterTests(FlaskAdapterTests): """Run webapp2 adapter tests. These tests should be the same tests as run against the Flask adapter, so we inherit from that class and change around what app the tests run against. Any new tests that should be run against all adapters should be added directly to the Flask tests. """ def setUp(self): from tests.example_app.webapp2_app import create_pale_webapp2_app self.wsgi_app = create_pale_webapp2_app() self.app = TestApp(self.wsgi_app)
class Webapp2AdapterTests(FlaskAdapterTests): '''Run webapp2 adapter tests. These tests should be the same tests as run against the Flask adapter, so we inherit from that class and change around what app the tests run against. Any new tests that should be run against all adapters should be added directly to the Flask tests. ''' def setUp(self): pass
2
1
4
0
4
0
1
1.4
1
0
0
0
1
2
1
82
15
3
5
5
2
7
5
5
2
1
3
0
1
147,291
Loudr/pale
Loudr_pale/tests/test_resource_patch.py
tests.test_resource_patch.UserResource
class UserResource(Resource): _value_type = 'Test "user" resource for patches' _underlying_model = User username = StringField("Username") id = StringField("User ID") stats = ResourceField("Test of a nested resource", resource_type=StatsResource) counters = ResourceListField("List of misc. counters", resource_type=CounterResource) tokens = ListField("List of string tokens", item_type=StringField)
class UserResource(Resource): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
14
3
11
7
10
0
8
7
7
0
1
0
0
147,292
Loudr/pale
Loudr_pale/tests/example_app/api/endpoints.py
tests.example_app.api.endpoints.TimeRangeEndpoint
class TimeRangeEndpoint(Endpoint): """Returns start and end times based on the passed in duration. The start time is implied to be "now", and the end time is calculated by adding the duration to that start time. This is obviously fairly contrived, but this endpoint is here to illustrate and test nested resources. """ _http_method = "GET" _uri = "/time/range" _route_name = "time_range_now_plus_duration" _returns = DateTimeRangeResource( "Information about the range specified, as well as the " "range's start and end datetimes.") duration = IntegerArgument( "The duration in milliseconds to be used.", required=True) def _handle(self, context): millis = context.args['duration'] time_range = DateTimeRangeModel(millis*1000) # microseconds return {'range': time_range}
class TimeRangeEndpoint(Endpoint): '''Returns start and end times based on the passed in duration. The start time is implied to be "now", and the end time is calculated by adding the duration to that start time. This is obviously fairly contrived, but this endpoint is here to illustrate and test nested resources. ''' def _handle(self, context): pass
2
1
4
0
4
1
1
0.5
1
1
1
0
1
0
1
1
29
9
14
9
12
7
10
9
8
1
1
0
1
147,293
Loudr/pale
Loudr_pale/tests/test_resource_patch.py
tests.test_resource_patch.User
class User(object): """Has: tokens - list of strings counters - list of Counter id - string id username - string username """ def __init__(self, id, username): assert isinstance(username, basestring) self.username = username assert isinstance(id, basestring) self.id = id self.stats = Stats() self.counters = [] self.tokens = []
class User(object): '''Has: tokens - list of strings counters - list of Counter id - string id username - string username ''' def __init__(self, id, username): pass
2
1
8
0
8
0
1
0.67
1
1
1
0
1
5
1
1
15
0
9
7
7
6
9
7
7
1
1
0
1
147,294
Loudr/pale
Loudr_pale/pale/adapters/flask.py
pale.adapters.flask.ContextualizedHandler
class ContextualizedHandler(object): """Flask route functions get called with no arguments unless there are arguments specified in the route path. This contextualizer object wraps the desired pale executor by grabbing the flask request and populating the appropriate kwargs before passing them onto the execute function. """ def __init__(self, func): self.handler = func def __call__(self, *args, **kwargs): """Call the handler with the flask request. We ignore the kwargs here, since they're also present on the request object as `request.view_args`. """ request = flask.request return self.handler(request)
class ContextualizedHandler(object): '''Flask route functions get called with no arguments unless there are arguments specified in the route path. This contextualizer object wraps the desired pale executor by grabbing the flask request and populating the appropriate kwargs before passing them onto the execute function. ''' def __init__(self, func): pass def __call__(self, *args, **kwargs): '''Call the handler with the flask request. We ignore the kwargs here, since they're also present on the request object as `request.view_args`. ''' pass
3
2
5
1
3
2
1
1.5
1
0
0
0
2
1
2
2
17
2
6
5
3
9
6
5
3
1
1
0
2
147,295
Loudr/pale
Loudr_pale/pale/response.py
pale.response.PaleRaisedResponse
class PaleRaisedResponse(PaleBaseResponse, Exception): pass
class PaleRaisedResponse(PaleBaseResponse, Exception): pass
1
0
0
0
0
0
0
0
2
0
0
1
0
0
0
12
2
0
2
1
1
0
2
1
1
0
3
0
0
147,296
Loudr/pale
Loudr_pale/pale/context.py
pale.context.DefaultContext
class DefaultContext(object): """A default Context object for pale request data""" def __init__(self): self.request = None self.headers = None self.cookies = None self.api_version = None self._raw_args = None self.args = None self.route_args = None self.current_user = None self.handler_result = None self.response = None
class DefaultContext(object): '''A default Context object for pale request data''' def __init__(self): pass
2
1
15
4
11
0
1
0.08
1
0
0
2
1
10
1
1
17
4
12
12
10
1
12
12
10
1
1
0
1
147,297
Loudr/pale
Loudr_pale/tests/example_app/api/endpoints.py
tests.example_app.api.endpoints.ResourceCreateEndpoint
class ResourceCreateEndpoint(PutResourceEndpoint): """Patches a resource which is local to each instance of the app. """ _uri = "/resource" _route_name = "resource_put" _resource = DebugResource("resource patch.") _returns = DebugResource("app resource.") def _handle_put(self, context, patch): data = {} patch.apply_to_dict(data) RESOURCE.clear() RESOURCE.update(data) return dict(RESOURCE)
class ResourceCreateEndpoint(PutResourceEndpoint): '''Patches a resource which is local to each instance of the app. ''' def _handle_put(self, context, patch): pass
2
1
6
0
6
0
1
0.18
1
1
0
0
1
0
1
16
16
3
11
7
9
2
11
7
9
1
3
0
1
147,298
Loudr/pale
Loudr_pale/pale/fields/links.py
pale.fields.links.RelativeLinksField
class RelativeLinksField(BaseField): """A field that contains relative links to a Resource. This field is inherently a list of relative links, but it's special in that it accepts a list of methods that get called to generate the links. Each of these link generation methods should return a tuple with the name of the relative link, as well as the url, i.e. ('canonical', 'https://github.com/Loudr/pale') The resulting field will render as an object of named URLs, like this: 'rel': { 'canonical': 'https://github.com/Loudr/pale' } """ value_type = "relative links" def __init__(self, description, link_generators=[], **kwargs): super(RelativeLinksField, self).__init__( self.value_type, description, **kwargs) self.link_generators = link_generators def render(self, obj, name, context): links = {} for renderer in self.link_generators: _tup = renderer(obj) if _tup is None: continue name, val = _tup links[name] = val if len(links) == 0: return None return links
class RelativeLinksField(BaseField): '''A field that contains relative links to a Resource. This field is inherently a list of relative links, but it's special in that it accepts a list of methods that get called to generate the links. Each of these link generation methods should return a tuple with the name of the relative link, as well as the url, i.e. ('canonical', 'https://github.com/Loudr/pale') The resulting field will render as an object of named URLs, like this: 'rel': { 'canonical': 'https://github.com/Loudr/pale' } ''' def __init__(self, description, link_generators=[], **kwargs): pass def render(self, obj, name, context): pass
3
1
9
0
9
0
3
0.58
1
1
0
0
2
1
2
6
38
8
19
9
16
11
16
9
13
4
2
2
5
147,299
Loudr/pale
Loudr_pale/tests/example_app/api/endpoints.py
tests.example_app.api.endpoints.RouteArgEndpoint
class RouteArgEndpoint(Endpoint): """Returns the arguments as provided from URI. """ _uri = "/arg_test/<arg_a>/<arg_b>" _http_method = 'GET' _route_name = "arg_test" _returns = DebugResource("app resource.") def _handle(self, context): arg_a = context.route_kwargs.get('arg_a', 'no') arg_b = context.route_kwargs.get('arg_b', 'no') return {"arg_a": arg_a, "arg_b": arg_b}
class RouteArgEndpoint(Endpoint): '''Returns the arguments as provided from URI. ''' def _handle(self, context): pass
2
1
4
0
4
0
1
0.22
1
0
0
0
1
0
1
1
14
3
9
8
7
2
9
8
7
1
1
0
1
147,300
Loudr/pale
Loudr_pale/pale/response.py
pale.response.RedirectFound
class RedirectFound(PaleRaisedResponse): http_status_code = 302 response_body = "" def __init__(self, redirect_url): self.redirect_url = redirect_url super(RedirectFound, self).__init__("Redirect to `%s`" % redirect_url) @property def headers(self): return [('Location', self.redirect_url)]
class RedirectFound(PaleRaisedResponse): def __init__(self, redirect_url): pass @property def headers(self): pass
4
0
3
0
3
0
1
0
1
1
0
0
2
1
2
14
11
2
9
7
5
0
8
6
5
1
4
0
2
147,301
Loudr/pale
Loudr_pale/tests/example_app/api/endpoints.py
tests.example_app.api.endpoints.BlankEndpoint
class BlankEndpoint(Endpoint): """ This carries out some action, then returns nothing on success. """ _http_method = "POST" _uri = "/blank" _route_name = "resource_blank" _allow_cors = True _returns = NoContentResource() def _handle(self, context): return None
class BlankEndpoint(Endpoint): ''' This carries out some action, then returns nothing on success. ''' def _handle(self, context): pass
2
1
2
0
2
0
1
0.25
1
0
0
0
1
0
1
1
12
2
8
7
6
2
8
7
6
1
1
0
1
147,302
Loudr/pale
Loudr_pale/pale/fields/base.py
pale.fields.base.ListField
class ListField(BaseField): """A Field that contains a list of Fields.""" value_type = 'list' def __init__(self, description, item_type=BaseField, **kwargs): super(ListField, self).__init__( self.value_type, description, **kwargs) # Item type initialization self.item_type = item_type kd = {'description':'nested_list'} if item_type is BaseField: kd['value_type'] = 'base_field' self.item_type_instance = self.item_type( **kd ) def doc_dict(self): doc = super(ListField, self).doc_dict() doc['item_type'] = self.item_type.value_type return doc def render(self, obj, name, context): if obj is None: return [] output = [] # again, the base renderer basically just calls getattr. # We're expecting the attr to be a list, though. lst = super(ListField, self).render(obj, name, context) if lst is None: return [] # attempt to wrap any non-iterable in to a list of iterables. if not isinstance(lst, Iterable): lst = [lst] renderer = self.item_type_instance.render for res in lst: item = renderer(StaticItem(res), 'obj', context) output.append(item) return output
class ListField(BaseField): '''A Field that contains a list of Fields.''' def __init__(self, description, item_type=BaseField, **kwargs): pass def doc_dict(self): pass def render(self, obj, name, context): pass
4
1
13
2
10
1
3
0.16
1
2
1
0
3
2
3
7
47
10
32
14
28
5
27
14
23
5
2
1
8
147,303
Loudr/pale
Loudr_pale/pale/fields/timestamp.py
pale.fields.timestamp.TimestampField
class TimestampField(StringField): """A field for timestamp strings.""" value_type = 'timestamp'
class TimestampField(StringField): '''A field for timestamp strings.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
5
3
0
2
2
1
1
2
2
1
0
3
0
0
147,304
Loudr/pale
Loudr_pale/tests/example_app/api/endpoints.py
tests.example_app.api.endpoints.CurrentTimeEndpoint
class CurrentTimeEndpoint(Endpoint): """An API endpoint to get the current time.""" _http_method = "GET" _uri = "/time/current" _route_name = "current_time" _allow_cors = True _returns = DateTimeResource( "The DateTimeResource representation of the current time on the " "server.", fields=DateTimeResource._all_fields()) _after_response_handlers = (add_after_response_test, ) def _handle(self, context): now = DateTimeModel(datetime.datetime.utcnow()) return {'time': now}
class CurrentTimeEndpoint(Endpoint): '''An API endpoint to get the current time.''' def _handle(self, context): pass
2
1
3
0
3
0
1
0.08
1
2
1
0
1
0
1
1
17
3
13
9
11
1
10
9
8
1
1
0
1
147,305
Loudr/pale
Loudr_pale/tests/example_app/api/endpoints.py
tests.example_app.api.endpoints.GetResourceEndpoint
class GetResourceEndpoint(Endpoint): """Returns the 'resource' as it exists in memory. """ _uri = "/resource" _http_method = 'GET' _route_name = "resource_get" _returns = DebugResource("app resource.") def _handle(self, context): return dict(RESOURCE)
class GetResourceEndpoint(Endpoint): '''Returns the 'resource' as it exists in memory. ''' def _handle(self, context): pass
2
1
2
0
2
0
1
0.29
1
1
0
0
1
0
1
1
12
3
7
6
5
2
7
6
5
1
1
0
1
147,306
Loudr/pale
Loudr_pale/pale/fields/base.py
pale.fields.base.BaseField
class BaseField(object): """The base class for all Fields and Arguments. Field objects are used by Resources to define the data they return. They include a name, a type, a short description, and a long description. Of these instance variables, only `name` is functionally significant, as it's used as the key for the field's value in the outgoing JSON. The rest of the instance variables are used to generate documentation. Argument objects inherit from Field, in that they share the same base set of instance variables, but are used on the input side of the API, and include validation functionality. """ value_type = 'base' def __init__(self, value_type, description, details=None, property_name=None, value=None): self.value_type = value_type self.description = description self.details = details self.property_name = property_name self.value_lambda = value if self.value_lambda is not None: assert isinstance(value, types.LambdaType), \ "A Field's `value` parameter must be a lambda" assert self.property_name is None, \ ("Field does not support setting both `property_name` " "*AND* `value`. Please pick one or the other") def _fix_up(self, cls, code_name): """Internal helper to name the field after its variable. This is called by _fix_up_fields, which is called by the MetaHasFields metaclass when finishing the construction of a Resource subclass. The `code_name` passed in is the name of the python attribute that the Field has been assigned to in the resource. Note that each BaseField instance must only be assigned to at most one Resource class attribute. """ self.name = code_name def render(self, obj, name, context): """The default field renderer. This basic renderer assumes that the object has an attribute with the same name as the field, unless a different field is specified as a `property_name`. The renderer is also passed the context so that it can be propagated to the `_render_serializable` method of nested resources (or, for example, if you decide to implement attribute hiding at the field level instead of at the object level). Callable attributes of `obj` will be called to fetch value. This is useful for fields computed from lambda functions or instance methods. """ if self.value_lambda is not None: val = self.value_lambda(obj) else: attr_name = name if self.property_name is not None: attr_name = self.property_name if isinstance(obj, dict): val = obj.get(attr_name, None) else: val = getattr(obj, attr_name, None) if callable(val): try: val = val() except: logging.exception("Attempted to call `%s` on obj of type %s.", attr_name, type(obj)) raise return val def doc_dict(self): """Generate the documentation for this field.""" doc = { 'type': self.value_type, 'description': self.description, 'extended_description': self.details } return doc
class BaseField(object): '''The base class for all Fields and Arguments. Field objects are used by Resources to define the data they return. They include a name, a type, a short description, and a long description. Of these instance variables, only `name` is functionally significant, as it's used as the key for the field's value in the outgoing JSON. The rest of the instance variables are used to generate documentation. Argument objects inherit from Field, in that they share the same base set of instance variables, but are used on the input side of the API, and include validation functionality. ''' def __init__(self, value_type, description, details=None, property_name=None, value=None): pass def _fix_up(self, cls, code_name): '''Internal helper to name the field after its variable. This is called by _fix_up_fields, which is called by the MetaHasFields metaclass when finishing the construction of a Resource subclass. The `code_name` passed in is the name of the python attribute that the Field has been assigned to in the resource. Note that each BaseField instance must only be assigned to at most one Resource class attribute. ''' pass def render(self, obj, name, context): '''The default field renderer. This basic renderer assumes that the object has an attribute with the same name as the field, unless a different field is specified as a `property_name`. The renderer is also passed the context so that it can be propagated to the `_render_serializable` method of nested resources (or, for example, if you decide to implement attribute hiding at the field level instead of at the object level). Callable attributes of `obj` will be called to fetch value. This is useful for fields computed from lambda functions or instance methods. ''' pass def doc_dict(self): '''Generate the documentation for this field.''' pass
5
4
19
2
11
5
3
0.68
1
2
0
9
4
5
4
4
98
19
47
19
37
32
32
14
27
6
1
2
10
147,307
Loudr/pale
Loudr_pale/pale/errors/validation.py
pale.errors.validation.AuthenticationError
class AuthenticationError(BasePaleError): pass
class AuthenticationError(BasePaleError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
13
2
0
2
1
1
0
2
1
1
0
4
0
0
147,308
Loudr/pale
Loudr_pale/pale/errors/validation.py
pale.errors.validation.ArgumentError
class ArgumentError(BasePaleError): def __init__(self, arg_name, message): error_msg = ("Invalid argument: `%s`. %s" % (arg_name, message)) self.arg_name = arg_name super(ArgumentError, self).__init__(error_msg)
class ArgumentError(BasePaleError): def __init__(self, arg_name, message): pass
2
0
5
0
5
0
1
0
1
1
0
0
1
1
1
14
6
0
6
4
4
0
5
4
3
1
4
0
1
147,309
Loudr/pale
Loudr_pale/pale/errors/base.py
pale.errors.base.BasePaleError
class BasePaleError(PaleBaseResponse, Exception): http_status_code = 500 @property def response_body(self): return '{"error": "%s"}' % (self.message, )
class BasePaleError(PaleBaseResponse, Exception): @property def response_body(self): pass
3
0
2
0
2
0
1
0
2
0
0
3
1
0
1
13
6
1
5
4
2
0
4
3
2
1
3
0
1
147,310
Loudr/pale
Loudr_pale/tests/example_app/api/endpoints.py
tests.example_app.api.endpoints.ResetResourceEndpoint
class ResetResourceEndpoint(Endpoint): """Returns the 'resource' as it exists in memory. """ _uri = "/resource/reset" _http_method = 'POST' _route_name = "resource_reset" _returns = DebugResource("app resource.") def _handle(self, context): RESOURCE.clear() RESOURCE.update(BASE_RESOURCE) return dict(RESOURCE)
class ResetResourceEndpoint(Endpoint): '''Returns the 'resource' as it exists in memory. ''' def _handle(self, context): pass
2
1
4
0
4
0
1
0.22
1
1
0
0
1
0
1
1
14
3
9
6
7
2
9
6
7
1
1
0
1
147,311
Loudr/pale
Loudr_pale/pale/fields/resource.py
pale.fields.resource.ResourceField
class ResourceField(BaseField): """A field that contains a nested resource""" value_type = 'resource' def __init__(self, description, resource_type=Resource, subfields=None, **kwargs): super(ResourceField, self).__init__( self.value_type, description, **kwargs) self.resource_type = resource_type if subfields is None: subfields = resource_type._default_fields self.subfields = subfields self.resource_instance = self.resource_type( 'nested_resource', fields=self.subfields) def doc_dict(self): doc = super(ResourceField, self).doc_dict() doc['resource_type'] = self.resource_type._value_type if self.subfields is None: logging.warn("paledoc: `subfields` on ResourceField %s is None", self.__class__.__name__) doc['default_fields'] = list(self.subfields or []) return doc def render(self, obj, name, context): if obj is None: return None # the base renderer basically just calls getattr, so it will # return the resource here resource = super(ResourceField, self).render(obj, name, context) renderer = self.resource_instance._render_serializable output = renderer(resource, context) return output
class ResourceField(BaseField): '''A field that contains a nested resource''' def __init__(self, description, resource_type=Resource, subfields=None, **kwargs): pass def doc_dict(self): pass def render(self, obj, name, context): pass
4
1
12
1
10
1
2
0.09
1
3
1
0
3
3
3
7
45
9
33
16
25
3
23
12
19
2
2
1
6
147,312
Loudr/pale
Loudr_pale/tests/test_resource_patch.py
tests.test_resource_patch.ResourcePatchTests
class ResourcePatchTests(unittest.TestCase): def setUp(self): super(ResourcePatchTests, self).setUp() def test_patch_resource(self): user = User( id="001", username="soundofjw", ) patch_data = { 'username': 'ammoses', 'stats': { 'logins': 12 }, 'counters': [ {'name': 'products', 'value': 36} ], 'tokens': [ 'gold-coin' ], 'bad_field': True, } user_resouce = UserResource() dt = user_resouce._render_serializable(user, None) self.assertEqual(dt['username'], 'soundofjw') self.assertEqual(dt['stats']['logins'], 0) self.assertEqual(dt['counters'], []) self.assertEqual(dt['tokens'], []) patch = ResourcePatch(patch_data, user_resouce) patch.ignore_missing_fields = True patch.apply_to_model(user) dt = user_resouce._render_serializable(user, None) self.assertEqual(dt['username'], 'ammoses') self.assertEqual(dt['stats']['logins'], 12) self.assertEqual(dt['counters'][0], {'name': 'products', 'value': 36}) self.assertEqual(dt['tokens'][0], 'gold-coin')
class ResourcePatchTests(unittest.TestCase): def setUp(self): pass def test_patch_resource(self): pass
3
0
21
4
17
0
1
0
1
4
3
0
2
0
2
74
44
9
35
8
32
0
20
8
17
1
2
0
2
147,313
Loudr/pale
Loudr_pale/tests/test_resource_patch.py
tests.test_resource_patch.StatsResource
class StatsResource(Resource): _value_type = 'Test "stats" resource for patches' _underlying_model = Stats logins = IntegerField("Number of logins")
class StatsResource(Resource): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
5
1
4
4
3
0
4
4
3
0
1
0
0
147,314
Loudr/pale
Loudr_pale/pale/fields/decimal_field.py
pale.fields.decimal_field.DecimalField
class DecimalField(BaseField): """A BaseField whose type is to be handled by `decimal.Decimal`. kwargs: quantize: `str`. Used with Decimal.quantize, which rounds the value to a given digit precision. prefix: `str`. String to prepend to the output. Useful for prefixing currencies. Usage: dollar_amount = DecimalField("Dollar amount rounded to nearest penny", quantize='.01', prefix='$') """ value_type = 'decimal' def __init__(self, description, **kwargs): quantize = kwargs.pop('quantize', None) self.quantize = Decimal(quantize) if quantize else None self.prefix = kwargs.pop('prefix', None) or '' super(DecimalField, self).__init__( self.value_type, description, **kwargs) def render(self, obj, name, context): if obj is None: return None value = super(DecimalField, self).render(obj, name, context) if value is None: return None value = Decimal(value) if self.quantize: value = value.quantize(self.quantize) return self.prefix+str(value)
class DecimalField(BaseField): '''A BaseField whose type is to be handled by `decimal.Decimal`. kwargs: quantize: `str`. Used with Decimal.quantize, which rounds the value to a given digit precision. prefix: `str`. String to prepend to the output. Useful for prefixing currencies. Usage: dollar_amount = DecimalField("Dollar amount rounded to nearest penny", quantize='.01', prefix='$') ''' def __init__(self, description, **kwargs): pass def render(self, obj, name, context): pass
3
1
10
1
9
0
3
0.6
1
3
0
0
2
2
2
6
41
9
20
8
17
12
17
8
14
4
2
1
6
147,315
Loudr/pale
Loudr_pale/pale/fields/integer.py
pale.fields.integer.IntegerField
class IntegerField(BaseField): """A BaseField whose type is `integer`.""" value_type = 'integer' def __init__(self, description, **kwargs): super(IntegerField, self).__init__( self.value_type, description, **kwargs)
class IntegerField(BaseField): '''A BaseField whose type is `integer`.''' def __init__(self, description, **kwargs): pass
2
1
5
0
5
0
1
0.14
1
1
0
0
1
0
1
5
9
1
7
3
5
1
4
3
2
1
2
0
1
147,316
Loudr/pale
Loudr_pale/pale/arguments/url.py
pale.arguments.url.URLArgument
class URLArgument(StringArgument): def __init__(self, *args, **kwargs): self.path_only = kwargs.pop('path_only', False) super(URLArgument, self).__init__(*args, **kwargs) def validate_url(self, original_string): """Returns the original string if it was valid, raises an argument error if it's not. """ # nipped from stack overflow: http://stackoverflow.com/questions/827557/how-do-you-validate-a-url-with-a-regular-expression-in-python # I preferred this to the thorough regex approach for simplicity and # readability pieces = urlparse.urlparse(original_string) try: if self.path_only: assert not any([pieces.scheme, pieces.netloc]) assert pieces.path else: assert all([pieces.scheme, pieces.netloc]) valid_chars = set(string.letters + string.digits + ":-_.") assert set(pieces.netloc) <= valid_chars assert pieces.scheme in ['http', 'https'] except AssertionError as e: raise ArgumentError(self.item_name, "The input you've provided is not a valid URL.") return pieces def validate(self, item, item_name): self.item_name = item_name item = super(URLArgument, self).validate(item, item_name) if item is not None: item = self.validate_url(item) return item
class URLArgument(StringArgument): def __init__(self, *args, **kwargs): pass def validate_url(self, original_string): '''Returns the original string if it was valid, raises an argument error if it's not. ''' pass def validate_url(self, original_string): pass
4
1
11
1
8
2
2
0.24
1
4
1
0
3
2
3
14
37
6
25
9
21
6
23
8
19
3
4
2
6
147,317
Loudr/pale
Loudr_pale/pale/arguments/string.py
pale.arguments.string.StringListArgument
class StringListArgument(ListArgument): """StringListArgument is a special case of ListArgument that allows for passing in a single string as the argument, and using a separator to split it into a list.""" allowed_types = (list, tuple, str, unicode) list_item_type = StringArgument('String list') def __init__(self, *args, **kwargs): self.separator = kwargs.pop('separator', ' ') self.trim_whitespace = kwargs.pop('trim_whitespace', False) super(StringListArgument, self).__init__(*args, **kwargs) def validate(self, item_list, item_name): if item_list is None: item_list = self.default if isinstance(item_list, (str, unicode)): item_list = item_list.split(self.separator) elif isinstance(item_list, list) and len(item_list) == 1: # Separate QS strings which come in as a single list. if isinstance(item_list[0], basestring) and self.separator in item_list[0]: item_list = item_list[0].split(self.separator) if self.trim_whitespace: item_list = [ item.strip() for item in item_list ] # list validation item_list = super(StringListArgument, self).validate(item_list, item_name) if item_list is not None: item_list = [unicode(val) for val in item_list] return item_list
class StringListArgument(ListArgument): '''StringListArgument is a special case of ListArgument that allows for passing in a single string as the argument, and using a separator to split it into a list.''' def __init__(self, *args, **kwargs): pass def validate(self, item_list, item_name): pass
3
1
12
2
10
1
4
0.23
1
3
0
1
2
2
2
15
32
5
22
7
19
5
20
7
17
7
4
2
8
147,318
Loudr/pale
Loudr_pale/pale/arguments/string.py
pale.arguments.string.StringArgument
class StringArgument(BaseArgument): allowed_types = (str, unicode) min_length = None max_length = None def validate(self, item, item_name): if item is None: # TODO: should we also set the default here if item is empty string? item = self.default self._validate_type(item, item_name) if self.required is True and \ (item is None or unicode(item) == ""): raise ArgumentError(item_name, ("This argument is required, and cannot be an empty " "string.")) if item is not None: item = unicode(item) return item def doc_dict(self): doc = super(StringArgument, self).doc_dict() doc['min_length'] = self.min_length doc['max_length'] = self.max_length return doc
class StringArgument(BaseArgument): def validate(self, item, item_name): pass def doc_dict(self): pass
3
0
10
1
9
1
3
0.05
1
2
1
1
2
0
2
11
27
5
21
7
18
1
18
7
15
4
3
1
5
147,319
Loudr/pale
Loudr_pale/pale/arguments/scope.py
pale.arguments.scope.ScopeArgument
class ScopeArgument(StringListArgument): """A field for OAuth 2.0 Scope strings. This is basically just a space-separated string list""" def __init__(self, *args, **kwargs): kwargs['separator'] = ' ' super(ScopeArgument, self).__init__(*args, **kwargs)
class ScopeArgument(StringListArgument): '''A field for OAuth 2.0 Scope strings. This is basically just a space-separated string list''' def __init__(self, *args, **kwargs): pass
2
1
3
0
3
0
1
0.5
1
1
0
0
1
0
1
16
8
2
4
2
2
2
4
2
2
1
5
0
1
147,320
Loudr/pale
Loudr_pale/pale/arguments/number.py
pale.arguments.number.IntegerArgument
class IntegerArgument(BaseArgument): value_type = 'integer' allowed_types = (int, long) min_value = None max_value = None def validate(self, item, item_name): if item is None: item = self.default if item is None: # i.e. the default was also None if self.required: raise ArgumentError(item_name, "This argument is required.") else: return item # it's an integer, so just try to shove it into that. try: item = int(item) except ValueError as e: # if it fails, then the argument is wrong raise ArgumentError(item_name, "%s is not a valid integer" % item) # range checking if self.min_value is not None and\ self.max_value is not None and\ not (self.min_value <= item <= self.max_value): raise ArgumentError(item_name, "You must provide a value between %d and %d" % ( self.min_value, self.max_value)) if self.min_value is not None and item < self.min_value: raise ArgumentError(item_name, "You must provide a value greater than or equal to %d" % ( self.min_value)) if self.max_value is not None and item > self.max_value: raise ArgumentError(item_name, "You must provide a value less than or equal to %d" % ( self.max_value)) return item def doc_dict(self): doc = super(IntegerArgument, self).doc_dict() doc['min_value'] = self.min_value doc['max_value'] = self.max_value return doc
class IntegerArgument(BaseArgument): def validate(self, item, item_name): pass def doc_dict(self): pass
3
0
22
3
17
2
5
0.1
1
4
1
0
2
0
2
11
51
9
39
9
36
4
28
8
25
8
3
2
9
147,321
Loudr/pale
Loudr_pale/pale/arguments/number.py
pale.arguments.number.FloatArgument
class FloatArgument(BaseArgument): value_type = 'float' allowed_types = (float, ) min_value = None max_value = None def validate(self, item, item_name): if item is None: item = self.default if item is None: # i.e. the default was also None if self.required: raise ArgumentError(item_name, "This argument is required.") else: return item # it's an integer, so just try to shove it into that. try: item = float(item) except ValueError as e: # if it fails, then the argument is wrong raise ArgumentError(item_name, "%s is not a valid integer" % item) # range checking if self.min_value is not None and\ self.max_value is not None and\ not (self.min_value <= item <= self.max_value): raise ArgumentError(item_name, "You must provide a value between %d and %d" % ( self.min_value, self.max_value)) if self.min_value is not None and item < self.min_value: raise ArgumentError(item_name, "You must provide a value greater than or equal to %d" % ( self.min_value)) if self.max_value is not None and item > self.max_value: raise ArgumentError(item_name, "You must provide a value less than or equal to %d" % ( self.max_value)) return item def doc_dict(self): doc = super(FloatArgument, self).doc_dict() doc['min_value'] = self.min_value doc['max_value'] = self.max_value return doc
class FloatArgument(BaseArgument): def validate(self, item, item_name): pass def doc_dict(self): pass
3
0
22
3
17
2
5
0.1
1
4
1
0
2
0
2
11
51
9
39
9
36
4
28
8
25
8
3
2
9
147,322
Loudr/pale
Loudr_pale/pale/arguments/boolean.py
pale.arguments.boolean.BooleanArgument
class BooleanArgument(BaseArgument): allowed_types = (bool, ) def validate(self, item, item_name): if item is None: item = self.default if isinstance(item, (str, unicode)): # coerce string types to bool, since we might get a string type # from the HTTP library val = item.lower() if val == 'true' or val == '1': item = True elif val == 'false' or val == '0': item = False else: raise ArgumentError(item_name, "Invalid string value '%s'. " "Boolean arguments must be either 'true' or 'false'." % (val,)) self._validate_type(item, item_name) if self.required is True and item is None: raise ArgumentError(item_name, "This argument is required.") return item
class BooleanArgument(BaseArgument): def validate(self, item, item_name): pass
2
0
24
4
18
2
6
0.1
1
2
1
0
1
0
1
10
27
5
20
4
18
2
15
4
13
6
3
2
6
147,323
Loudr/pale
Loudr_pale/pale/fields/string.py
pale.fields.string.StringField
class StringField(BaseField): """A BaseField whose type is `string`.""" value_type = 'string' def __init__(self, description, **kwargs): super(StringField, self).__init__( self.value_type, description, **kwargs)
class StringField(BaseField): '''A BaseField whose type is `string`.''' def __init__(self, description, **kwargs): pass
2
1
5
0
5
0
1
0.14
1
1
0
3
1
0
1
5
9
1
7
3
5
1
4
3
2
1
2
0
1
147,324
Loudr/pale
Loudr_pale/pale/fields/scope.py
pale.fields.scope.ScopeField
class ScopeField(StringField): """A field for the OAuth 2.0 Scope parameter""" value_type = 'oauth scope'
class ScopeField(StringField): '''A field for the OAuth 2.0 Scope parameter''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
5
3
0
2
2
1
1
2
2
1
0
3
0
0
147,325
Loudr/pale
Loudr_pale/pale/arguments/base.py
pale.arguments.base.ListArgument
class ListArgument(BaseArgument): """A basic List Argument type, with flexible type support. This base list abstraction supports a set of allowed item types, and iterates through the passed in items to validate each one individually. If any single item is invalid, then the entire list is considered to be invalid, and an argument error is thrown. """ allowed_types = (list, tuple) list_item_type = "*" def __init__(self, *args, **kwargs): self.list_item_type = kwargs.pop('item_type', self.list_item_type) super(ListArgument, self).__init__(*args, **kwargs) def _validate_required(self, item, name): super(ListArgument, self)._validate_required(item, name) # should we also validate that the list is not empty? def validate_items(self, input_list): """Validates that items in the list are of the type specified. Returns the input list if it's valid, or raises an ArgumentError if it's not.""" output_list = [] for item in input_list: valid = self.list_item_type.validate(item, self.item_name) output_list.append(valid) # this might lead to confusing error messages. tbh, we need to # figure out a better way to do validation and error handling here, # but i'm brute forcing this a bit so that we have something # workable return output_list def validate(self, item, item_name): self.item_name = item_name if item is None: item = self.default self._validate_type(item, item_name) self._validate_required(item, item_name) # item might still be None if it's not required, has no default, # and wasn't passed in if item is None: return item item_list = list(item) validated_list = self.validate_items(item_list) return validated_list
class ListArgument(BaseArgument): '''A basic List Argument type, with flexible type support. This base list abstraction supports a set of allowed item types, and iterates through the passed in items to validate each one individually. If any single item is invalid, then the entire list is considered to be invalid, and an argument error is thrown. ''' def __init__(self, *args, **kwargs): pass def _validate_required(self, item, name): pass def validate_items(self, input_list): '''Validates that items in the list are of the type specified. Returns the input list if it's valid, or raises an ArgumentError if it's not.''' pass def validate_items(self, input_list): pass
5
2
9
1
6
2
2
0.64
1
2
0
1
4
1
4
13
55
14
25
13
20
16
25
13
20
3
3
1
7
147,326
Loudr/pale
Loudr_pale/tests/example_app/api/resources.py
tests.example_app.api.resources.DateTimeResource
class DateTimeResource(Resource): """A simple datetime resource used for testing Pale Resources.""" _value_type = 'DateTime Resource' _underlying_model = DateTimeModel year = IntegerField("The year of the returned DateTime") month = IntegerField("A month, between 1 and 12") day = IntegerField("The date of the month") hours = IntegerField("The hours time, between 0 and 23") minutes = IntegerField("The minutes, between 0 and 59") seconds = IntegerField("The seconds, between 0 and 59") isoformat = StringField("The DateTime's ISO representation", property_name='iso') eurodate = StringField("The date in DD.MM.YYYY format", value=lambda item: item.timestamp.strftime("%d.%m.%Y")) name = StringField("Your DateTime's name", details="This value will be `null` on most DateTimes. It's " "only set when the DateTime is created with `/parse_time/` " "and a `name` is passed in.") _default_fields = ('year', 'month', 'day', 'isoformat') def _render_serializable(self, instance, context): """Render a datetime for the context provided""" if not isinstance(instance, DateTimeModel): """This check is here for illustration purposes, but isn't strictly required, as long as you make sure you send the correct objects to their correct serializers.""" raise ValueError(("You broke the test app by trying to pass " "something other than a `DateTimeModel` to the " "DateTimeResource serializer.")) output = super(DateTimeResource, self)._render_serializable( instance, context) # add fields based on the instance state if instance.include_time: output['hours'] = instance.hours output['minutes'] = instance.minutes output['seconds'] = instance.seconds if instance.name is not None: output['name'] = instance.name # Typically, the context is also used to selectively render (or hide) # specific fields based on the current user, and whether or not they own # the object that they're trying to obtain. # But we're not doing that in this example. return output
class DateTimeResource(Resource): '''A simple datetime resource used for testing Pale Resources.''' def _render_serializable(self, instance, context): '''Render a datetime for the context provided''' pass
2
2
29
6
14
9
4
0.29
1
3
1
0
1
0
1
1
61
16
35
15
33
10
24
15
22
4
1
1
4
147,327
Loudr/pale
Loudr_pale/pale/fields/resource.py
pale.fields.resource.ResourceListField
class ResourceListField(BaseField): """A Field that contains a list of Fields.""" item_type = ResourceField value_type = 'resource_list' def __init__(self, description, resource_type=Resource, subfields=None, **kwargs): super(ResourceListField, self).__init__( self.value_type, description=description, **kwargs) self.resource_type = resource_type if subfields is None: subfields = resource_type._default_fields self.subfields = subfields self.resource_instance = self.resource_type( 'nested_resource', fields=self.subfields) def doc_dict(self): doc = super(ResourceListField, self).doc_dict() doc['resource_type'] = self.resource_type._value_type return doc def render(self, obj, name, context): if obj is None: return None output = [] # again, the base renderer basically just calls getattr. # We're expecting the attr to be a list, though. resources = super(ResourceListField, self).render(obj, name, context) renderer = self.resource_instance._render_serializable for res in resources: item = renderer(res, context) output.append(item) return output
class ResourceListField(BaseField): '''A Field that contains a list of Fields.''' def __init__(self, description, resource_type=Resource, subfields=None, **kwargs): pass def doc_dict(self): pass def render(self, obj, name, context): pass
4
1
12
1
10
1
2
0.09
1
2
1
0
3
3
3
7
45
9
33
19
25
3
24
15
20
3
2
1
6
147,328
Loudr/pale
Loudr_pale/pale/arguments/base.py
pale.arguments.base.JsonDictArgument
class JsonDictArgument(BaseArgument): allowed_types = (dict, set) def __init__(self, *args, **kwargs): self.field_map = kwargs.pop('field_map', {}) self.allow_extra_fields = kwargs.pop('allow_extra_fields', False) super(JsonDictArgument, self).__init__(*args, **kwargs) def validate(self, item, item_name): if isinstance(item, basestring): try: item = json.loads(item) except ValueError as e: logging.error("couldn't serialize json from item: '%s'", item) raise ArgumentError(item_name, "Invalid JSON string: '%s'" % item) self._validate_type(item, item_name) if item is None: return item item_keys = item.keys() field_keys = self.field_map.keys() extra_keys = [ k for k in item_keys if k not in field_keys ] missing_keys = [ k for k in field_keys if k not in item_keys ] if len(extra_keys) > 0 and not self.allow_extra_fields: raise ArgumentError(item_name, "Extra keys '%s' in item are not allowed" % extra_keys) output_dict = dict() for item_key, argument in self.field_map.iteritems(): item_value = item.get(item_key, None) nested_item_name = "%s.%s" % (item_name, item_key) validated = argument.validate(item_value, nested_item_name) output_dict[item_key] = validated for extra in extra_keys: val = item[extra] logging.debug("Adding unvalidated value '%s: %s' to json dict %s", extra, val, item_name) output_dict[extra] = val return output_dict
class JsonDictArgument(BaseArgument): def __init__(self, *args, **kwargs): pass def validate(self, item, item_name): pass
3
0
21
4
18
0
4
0
1
4
1
0
2
2
2
11
47
10
37
18
34
0
33
17
30
7
3
2
8
147,329
Loudr/pale
Loudr_pale/tests/example_app/api/resources.py
tests.example_app.api.resources.DateTimeRangeResource
class DateTimeRangeResource(Resource): """A time range that returns some nested resources""" _value_type = "DateTime Range Resource" _underlying_model = DateTimeRangeModel duration_microseconds = IntegerField( "The range's duration in microseconds.") start = ResourceField("The starting datetime of the range.", resource_type=DateTimeResource) end = ResourceField( "The ending datetime of the range.", resource_type=DateTimeResource, subfields=DateTimeResource._all_fields())
class DateTimeRangeResource(Resource): '''A time range that returns some nested resources''' pass
1
1
0
0
0
0
0
0.09
1
0
0
0
0
0
0
0
17
5
11
6
10
1
6
6
5
0
1
0
0
147,330
Loudr/pale
Loudr_pale/tests/test_arguments.py
tests.test_arguments.ArgumentTests
class ArgumentTests(unittest.TestCase): def expect_valid_argument(self, arg_inst, value, expected): validated = arg_inst.validate(value, 'test item') self.assertEqual(validated, expected) def expect_invalid_argument(self, arg_inst, value): with self.assertRaises(ArgumentError): validated = arg_inst.validate(value, 'test item') def test_boolean_argument(self): required_bool_arg = BooleanArgument('test bool arg', required=True) self.expect_valid_argument(required_bool_arg, 'true', True) self.expect_valid_argument(required_bool_arg, 'TRUE', True) self.expect_valid_argument(required_bool_arg, 'True', True) self.expect_valid_argument(required_bool_arg, 'TrUe', True) self.expect_valid_argument(required_bool_arg, 'false', False) self.expect_valid_argument(required_bool_arg, 'FALSE', False) self.expect_valid_argument(required_bool_arg, 'False', False) self.expect_valid_argument(required_bool_arg, 'FaLSe', False) self.expect_invalid_argument(required_bool_arg, None) self.expect_invalid_argument(required_bool_arg, 'hello') # allow 0/1 integers, but not other ints self.expect_valid_argument(required_bool_arg, '0', False) self.expect_valid_argument(required_bool_arg, '1', True) self.expect_invalid_argument(required_bool_arg, '-241') self.expect_invalid_argument(required_bool_arg, '241') self.expect_invalid_argument(required_bool_arg, '0.0') self.expect_invalid_argument(required_bool_arg, '1.0') self.expect_invalid_argument(required_bool_arg, '1.234') optional_bool_arg = BooleanArgument('test arg', required=False) self.expect_valid_argument(optional_bool_arg, 'True', True) self.expect_valid_argument(optional_bool_arg, None, None) default_bool_arg = BooleanArgument('test arg', required=False, default=False) self.expect_valid_argument(default_bool_arg, None, False) # passing a value overrides the default self.expect_valid_argument(default_bool_arg, 'true', True) required_default_bool_arg = BooleanArgument('test arg', required=True, default=False) self.expect_valid_argument(required_default_bool_arg, None, False) self.expect_valid_argument(required_default_bool_arg, 'true', True) def test_string_argument(self): # damn near everything will probably come in as a string, so there's # only so much to test without regex matching required_string_arg = StringArgument('test string arg', required=True) self.expect_valid_argument(required_string_arg, 'hello, world', 'hello, world') self.expect_valid_argument(required_string_arg, '12345', '12345') self.expect_invalid_argument(required_string_arg, None) self.expect_invalid_argument(required_string_arg, '') optional_string_arg = StringArgument('test string arg', required=False) self.expect_valid_argument(optional_string_arg, 'hello, world', 'hello, world') self.expect_valid_argument(optional_string_arg, None, None) default_string_arg = StringArgument('test string arg', required=False, default="hello tests") self.expect_valid_argument(default_string_arg, 'hello, world', 'hello, world') self.expect_valid_argument(default_string_arg, None, 'hello tests') required_default_string_arg = StringArgument('test string arg', required=True, default="hello tests") self.expect_valid_argument(required_default_string_arg, 'hello, world', 'hello, world') self.expect_valid_argument(required_default_string_arg, None, 'hello tests') def test_url_argument(self): required_url_arg = URLArgument('test url arg', required=True) google_url = urlparse.urlparse('https://www.google.com/') ftp_url = urlparse.urlparse('ftp://www.google.com/') url_path = urlparse.urlparse('/foo/bar/baz') url_path_with_query = urlparse.urlparse('/foo/bar/baz?query=hi') url_path_with_fragment = urlparse.urlparse('/foo/bar/baz#hello') url_path_with_query_fragment = urlparse.urlparse( '/foo/bar/baz?query=hi#hello') self.expect_invalid_argument(required_url_arg, None) self.expect_invalid_argument(required_url_arg, '') self.expect_invalid_argument(required_url_arg, ftp_url.geturl()) self.expect_invalid_argument(required_url_arg, 'i am not a url') self.expect_invalid_argument(required_url_arg, url_path.geturl()) self.expect_valid_argument(required_url_arg, google_url.geturl(), google_url) optional_url_arg = URLArgument('test string arg', required=False) self.expect_valid_argument(optional_url_arg, None, None) self.expect_valid_argument(optional_url_arg, google_url.geturl(), google_url) url_path_arg = URLArgument('test string arg', path_only=True) self.expect_invalid_argument(url_path_arg, google_url.geturl()) self.expect_valid_argument(url_path_arg, url_path.geturl(), url_path) self.expect_valid_argument(url_path_arg, url_path_with_query.geturl(), url_path_with_query) self.expect_valid_argument(url_path_arg, url_path_with_fragment.geturl(), url_path_with_fragment) self.expect_valid_argument(url_path_arg, url_path_with_query_fragment.geturl(), url_path_with_query_fragment) def test_integer_argument(self): required_int_arg = IntegerArgument('test integer arg', required=True) self.expect_invalid_argument(required_int_arg, 'i am not an int') # single characters aren't accidentally converted to ascii values self.expect_invalid_argument(required_int_arg, 'Q') self.expect_invalid_argument(required_int_arg, None) self.expect_valid_argument(required_int_arg, '123', 123) # no floats self.expect_invalid_argument(required_int_arg, '123.45') self.expect_valid_argument(required_int_arg, '-159', -159) optional_int_arg = IntegerArgument('test integer arg') self.expect_invalid_argument(optional_int_arg, 'i am not an int') self.expect_valid_argument(optional_int_arg, None, None) self.expect_valid_argument(optional_int_arg, '75', 75) default_int_arg = IntegerArgument('test integer arg', default=42) self.expect_invalid_argument(default_int_arg, 'i am not an int') self.expect_valid_argument(default_int_arg, None, 42) self.expect_valid_argument(default_int_arg, '33', 33) default_required_int_arg = IntegerArgument('test integer arg', default=42, required=True) self.expect_invalid_argument(default_required_int_arg, 'i am not an int') self.expect_valid_argument(default_required_int_arg, None, 42) self.expect_valid_argument(default_required_int_arg, '33', 33) self.expect_valid_argument(default_required_int_arg, '0', 0) minimum_int_arg = IntegerArgument('test integer arg', min_value=9) self.expect_invalid_argument(minimum_int_arg, 'i am not an int') self.expect_invalid_argument(minimum_int_arg, 8) self.expect_invalid_argument(minimum_int_arg, -873) self.expect_valid_argument(minimum_int_arg, 9, 9) self.expect_valid_argument(minimum_int_arg, 31423, 31423) maximum_int_arg = IntegerArgument('test integer arg', max_value=9) self.expect_invalid_argument(maximum_int_arg, 'i am not an int') self.expect_invalid_argument(maximum_int_arg, 10) self.expect_invalid_argument(maximum_int_arg, 873) self.expect_valid_argument(maximum_int_arg, 9, 9) self.expect_valid_argument(maximum_int_arg, -31423, -31423) min_max_int_arg = IntegerArgument('test integer arg', min_value=0, max_value=9) self.expect_invalid_argument(min_max_int_arg, 'i am not an int') self.expect_invalid_argument(min_max_int_arg, 10) self.expect_invalid_argument(min_max_int_arg, 873) self.expect_invalid_argument(min_max_int_arg, -1) self.expect_invalid_argument(min_max_int_arg, -972151) self.expect_valid_argument(min_max_int_arg, 9, 9) self.expect_valid_argument(min_max_int_arg, 0, 0) self.expect_valid_argument(min_max_int_arg, 5, 5) def test_float_argument(self): required_float_arg = FloatArgument('test float arg', required=True) self.expect_invalid_argument(required_float_arg, 'i am not a float') # single characters aren't accidentally converted to ascii values self.expect_invalid_argument(required_float_arg, 'Q') self.expect_invalid_argument(required_float_arg, None) self.expect_valid_argument(required_float_arg, '123', 123.0) self.expect_valid_argument(required_float_arg, '123.45', 123.45) self.expect_valid_argument(required_float_arg, '-159', -159.0) optional_float_arg = FloatArgument('test float arg') self.expect_invalid_argument(optional_float_arg, 'i am not a float') self.expect_valid_argument(optional_float_arg, None, None) self.expect_valid_argument(optional_float_arg, '3.14159', 3.14159) default_float_arg = FloatArgument('test float arg', default=1.5) self.expect_invalid_argument(default_float_arg, 'i am not a float') self.expect_valid_argument(default_float_arg, None, 1.5) self.expect_valid_argument(default_float_arg, 42.245, 42.245) min_float_arg = FloatArgument('test float arg', min_value=0.2) self.expect_invalid_argument(min_float_arg, 'i am not a float') self.expect_invalid_argument(min_float_arg, '-1.589') self.expect_invalid_argument(min_float_arg, '0.1') self.expect_valid_argument(min_float_arg, '0.2', 0.2) self.expect_valid_argument(min_float_arg, '12.245', 12.245) max_float_arg = FloatArgument('test float arg', max_value=100.0) self.expect_invalid_argument(max_float_arg, 'i am not a float') self.expect_invalid_argument(max_float_arg, '158.9') self.expect_invalid_argument(max_float_arg, '100.1') self.expect_valid_argument(max_float_arg, '0.1', 0.1) self.expect_valid_argument(max_float_arg, '99.9', 99.9) self.expect_valid_argument(max_float_arg, '-102.245', -102.245) min_max_float_arg = FloatArgument('test float arg', min_value=0.0, max_value=1.0) self.expect_invalid_argument(min_max_float_arg, 'i am not a float') self.expect_invalid_argument(min_max_float_arg, '1.1') self.expect_invalid_argument(min_max_float_arg, '-102.245') self.expect_invalid_argument(min_max_float_arg, '99.9') self.expect_valid_argument(min_max_float_arg, '0.1', 0.1) self.expect_valid_argument(min_max_float_arg, '0.567235', 0.567235) self.expect_valid_argument(min_max_float_arg, '0', 0.0) self.expect_valid_argument(min_max_float_arg, '1', 1.0) def test_scope_argument(self): required_scope_arg = ScopeArgument('test scope arg', required=True) self.expect_invalid_argument(required_scope_arg, None) self.expect_valid_argument(required_scope_arg, "hello world", ['hello', 'world']) self.expect_valid_argument(required_scope_arg, "hello.world and.goodbye.mars", ['hello.world', 'and.goodbye.mars']) def test_string_list_argument(self): comma_separated_string_list = StringListArgument('test string list arg', separator=',', trim_whitespace=False, required=True) self.expect_invalid_argument(comma_separated_string_list, None) self.expect_valid_argument(comma_separated_string_list, "hello world", ['hello world']) self.expect_valid_argument(comma_separated_string_list, "hello,world", ['hello', 'world']) self.expect_valid_argument(comma_separated_string_list, "hello, world", ['hello', ' world']) # it can also handle querystring lists, in which case, it'll get a list # directly, rather than a value-separated string self.expect_valid_argument(comma_separated_string_list, ['hello', 'world'], ['hello', 'world']) self.expect_valid_argument(comma_separated_string_list, ['hello', ' world'], ['hello', ' world']) comma_separated_string_list.trim_whitespace = True self.expect_valid_argument(comma_separated_string_list, "hello, world", ['hello', 'world']) self.expect_valid_argument(comma_separated_string_list, ['hello', 'world'], ['hello', 'world']) self.expect_valid_argument(comma_separated_string_list, ['hello', ' world'], ['hello', 'world']) def test_list_argument(self): required_bool_list_arg = ListArgument('test list arg', required=True, item_type=BooleanArgument('Boolean items')) self.expect_invalid_argument(required_bool_list_arg, 'true') self.expect_valid_argument(required_bool_list_arg, ['true', 'True', '1', 'false'], [True, True, True, False]) self.expect_invalid_argument(required_bool_list_arg, ['true', 'True', '1', 'false', 'hello, world']) optional_list_arg = ListArgument('test list arg', item_type=StringArgument('a string')) self.expect_valid_argument(optional_list_arg, None, None) def test_dict_argument(self): # because sometimes you want to pass a json dictionary... required_dict_arg = JsonDictArgument('test dict arg', required=True, field_map={ 'foo': StringArgument("the thing's foo", required=True), 'count': IntegerArgument('why not have a count?', required=True), 'optionals': StringListArgument("more optional things") }) valid_dict = { 'foo': 'hello', 'count': 5 } expected_dict = { 'foo': 'hello', 'count': 5, 'optionals': None } self.expect_valid_argument(required_dict_arg, json.dumps(valid_dict), expected_dict) self.expect_invalid_argument(required_dict_arg, json.dumps({'foo': 'bar'})) self.expect_invalid_argument(required_dict_arg, 'this is not a json.') self.expect_invalid_argument(required_dict_arg, json.dumps({'foo': 'hi', 'count': 10, 'extra': 'something else'})) allow_extras_dict_arg = JsonDictArgument('test dict arg', required=True, allow_extra_fields=True, field_map={ 'foo': StringArgument("the thing's foo", required=True), 'count': IntegerArgument('why not have a count?', required=True), 'optionals': StringListArgument("more optional things") }) self.expect_valid_argument(allow_extras_dict_arg, json.dumps({ 'foo': 'hi', 'count': 10, 'extra': 'something else', 'optionals': ['hello', 'how are you'] }), { 'foo': 'hi', 'count': 10, 'extra': 'something else', 'optionals': ['hello', 'how are you'] })
class ArgumentTests(unittest.TestCase): def expect_valid_argument(self, arg_inst, value, expected): pass def expect_invalid_argument(self, arg_inst, value): pass def test_boolean_argument(self): pass def test_string_argument(self): pass def test_url_argument(self): pass def test_integer_argument(self): pass def test_float_argument(self): pass def test_scope_argument(self): pass def test_string_list_argument(self): pass def test_list_argument(self): pass def test_dict_argument(self): pass
12
0
29
3
25
1
1
0.04
1
10
10
0
11
0
11
83
339
51
278
52
266
12
187
52
175
1
2
1
11
147,331
Loudr/pale
Loudr_pale/tests/test_fields.py
tests.test_fields.FieldsTests
class FieldsTests(unittest.TestCase): def setUp(self): super(FieldsTests, self).setUp() def test_create_base_field(self): field = BaseField("integer", "This is a test field", details="This is where I put special notes about the field") self.assertEqual(field.value_type, "integer") self.assertEqual(field.description, "This is a test field") self.assertEqual(field.details, "This is where I put special notes about the field") doc = field.doc_dict() self.assertEqual(doc["type"], "integer") self.assertEqual(doc["description"], "This is a test field") self.assertEqual(doc["extended_description"], "This is where I put special notes about the field") # test details default field = BaseField("integer", "This is a test field") self.assertIsNone(field.details) doc = field.doc_dict() self.assertIsNone(doc["extended_description"]) def test_create_string_field(self): field = StringField("Your name", details="You should put a real name here, not some gibberish") self.assertEqual(field.value_type, "string") self.assertEqual(field.description, "Your name") self.assertEqual(field.details, "You should put a real name here, not some gibberish") doc = field.doc_dict() self.assertEqual(doc["type"], "string") self.assertEqual(doc["description"], "Your name") self.assertEqual(doc["extended_description"], "You should put a real name here, not some gibberish") field = StringField("Your name") self.assertIsNone(field.details) doc = field.doc_dict() self.assertIsNone(doc["extended_description"]) def test_integer_field(self): field = IntegerField("The amount of stuff for your things", details="This amount will always be a positive integer, but " "may be only eventually consistent.") self.assertEqual(field.value_type, "integer") self.assertEqual(field.description, "The amount of stuff for your things") self.assertEqual(field.details, "This amount will always be a positive integer, but may " "be only eventually consistent.") doc = field.doc_dict() self.assertEqual(doc["type"], "integer") self.assertEqual(doc["description"], "The amount of stuff for your things") self.assertEqual(doc["extended_description"], "This amount will always be a positive integer, but may " "be only eventually consistent.") field = IntegerField("Some amount thing") self.assertIsNone(field.details) doc = field.doc_dict() self.assertIsNone(doc["extended_description"]) def test_decimal_field(self): field = DecimalField("Dollar amount rounded to nearest penny", quantize='.01', prefix='$') self.assertEqual(field.value_type, "decimal") self.assertEqual(field.description, "Dollar amount rounded to nearest penny") self.assertEqual(field.prefix, "$") self.assertEqual(field.quantize, Decimal(".01")) Object = namedtuple('obj', 'amount') obj = Object(amount=25.77) val = field.render(obj, 'amount', context=None) self.assertEqual(val, '$25.77') obj = Object(amount="25.77") val = field.render(obj, 'amount', context=None) self.assertEqual(val, '$25.77') obj = Object(amount="25.779") val = field.render(obj, 'amount', context=None) self.assertEqual(val, '$25.78') obj = Object(amount="25.772") val = field.render(obj, 'amount', context=None) self.assertEqual(val, '$25.77') obj = Object(amount=None) val = field.render(obj, 'amount', context=None) self.assertIsNone(val) def test_list_field_with_no_item_type(self): list_no_item_type = ListField("This is a test list field", details="You might add information about the list here.") self.assertEqual(list_no_item_type.value_type, "list") self.assertEqual(list_no_item_type.description, "This is a test list field") self.assertEqual(list_no_item_type.details, "You might add information about the list here.") self.assertEqual(list_no_item_type.item_type, BaseField) def test_create_list_field(self): field = ListField("This is a test list field", details="You might add information about the list here.", item_type=StringField) self.assertEqual(field.value_type, "list") self.assertEqual(field.description, "This is a test list field") self.assertEqual(field.details, "You might add information about the list here.") self.assertEqual(field.item_type, StringField) doc = field.doc_dict() self.assertEqual(doc["type"], "list") self.assertEqual(doc["description"], "This is a test list field") self.assertEqual(doc["extended_description"], "You might add information about the list here.") self.assertEqual(doc["item_type"], StringField.value_type) def test_resource_field(self): """Test ResourceField creation and documentation A resource field is the primary way to nest objects. At a high level, a Resource is basically just a format and content specification for a JSON object, so if one of the values in that object is itself another object, it makes sense to specify the nested object as simply a nested resource. """ field = ResourceField("This is a test resource field", details="Why does this Resource have another Resource?", resource_type=DateTimeResource) self.assertEqual(field.value_type, "resource") self.assertEqual(field.description, "This is a test resource field") self.assertEqual(field.details, "Why does this Resource have another Resource?") self.assertEqual(field.resource_type, DateTimeResource) self.assertEqual(field.subfields, DateTimeResource._default_fields) doc = field.doc_dict() self.assertEqual(doc["type"], "resource") self.assertEqual(doc["description"], "This is a test resource field") self.assertEqual(doc["extended_description"], "Why does this Resource have another Resource?") self.assertEqual(doc["resource_type"], DateTimeResource._value_type) self.assertEqual(doc["default_fields"], list(field.subfields)) def test_resource_field_no_type(self): field = ResourceField("This is a test resource field", details="Why does this Resource have another Resource?") self.assertEqual(field.value_type, "resource") self.assertEqual(field.description, "This is a test resource field") self.assertEqual(field.details, "Why does this Resource have another Resource?") self.assertEqual(field.resource_type, Resource) self.assertEqual(field.subfields, None)
class FieldsTests(unittest.TestCase): def setUp(self): pass def test_create_base_field(self): pass def test_create_string_field(self): pass def test_integer_field(self): pass def test_decimal_field(self): pass def test_list_field_with_no_item_type(self): pass def test_create_list_field(self): pass def test_resource_field(self): '''Test ResourceField creation and documentation A resource field is the primary way to nest objects. At a high level, a Resource is basically just a format and content specification for a JSON object, so if one of the values in that object is itself another object, it makes sense to specify the nested object as simply a nested resource. ''' pass def test_resource_field_no_type(self): pass
10
1
18
2
15
1
1
0.06
1
10
7
0
9
0
9
81
183
36
139
26
129
8
101
26
91
1
2
0
9
147,332
Loudr/pale
Loudr_pale/tests/test_flask_adapter.py
tests.test_flask_adapter.FlaskAdapterTests
class FlaskAdapterTests(unittest.TestCase): def setUp(self): from tests.example_app.flask_app import create_pale_flask_app self.flask_app = create_pale_flask_app() self.app = TestApp(self.flask_app) def assertExpectedFields(self, returned_dict, expected_fields): d = returned_dict.copy() # don't clobber the input for f in expected_fields: self.assertIn(f, d) val = d.pop(f) # don't check the val for now # make sure there's nothing extraneous left in the dict self.assertEqual(len(d.keys()), 0) return def test_successful_get_with_route_args(self): now = datetime.datetime.utcnow() resp = self.app.get('/api/arg_test/arg-a/arg-b') self.assertEqual(resp.status_code, 200) self.assertEqual(resp.json, { "arg_a": "arg-a", "arg_b": "arg-b", }) def test_successful_get_without_params(self): now = datetime.datetime.utcnow() resp = self.app.get('/api/time/current') self.assertEqual(resp.status_code, 200) # Test _after_response_handlers self.assertIn("After-Response", resp.headers) self.assertEqual(resp.headers["After-Response"], 'OK') # Test CORS self.assertIn("Access-Control-Allow-Origin", resp.headers) self.assertEqual(resp.headers["Access-Control-Allow-Origin"], '*') # the 'time' value was set in the endpoint handler self.assertIn('time', resp.json_body) # the returned time value should match the resource defined # in tests.example_app.api.resources.py returned_time = resp.json_body['time'] # the endpoint specifies `fields=DateTimeResource._all_fields()` # so, we should expect to find all of them expected_fields = DateTimeResource._all_fields() self.assertExpectedFields(returned_time, expected_fields) self.assertEqual(returned_time['eurodate'], now.strftime("%d.%m.%Y")) def test_successful_post_with_required_params(self): # month is required in the endpoint definition, so we must pass # it in here resp = self.app.post('/api/time/parse', {'month': 2}) self.assertEqual(resp.status_code, 200) self.assertIn('time', resp.json_body) returned_time = resp.json_body['time'] # we didn't specify any other fields in the endpoint definition, # so this one should only get the defaults expected_fields = DateTimeResource._default_fields self.assertExpectedFields(returned_time, expected_fields) self.assertIn('Cache-Control', resp.headers) self.assertEqual('max-age=3', resp.headers['Cache-Control']) def test_successful_json_post_with_required_params(self): # this is the same as the above post, but passes json in the # request body, instead of x-www-form-urlencoded resp = self.app.post_json('/api/time/parse', {'month': 2}) self.assertEqual(resp.status_code, 200) self.assertIn('time', resp.json_body) returned_time = resp.json_body['time'] # we didn't specify any other fields in the endpoint definition, # so this one should only get the defaults expected_fields = DateTimeResource._default_fields self.assertExpectedFields(returned_time, expected_fields) def test_unsuccessful_post_missing_required_params(self): resp = self.app.post('/api/time/parse', status=422) self.assertIn('error', resp.json_body) def test_getting_with_nested_resources(self): test_duration = 60 * 1000 # one minute in milliseconds resp = self.app.get('/api/time/range', {'duration': test_duration}) self.assertEqual(resp.status_code, 200) self.assertIn('range', resp.json_body) returned_range = resp.json_body['range'] self.assertEqual(returned_range['duration_microseconds'], test_duration * 1000) # start has default fields start = returned_range['start'] expected_fields = DateTimeResource._default_fields self.assertExpectedFields(start, expected_fields) # end has all of them end = returned_range['end'] expected_fields = DateTimeResource._all_fields() self.assertExpectedFields(end, expected_fields) def test_resource(self): # Start by resetting the resource. # (multiple test runs from the same process will fail otherwise) resp = self.app.post('/api/resource/reset') self.assertEqual(resp.status_code, 200) self.assertEqual(resp.content_type, 'application/json') self.assertEqual(resp.json, {'key': 'value'}) # Test creating a new resource resp = self.app.put_json('/api/resource', {'key': 'boop'}, headers={'Content-Type': 'application/json'}) self.assertEqual(resp.status_code, 200) self.assertEqual(resp.content_type, 'application/json') self.assertEqual(resp.json, {'key': 'boop'}) # Test retrieving the resource. resp = self.app.get('/api/resource') self.assertEqual(resp.status_code, 200) self.assertEqual(resp.content_type, 'application/json') self.assertEqual(resp.json, {'key': 'boop'}) # Test patching the resource. # Without the correct Content-Type, we expect a 415 error. self.assertRaises(AppError, self.app.patch_json, '/api/resource', {'key': 'value2'}) resp = self.app.patch_json('/api/resource', {'key': 'value2'}, headers={'Content-Type': 'application/merge-patch+json'}) self.assertEqual(resp.status_code, 200) self.assertEqual(resp.content_type, 'application/json') self.assertEqual(resp.json, {'key': 'value2'}) # Test get to ensure the resource persists. resp = self.app.get('/api/resource') self.assertEqual(resp.status_code, 200) self.assertEqual(resp.content_type, 'application/json') self.assertEqual(resp.json, {'key': 'value2'}) # A NoContentResource shouldn't have a Content-Type header (no content!) resp = self.app.post('/api/blank') self.assertEqual(resp.status_code, 204) self.assertEqual(resp.content_type, None)
class FlaskAdapterTests(unittest.TestCase): def setUp(self): pass def assertExpectedFields(self, returned_dict, expected_fields): pass def test_successful_get_with_route_args(self): pass def test_successful_get_without_params(self): pass def test_successful_post_with_required_params(self): pass def test_successful_json_post_with_required_params(self): pass def test_unsuccessful_post_missing_required_params(self): pass def test_getting_with_nested_resources(self): pass def test_resource(self): pass
10
0
17
3
10
3
1
0.31
1
2
1
1
9
2
9
81
165
43
95
36
84
29
87
36
76
2
2
1
10
147,333
Loudr/pale
Loudr_pale/tests/test_paledoc.py
tests.test_paledoc.PaleDocTests
class PaleDocTests(unittest.TestCase): def setUp(self): super(PaleDocTests, self).setUp() from tests.example_app import api as example_pale_app from pale import fields self.example_app = example_pale_app self.example_fields = fields self.doc_dict = generate_doc_dict(self.example_app, test_user) def test_doc_dict_root_structure(self): self.assertTrue('endpoints' in self.doc_dict) self.assertTrue(isinstance(self.doc_dict['endpoints'], dict)) self.assertTrue('resources' in self.doc_dict) self.assertTrue(isinstance(self.doc_dict['resources'], dict)) def test_doc_json(self): json_docs = generate_json_docs(self.example_app, pretty_print=False, user=test_user) # use yaml's safe_load here, because it returns strings instead # of unicode, and we know that our test data doesn't have any # strictly-unicode characters. import yaml json_dict = yaml.safe_load(json_docs) self.assertDictEqual(json_dict, self.doc_dict) def test_endpoint_without_args_docs(self): endpoints = self.doc_dict['endpoints'] # we defined n endpoints in the example app self.assertEqual(len(endpoints), COUNT_ENDPOINTS) # the current time endpoint current_time_doc = endpoints['current_time'] self.assertEqual(current_time_doc['uri'], '/time/current') self.assertEqual(current_time_doc['http_method'], 'GET') self.assertEqual(current_time_doc['arguments'], {}) return_doc = current_time_doc['returns'] self.assertEqual(return_doc['description'], "The DateTimeResource representation of the current time on the server.") self.assertEqual(return_doc['resource_name'], 'DateTime Resource') self.assertEqual(return_doc['resource_type'], 'DateTimeResource') def test_endpoint_with_args_docs(self): endpoints = self.doc_dict['endpoints'] # we defined n endpoints in the example app self.assertEqual(len(endpoints), COUNT_ENDPOINTS) # the current time endpoint parse_time_doc = endpoints['parse_time'] self.assertEqual(parse_time_doc['uri'], '/time/parse') self.assertEqual(parse_time_doc['http_method'], 'POST') return_doc = parse_time_doc['returns'] self.assertEqual(return_doc['description'], "The DateTimeResource corresponding to the timing information sent in by the requester.") self.assertEqual(return_doc['resource_name'], 'DateTime Resource') self.assertEqual(return_doc['resource_type'], 'DateTimeResource') args = parse_time_doc['arguments'] self.assertEqual(len(args), 5) self.assertTrue('year' in args) self.assertTrue('month' in args) self.assertTrue('day' in args) self.assertTrue('name' in args) self.assertTrue('include_time' in args) # the year argument year_arg = args['year'] self.assertEqual(year_arg['description'], "Set the year of the returned datetime.") self.assertFalse('detailed_description' in year_arg) self.assertEqual(year_arg['type'], 'IntegerArgument') self.assertEqual(year_arg['default'], 2015) self.assertEqual(year_arg['required'], False) # month, which has min and max values month_arg = args['month'] self.assertEqual(month_arg['description'], "Set the month of the returned datetime.") self.assertFalse('detailed_description' in month_arg) self.assertEqual(month_arg['type'], 'IntegerArgument') self.assertEqual(month_arg['default'], None) self.assertEqual(month_arg['min_value'], 1) self.assertEqual(month_arg['max_value'], 12) self.assertEqual(month_arg['required'], True) # day, which is barebones day_arg = args['day'] self.assertEqual(day_arg['description'], "Set the day of the returned datetime.") self.assertFalse('detailed_description' in day_arg) self.assertEqual(day_arg['type'], 'IntegerArgument') self.assertEqual(day_arg['default'], None) self.assertEqual(day_arg['required'], False) # name arg name_arg = args['name'] self.assertEqual(name_arg['description'], "The name for your datetime.") self.assertEqual(name_arg['detailed_description'], "You can give your time a name, which will be returned back to you in the response, as the field `name`. If you omit this input parameter, your response won't include a `name`.") self.assertEqual(name_arg['type'], 'StringArgument') self.assertEqual(name_arg['default'], None) self.assertEqual(name_arg['required'], False) self.assertEqual(name_arg['min_length'], 3) self.assertEqual(name_arg['max_length'], 20) # include time incl_time = args['include_time'] self.assertEqual(incl_time['description'], "Include the time in the output?") self.assertEqual(incl_time['detailed_description'], "If present, the response will include JSON fields for the current time, including `hours`, `minutes`, and `seconds`.") self.assertEqual(incl_time['type'], 'BooleanArgument') self.assertEqual(incl_time['default'], False) self.assertEqual(incl_time['required'], False) def test_clean_description(self): """The descriptions need to be free of artifacts created by the documentation process. Also, any string that doesn't end with punctuation is given a period.""" test_leading_spaces = clean_description(" Hey,") self.assertEquals(test_leading_spaces, "Hey,") test_multiple_spaces = clean_description(" look at this!") self.assertEquals(test_multiple_spaces, "look at this!") test_newlines = clean_description("\nsomeone left") self.assertEquals(test_newlines, "someone left.") test_colon = clean_description("this : sentence") self.assertEquals(test_colon, "this = sentence.") test_colon_url = clean_description("at https://loudr.fm") self.assertEquals(test_colon_url, "at https://loudr.fm.") test_machine_code = clean_description("(with code in it)<pale.fields.string.StringField object at 0x106edbed0>") self.assertEquals(test_machine_code, "(with code in it).") test_punctuation = clean_description("hanging") self.assertEquals(test_punctuation, "hanging.") test_empty_string = clean_description("") self.assertEquals(test_empty_string, "", "Leaves empty strings as they are.") test_trailing_whitespace = clean_description("Is this the end? ") self.assertEquals(test_trailing_whitespace, "Is this the end?") def test_resource_doc(self): resources = self.doc_dict['resources'] # we defined n resources in the example app self.assertEqual(len(resources), 3) resource = resources['DateTime Resource'] self.assertEqual(resource['name'], 'DateTime Resource') self.assertEqual(resource['description'], 'A simple datetime resource used for testing Pale Resources.') resource = resources['DateTime Range Resource'] self.assertEqual(resource['name'], 'DateTime Range Resource') self.assertEqual(resource['description'], 'A time range that returns some nested resources.') def test_generate_basic_type_docs(self): fields = self.example_fields sample_existing_types = { "oauth_scope": { "description": "An existing oauth scope type", "type": "base" } } # set up basic fields the same way as generate_raml_docs basic_fields = [] for field_module in inspect.getmembers(fields, inspect.ismodule): for field_class in inspect.getmembers(field_module[1], inspect.isclass): basic_fields.append(field_class[1]) test_types = generate_basic_type_docs(basic_fields, sample_existing_types)[1] self.assertTrue(len(basic_fields) > 0) self.assertTrue(test_types.get('base') != None) self.assertEquals(test_types["base"]["type"], "object") self.assertEquals(test_types["list"]["type"], "array", "Sets type for children of RAML built-in types to their parent type") self.assertEquals(test_types.get("oauth_scope"), None, "Does not overwrite an existing type") def test_generate_raml_tree(self): # set up test_tree the same way as generate_raml_docs from pale import extract_endpoints, extract_resources, is_pale_module raml_resources = extract_endpoints(self.example_app) raml_resource_doc_flat = { ep._route_name: document_endpoint(ep) for ep in raml_resources } test_tree = generate_raml_tree(raml_resource_doc_flat, api_root="api") # check if the tree is parsing the URIs correctly self.assertTrue(test_tree.get("path") != None) self.assertTrue(test_tree["path"]["time"] != None) self.assertTrue(test_tree["path"]["time"]["path"]["current"] != None) self.assertTrue(test_tree["path"]["arg_test/{arg_a}"] != None, "Includes parent folder in the path for URIs") self.assertTrue(test_tree["path"]["arg_test/{arg_a}"]["path"]["{arg_b}"] != None, "Correctly parses nested URIS") test_endpoint = test_tree["path"]["time"]["path"]["parse"]["endpoint"] # check if the endpoint contains what we expect self.assertEquals(test_endpoint["http_method"], "POST") self.assertEquals(test_endpoint["returns"]["resource_type"], "DateTimeResource") self.assertEquals(test_endpoint["arguments"]["month"]["min_value"], 1) def test_generate_raml_resource_types(self): test_types = generate_raml_resource_types(self.example_app) test_string = "day:\n type: integer\n description: The date of the month" self.assertTrue(test_string in test_types, "Contains some of the output we expect") self.assertTrue("affords\n" not in test_types, "Does not contain newlines in descriptions") def test_generate_raml_resources(self): # mock a user instance class User(object): def __init__(self, is_admin): self.is_admin = is_admin test_admin_user = User(True) test_public_user = User(False) test_resources_admin = generate_raml_resources(self.example_app, "", test_admin_user) test_string = "responses:\n 200:\n body:\n description: app resource." self.assertTrue(test_string in test_resources_admin, "Contains some of the output we expect") self.assertTrue("start time.\n" not in test_resources_admin, "Does not contain newlines in descriptions") self.assertTrue("<" not in test_resources_admin, """Does not contain the machine code version of string formatting, like '<pale.fields.string.StringField object at 0x1132bd2d0>' for example""") self.assertTrue("default: False" not in test_resources_admin, "Converts upper-cased Booleans to lower-cased Booleans") test_resources_public = generate_raml_resources(self.example_app, "", test_public_user) test_restricted_resource = "Include the time in the output?" self.assertTrue(test_restricted_resource not in test_resources_public, "Does not include restricted resources for public users") self.assertTrue(test_restricted_resource in test_resources_admin, "Does include restricted resources for admin users")
class PaleDocTests(unittest.TestCase): def setUp(self): pass def test_doc_dict_root_structure(self): pass def test_doc_json(self): pass def test_endpoint_without_args_docs(self): pass def test_endpoint_with_args_docs(self): pass def test_clean_description(self): '''The descriptions need to be free of artifacts created by the documentation process. Also, any string that doesn't end with punctuation is given a period.''' pass def test_resource_doc(self): pass def test_generate_basic_type_docs(self): pass def test_generate_raml_tree(self): pass def test_generate_raml_resource_types(self): pass def test_generate_raml_resources(self): pass class User(object): def __init__(self, is_admin): pass
14
1
20
2
16
2
1
0.11
1
3
1
0
11
3
11
83
255
48
187
65
169
20
156
65
138
3
2
2
14
147,334
Loudr/pale
Loudr_pale/tests/test_paledoc.py
tests.test_paledoc.User
class User(object): def __init__(self): self.is_admin = True
class User(object): def __init__(self): pass
2
0
2
0
2
0
1
0
1
0
0
0
1
1
1
1
3
0
3
3
1
0
3
3
1
1
1
0
1
147,335
Loudr/pale
Loudr_pale/pale/fields/url.py
pale.fields.url.URLField
class URLField(StringField): """A String field that has a URL in it.""" value_type = 'url'
class URLField(StringField): '''A String field that has a URL in it.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
5
3
0
2
2
1
1
2
2
1
0
3
0
0
147,336
Loudr/pale
Loudr_pale/pale/meta.py
pale.meta.MetaHasFields
class MetaHasFields(type): """Metaclass for classes that support named field definitions. In Pale, this is particularly Endpoint and Resource. This metaclass is here to populate the developer-specified fields on the class so that simple API definition like the following is possible: class MyEndpoint(Endpoint): _method = 'GET' _uri = '/hello' name = StringArgument( description="Who should we say Hello to?", default="World") _returns = RawStringResource("A 'Hello, world' string") def _handle(self, context): return "Hello, %s" % context.args.name In the above case, this metaclass allows us to create a `_arguments` map that would store {"name": MyEndpoint.name}. """ def __init__(cls, name, bases, classdict): super(MetaHasFields, cls).__init__(name, bases, classdict) cls._fix_up_fields()
class MetaHasFields(type): '''Metaclass for classes that support named field definitions. In Pale, this is particularly Endpoint and Resource. This metaclass is here to populate the developer-specified fields on the class so that simple API definition like the following is possible: class MyEndpoint(Endpoint): _method = 'GET' _uri = '/hello' name = StringArgument( description="Who should we say Hello to?", default="World") _returns = RawStringResource("A 'Hello, world' string") def _handle(self, context): return "Hello, %s" % context.args.name In the above case, this metaclass allows us to create a `_arguments` map that would store {"name": MyEndpoint.name}. ''' def __init__(cls, name, bases, classdict): pass
2
1
3
0
3
0
1
4
1
1
0
0
1
0
1
14
27
7
4
2
2
16
4
2
2
1
2
0
1
147,337
Loudr/pale
Loudr_pale/tests/test_resource_patch.py
tests.test_resource_patch.Counter
class Counter(object): def __init__(self, key, value=0): self.key = key self.value = value
class Counter(object): def __init__(self, key, value=0): pass
2
0
3
0
3
0
1
0
1
0
0
0
1
2
1
1
4
0
4
4
2
0
4
4
2
1
1
0
1
147,338
Loudr/pale
Loudr_pale/tests/test_resource_patch.py
tests.test_resource_patch.CounterResource
class CounterResource(Resource): _value_type = 'Test repeated nested resources' _underlying_model = Counter name = StringField("Name of counter", property_name='key') value = IntegerField("Value of counter")
class CounterResource(Resource): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
7
1
6
5
5
0
5
5
4
0
1
0
0
147,339
Loudr/pale
Loudr_pale/pale/resource.py
pale.resource.DebugResource
class DebugResource(Resource): """A schema-less resource to help with debugging. This is one of the most dangerous Pale resource types, because it affords you the opportunity to _not define your resource_. You should only use this when you're trying to define your resource fields, or on endpoints that you might not need to keep for the long term. """ def _render_serializable(self, obj, context): return obj
class DebugResource(Resource): '''A schema-less resource to help with debugging. This is one of the most dangerous Pale resource types, because it affords you the opportunity to _not define your resource_. You should only use this when you're trying to define your resource fields, or on endpoints that you might not need to keep for the long term. ''' def _render_serializable(self, obj, context): pass
2
1
2
0
2
0
1
2
1
0
0
0
1
0
1
5
11
2
3
2
1
6
3
2
1
1
2
0
1
147,340
Loudr/pale
Loudr_pale/pale/errors/api_error.py
pale.errors.api_error.APIError
class APIError(BasePaleError): @classmethod def Forbidden(cls, message="You don't have permission to do that."): err = cls(message) err.http_status_code = 403 return err @classmethod def NotFound(cls, message): err = cls(message) err.http_status_code = 404 return err @classmethod def UnprocessableEntity(cls, message): err = cls(message) err.http_status_code = 422 return err @classmethod def UnsupportedMedia(cls, message): err = cls(message) err.http_status_code = 415 return err @classmethod def BadRequest(cls, message): err = cls(message) err.http_status_code = 400 return err @classmethod def Exception(cls, message): err = cls(message) err.http_status_code = 500 return err
class APIError(BasePaleError): @classmethod def Forbidden(cls, message="You don't have permission to do that."): pass @classmethod def NotFound(cls, message): pass @classmethod def UnprocessableEntity(cls, message): pass @classmethod def UnsupportedMedia(cls, message): pass @classmethod def BadRequest(cls, message): pass @classmethod def Exception(cls, message): pass
13
0
4
0
4
0
1
0
1
0
0
0
0
0
6
19
36
5
31
19
18
0
25
13
18
1
4
0
6
147,341
Loudr/pale
Loudr_pale/tests/test_resource_patch.py
tests.test_resource_patch.Stats
class Stats(object): def __init__(self): self.logins = 0
class Stats(object): def __init__(self): pass
2
0
2
0
2
0
1
0
1
0
0
0
1
1
1
1
3
0
3
3
1
0
3
3
1
1
1
0
1
147,342
Loudr/pale
Loudr_pale/pale/arguments/base.py
pale.arguments.base.BaseArgument
class BaseArgument(BaseField): """The base class for Pale Arguments. Arguments in this context are values passed in to Pale Endpoints from the HTTP layer. These Argument objects are expected to validate parameters received from the HTTP layer before they're propagated to the endpoint handler that you define in your API. The `validate` method in subclasses should return the value if it is valid (including returning None if None is a valid value), or raise an ArgumentError if the argument is invalid. The ArgumentError will generate an HTTP 422 Unprocessable Entity response, and propagate the message of the exception to the caller. """ allowed_types = (object,) def __init__(self, short_doc, default=None, required=False, **kwargs): """Initialize an argument. This method is usually called from the Endpoint definition, and the created object is typically assigned to a key in the endpoint's `arguments` dictionary. """ self.description = short_doc self.default = default self.required = required for k, v in kwargs.iteritems(): setattr(self, k, v) def validate(self, item, item_name): """Validate the passed in item. The `item_name` is passed in so that we can generate a human-readable and user friendly error message, but this is architecturally a bit cumbersome right now, so we may want to change it in the future. Subclasses of BaseArgument should implement their own validation function. """ raise ArgumentError(item_name, ("ERROR! Your endpoint is missing a parser for your argument. " "The argument validator bubbled all the way up to the base " "argument, which is definitely not what you want!")) def _validate_type(self, item, name): """Validate the item against `allowed_types`.""" if item is None: # don't validate None items, since they'll be caught by the portion # of the validator responsible for handling `required`ness return if not isinstance(item, self.allowed_types): item_class_name = item.__class__.__name__ raise ArgumentError(name, "Expected one of %s, but got `%s`" % ( self.allowed_types, item_class_name)) def _validate_required(self, item, name): """Validate that the item is present if it's required.""" if self.required is True and item is None: raise ArgumentError(name, "This argument is required.") def doc_dict(self): """Returns the documentation dictionary for this argument.""" doc = { 'type': self.__class__.__name__, 'description': self.description, 'default': self.default, 'required': self.required } if hasattr(self, 'details'): doc['detailed_description'] = self.details return doc
class BaseArgument(BaseField): '''The base class for Pale Arguments. Arguments in this context are values passed in to Pale Endpoints from the HTTP layer. These Argument objects are expected to validate parameters received from the HTTP layer before they're propagated to the endpoint handler that you define in your API. The `validate` method in subclasses should return the value if it is valid (including returning None if None is a valid value), or raise an ArgumentError if the argument is invalid. The ArgumentError will generate an HTTP 422 Unprocessable Entity response, and propagate the message of the exception to the caller. ''' def __init__(self, short_doc, default=None, required=False, **kwargs): '''Initialize an argument. This method is usually called from the Endpoint definition, and the created object is typically assigned to a key in the endpoint's `arguments` dictionary. ''' pass def validate(self, item, item_name): '''Validate the passed in item. The `item_name` is passed in so that we can generate a human-readable and user friendly error message, but this is architecturally a bit cumbersome right now, so we may want to change it in the future. Subclasses of BaseArgument should implement their own validation function. ''' pass def _validate_type(self, item, name): '''Validate the item against `allowed_types`.''' pass def _validate_required(self, item, name): '''Validate that the item is present if it's required.''' pass def doc_dict(self): '''Returns the documentation dictionary for this argument.''' pass
6
6
11
1
7
3
2
0.74
1
1
1
6
5
3
5
9
82
16
38
17
28
28
24
13
18
3
2
1
10
147,343
Loudr/pale
Loudr_pale/tests/example_app/api/endpoints.py
tests.example_app.api.endpoints.ParseTimeEndpoint
class ParseTimeEndpoint(Endpoint): """Parses some passed in parameters to generate a corresponding DateTimeResource. """ # mock the permissions: # @requires_permission("licensing") _http_method = "POST" _uri = "/time/parse" _route_name = "parse_time" _default_cache = 'max-age=3' _returns = DateTimeResource( "The DateTimeResource corresponding to the timing " "information sent in by the requester.") year = IntegerArgument("Set the year of the returned datetime", default=2015) month = IntegerArgument("Set the month of the returned datetime", required=True, min_value=1, max_value=12) day = IntegerArgument("Set the day of the returned datetime") name = StringArgument("The name for your datetime", details="You can give your time a name, which will be " "returned back to you in the response, as the field `name`. " "If you omit this input parameter, your response won't " "include a `name`.", min_length=3, max_length=20) include_time = BooleanArgument("Include the time in the output?", details="If present, the response will include JSON fields " "for the current time, including `hours`, `minutes`, and " "`seconds`.", default=False) def _handle(self, context): now = DateTimeModel(datetime.datetime.utcnow()) now.update_date( # year has a default, so it will always be present context.args['year'], # month is required, so it will always be present context.args['month'], context.args.get('day', None)) now.set_include_time(context.args['include_time']) now.name = context.args.get('name', None) return {'time': now}
class ParseTimeEndpoint(Endpoint): '''Parses some passed in parameters to generate a corresponding DateTimeResource. ''' def _handle(self, context): pass
2
1
14
3
9
2
1
0.19
1
2
1
0
1
0
1
1
59
16
36
13
34
7
17
13
15
1
1
0
1
147,344
LucidtechAI/las-sdk-python
LucidtechAI_las-sdk-python/las/client.py
las.client.FileFormatException
class FileFormatException(ClientException): """A FileFormatException is raised if the file format is not supported by the api.""" pass
class FileFormatException(ClientException): '''A FileFormatException is raised if the file format is not supported by the api.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
10
3
0
2
1
1
1
2
1
1
0
4
0
0
147,345
LucidtechAI/las-sdk-python
LucidtechAI_las-sdk-python/las/client.py
las.client.BadRequest
class BadRequest(ClientException): """BadRequest is raised if you have made a request that is disqualified based on the input""" pass
class BadRequest(ClientException): '''BadRequest is raised if you have made a request that is disqualified based on the input''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
10
3
0
2
1
1
1
2
1
1
0
4
0
0
147,346
LucidtechAI/las-sdk-python
LucidtechAI_las-sdk-python/las/client.py
las.client.InvalidCredentialsException
class InvalidCredentialsException(ClientException): """An InvalidCredentialsException is raised if api key, access key id or secret access key is invalid.""" pass
class InvalidCredentialsException(ClientException): '''An InvalidCredentialsException is raised if api key, access key id or secret access key is invalid.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
10
3
0
2
1
1
1
2
1
1
0
4
0
0
147,347
LucidtechAI/las-sdk-python
LucidtechAI_las-sdk-python/las/client.py
las.client.EmptyRequestError
class EmptyRequestError(ValueError): """An EmptyRequestError is raised if the request body is empty when expected not to be empty.""" pass
class EmptyRequestError(ValueError): '''An EmptyRequestError is raised if the request body is empty when expected not to be empty.''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
11
3
0
2
1
1
1
2
1
1
0
4
0
0