code
string | signature
string | docstring
string | loss_without_docstring
float64 | loss_with_docstring
float64 | factor
float64 |
|---|---|---|---|---|---|
api = self._get_api(billing.DefaultApi)
month = self._month_converter(month)
response = api.get_billing_report_firmware_updates(month=month)
download_url = response.url
file_path = self._filepath_converter(file_path, response.filename)
if file_path:
urllib.request.urlretrieve(download_url, file_path)
return response
|
def get_report_firmware_updates(self, month=None, file_path=None)
|
Downloads a report of the firmware updates
:param str file_path: [optional] location to store output file
:param month: [default: utcnow] month as datetime instance, or string in YYYY-MM format
:type month: str or datetime
:return: The report structure
:rtype: dict
| 4.059108
| 4.542551
| 0.893575
|
return self.delete_long_poll_channel_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.delete_long_poll_channel_with_http_info(**kwargs) # noqa: E501
return data
|
def delete_long_poll_channel(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Delete notification Long Poll channel # noqa: E501
To delete a notification Long Poll channel. This is required to change the channel from Long Poll to a callback. You should not make a GET `/v2/notification/pull` call for 2 minutes after channel was deleted, because it can implicitly recreate the pull channel. You can also have some random responses with payload or 410 GONE with \"CHANNEL_DELETED\" as a payload or 200/204 until the old channel is purged. **Example usage:** curl -X DELETE https://api.us-east-1.mbedcloud.com/v2/notification/pull -H 'authorization: Bearer {api-key}' # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.delete_long_poll_channel(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:return: None
If the method is called asynchronously,
returns the request thread.
| 1.563756
| 2.036004
| 0.768052
|
return self.deregister_webhook_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.deregister_webhook_with_http_info(**kwargs) # noqa: E501
return data
|
def deregister_webhook(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Delete callback URL # noqa: E501
Deletes the callback URL. **Example usage:** curl -X DELETE https://api.us-east-1.mbedcloud.com/v2/notification/callback -H 'authorization: Bearer {api-key}' # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.deregister_webhook(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:return: None
If the method is called asynchronously,
returns the request thread.
| 1.642195
| 2.286929
| 0.718078
|
return self.get_webhook_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_webhook_with_http_info(**kwargs) # noqa: E501
return data
|
def get_webhook(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Check callback URL # noqa: E501
Shows the current callback URL if it exists. **Example usage:** curl -X GET https://api.us-east-1.mbedcloud.com/v2/notification/callback -H 'authorization: Bearer {api-key}' # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_webhook(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:return: Webhook
If the method is called asynchronously,
returns the request thread.
| 1.645853
| 2.149196
| 0.7658
|
return self.long_poll_notifications_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.long_poll_notifications_with_http_info(**kwargs) # noqa: E501
return data
|
def long_poll_notifications(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get notifications using Long Poll # noqa: E501
In this case, notifications are delivered through HTTP long poll requests. The HTTP request is kept open until an event notification or a batch of event notifications are delivered to the client or the request times out (response code 204). In both cases, the client should open a new polling connection after the previous one closes. Only a single long polling connection per API key can be ongoing at any given time. You must have a persistent connection (Connection keep-alive header in the request) to avoid excess TLS handshakes. The pull channel is implicitly created by the first GET call to `/v2/notification/pull`. It is refreshed on each GET call. If the channel is not polled for a long time (10 minutes) - it expires and will be deleted. This means that no notifications will stay in the queue between polls. A channel can be also deleted explicitly by a DELETE call. **Note:** If you cannot have a public facing callback URL, for example when developing on your local machine, you can use long polling to check for new messages. However, **long polling is deprecated** and will likely be replaced in future. It is meant only for experimentation and not for commercial usage. The proper method to receive notifications is a **notification callback**. There can only be one notification channel per API key at a time in Device Management Connect. If a callback notification channel already exists, you need to delete it before creating a long poll notification channel, and vice-versa. **Example usage:** curl -X GET https://api.us-east-1.mbedcloud.com/v2/notification/pull -H 'authorization: Bearer {api-key}' # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.long_poll_notifications(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:return: NotificationMessage
If the method is called asynchronously,
returns the request thread.
| 1.601675
| 2.112209
| 0.758294
|
return self.register_webhook_with_http_info(webhook, **kwargs) # noqa: E501
else:
(data) = self.register_webhook_with_http_info(webhook, **kwargs) # noqa: E501
return data
|
def register_webhook(self, webhook, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Register a callback URL # noqa: E501
Register a URL to which the server should deliver notifications of the subscribed resource changes. To get notifications pushed, you also need to place the subscriptions. The maximum length of the URL, header keys and values, all combined, is 400 characters. Notifications are delivered as PUT messages to the HTTP server defined by the client with a subscription server message. The given URL should be accessible and respond to the PUT request with response code of 200 or 204. Device Management Connect tests the callback URL with an empty payload when the URL is registered. For more information on callback notification, see [NotificationMessage](/docs/current/service-api-references/mbed-cloud-connect.html#models). **Optional headers in a callback message:** You can set optional headers to a callback in a **Webhook** object. Device Management Connect will include the header and key pairs to the notification messages send them to callback URL. As the callback URL's are API key specific also the headers are. One possible use for the additional headers is to check the origin of a PUT request and also distinguish the application (API key) to which the notification belongs to. **Note**: Only one callback URL per an API key can be active. If you register a new URL while another one is already active, it replaces the active one. There can be only one notification channel at a time. If the Long Poll notification is already present, you need to delete it before setting the callback URL. **Expiration of a callback URL:** A callback can expire when Device Management cannot deliver a notification due to a connection timeout or an error response (4xx or 5xx). After each delivery failure, Device Management sets an exponential back off time and makes a retry attempt after that. The first retry delay is 1 second, then 2s, 4s, 8s, ..., 2min, 2min. The maximum retry delay is 2 minutes. The callback URL will be removed if all retries fail withing 24 hours. More about [notification sending logic](/docs/current/integrate-web-app/event-notification.html#notification-sending-logic). **Supported callback URL protocols:** Currently, only HTTP and HTTPS protocols are supported. **HTTPS callback URLs:** When delivering a notification to an HTTPS based callback URL, Device Management Connect will present a valid client certificate to identify itself. The certificate is signed by a trusted certificate authorithy (GlobalSign) with a Common Name (CN) set to notifications.mbedcloud.com. **Example usage:** This example command shows how to set your callback URL and API key. It also sets an optional header authorization. When Device Management Connect calls your callback URL, the call contains the authorization header with the defined value. curl -X PUT \\ https://api.us-east-1.mbedcloud.com/v2/notification/callback \\ -H 'authorization: Bearer {api-key}' \\ -H 'content-type: application/json' \\ -d '{ \"url\": \"{callback-url}\", \"headers\": {\"authorization\" : \"f4b93d6e-4652-4874-82e4-41a3ced0cd56\"} }' # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.register_webhook(webhook, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param Webhook webhook: A json object that contains the optional headers and the URL to which the notifications need to be sent. (required)
:return: None
If the method is called asynchronously,
returns the request thread.
| 1.595317
| 2.456561
| 0.649411
|
if event_type is not None and len(event_type) > 100:
raise ValueError("Invalid value for `event_type`, length must be less than or equal to `100`")
self._event_type = event_type
|
def event_type(self, event_type)
|
Sets the event_type of this DeviceEventData.
Event code
:param event_type: The event_type of this DeviceEventData.
:type: str
| 2.048907
| 2.110261
| 0.970926
|
return self.add_my_api_key_to_groups_with_http_info(body, **kwargs) # noqa: E501
else:
(data) = self.add_my_api_key_to_groups_with_http_info(body, **kwargs) # noqa: E501
return data
|
def add_my_api_key_to_groups(self, body, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Add API key to a list of groups. # noqa: E501
An endpoint for adding API key to groups. **Example usage:** `curl -X POST https://api.us-east-1.mbedcloud.com/v3/api-keys/me/groups -d '[0162056a9a1586f30242590700000000,0117056a9a1586f30242590700000000]' -H 'content-type: application/json' -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.add_my_api_key_to_groups(body, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param list[str] body: A list of IDs of the groups to be updated. (required)
:return: UpdatedResponse
If the method is called asynchronously,
returns the request thread.
| 1.502025
| 2.031981
| 0.739192
|
return self.create_api_key_with_http_info(body, **kwargs) # noqa: E501
else:
(data) = self.create_api_key_with_http_info(body, **kwargs) # noqa: E501
return data
|
def create_api_key(self, body, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Create a new API key. # noqa: E501
An endpoint for creating a new API key. **Example usage:** `curl -X POST https://api.us-east-1.mbedcloud.com/v3/api-keys -d '{\"name\": \"MyKey1\"}' -H 'content-type: application/json' -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.create_api_key(body, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param ApiKeyInfoReq body: The details of the API key to be created. (required)
:return: ApiKeyInfoResp
If the method is called asynchronously,
returns the request thread.
| 1.590942
| 2.17863
| 0.730249
|
return self.delete_api_key_with_http_info(api_key, **kwargs) # noqa: E501
else:
(data) = self.delete_api_key_with_http_info(api_key, **kwargs) # noqa: E501
return data
|
def delete_api_key(self, api_key, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Delete API key. # noqa: E501
An endpoint for deleting the API key. **Example usage:** `curl -X DELETE https://api.us-east-1.mbedcloud.com/v3/api-keys/{apikey-id} -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.delete_api_key(api_key, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str api_key: The ID of the API key to be deleted. (required)
:return: None
If the method is called asynchronously,
returns the request thread.
| 1.554945
| 2.042842
| 0.761167
|
return self.delete_certificate_with_http_info(cert_id, **kwargs) # noqa: E501
else:
(data) = self.delete_certificate_with_http_info(cert_id, **kwargs) # noqa: E501
return data
|
def delete_certificate(self, cert_id, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Delete a trusted certificate by ID. # noqa: E501
An endpoint for deleting a trusted certificate. **Example usage:** `curl -X DELETE https://api.us-east-1.mbedcloud.com/v3/trusted-certificates/{cert-id} -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.delete_certificate(cert_id, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str cert_id: The ID of the trusted certificate to be deleted. (required)
:return: None
If the method is called asynchronously,
returns the request thread.
| 1.575787
| 2.123948
| 0.741914
|
return self.get_all_api_keys_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_all_api_keys_with_http_info(**kwargs) # noqa: E501
return data
|
def get_all_api_keys(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get all API keys # noqa: E501
An endpoint for retrieving API keys in an array, optionally filtered by the owner. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/api-keys -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_all_api_keys(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param int limit: The number of results to return (2-1000), default is 50.
:param str after: The entity ID to fetch after the given one.
:param str order: The order of the records based on creation time, ASC or DESC; by default ASC
:param str include: Comma separated additional data to return. Currently supported: total_count
:param str key__eq: API key filter.
:param str owner__eq: Owner name filter.
:return: ApiKeyInfoRespList
If the method is called asynchronously,
returns the request thread.
| 1.600523
| 2.160268
| 0.740891
|
return self.get_all_certificates_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_all_certificates_with_http_info(**kwargs) # noqa: E501
return data
|
def get_all_certificates(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get all trusted certificates. # noqa: E501
An endpoint for retrieving trusted certificates in an array. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/trusted-certificates -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_all_certificates(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param int limit: The number of results to return (2-1000), default is 50.
:param str after: The entity ID to fetch after the given one.
:param str order: The order of the records based on creation time, ASC or DESC; by default ASC
:param str include: Comma separated additional data to return. Currently supported: total_count
:param str name__eq: Filter for certificate name
:param str service__eq: Service filter, either lwm2m or bootstrap
:param int expire__eq: Expire filter in days
:param int device_execution_mode__eq: Device execution mode, as 1 for developer certificates or as another natural integer value
:param int device_execution_mode__neq: Device execution mode not equals filter
:param str owner__eq: Owner name filter
:param bool enrollment_mode__eq: Enrollment mode filter
:param str issuer__like: Issuer filter. Finds all matches where the filter value is a case insensitive substring of the result. Example: issuer__like=cn=iss matches CN=issuer.
:param str subject__like: Subject filter. Finds all matches where the filter value is a case insensitive substring of the result. Example: subject__like=cn=su matches CN=subject.
:return: TrustedCertificateRespList
If the method is called asynchronously,
returns the request thread.
| 1.616866
| 2.133555
| 0.757827
|
return self.get_all_groups_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_all_groups_with_http_info(**kwargs) # noqa: E501
return data
|
def get_all_groups(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get all group information. # noqa: E501
An endpoint for retrieving all group information. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/policy-groups -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_all_groups(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param int limit: The number of results to return (2-1000), default is 50.
:param str after: The entity ID to fetch after the given one.
:param str order: The order of the records based on creation time, ASC or DESC; by default ASC
:param str include: Comma separated additional data to return. Currently supported: total_count
:param str name__eq: Filter for group name
:return: GroupSummaryList
If the method is called asynchronously,
returns the request thread.
| 1.595873
| 2.21793
| 0.719533
|
return self.get_api_key_with_http_info(api_key, **kwargs) # noqa: E501
else:
(data) = self.get_api_key_with_http_info(api_key, **kwargs) # noqa: E501
return data
|
def get_api_key(self, api_key, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get API key details. # noqa: E501
An endpoint for retrieving API key details. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/api-keys/{apikey-id} -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_api_key(api_key, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str api_key: The ID of the API key to be retrieved. (required)
:return: ApiKeyInfoResp
If the method is called asynchronously,
returns the request thread.
| 1.531786
| 2.087541
| 0.733775
|
return self.get_api_keys_of_group_with_http_info(group_id, **kwargs) # noqa: E501
else:
(data) = self.get_api_keys_of_group_with_http_info(group_id, **kwargs) # noqa: E501
return data
|
def get_api_keys_of_group(self, group_id, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get the API keys of a group. # noqa: E501
An endpoint for listing the API keys of the group with details. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/policy-groups/{group-id}/api-keys -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_api_keys_of_group(group_id, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str group_id: The ID of the group whose API keys are retrieved. (required)
:param int limit: The number of results to return (2-1000), default is 50.
:param str after: The entity ID to fetch after the given one.
:param str order: The order of the records based on creation time, ASC or DESC; by default ASC
:param str include: Comma separated additional data to return. Currently supported: total_count
:return: ApiKeyInfoRespList
If the method is called asynchronously,
returns the request thread.
| 1.488081
| 1.929044
| 0.771408
|
return self.get_certificate_with_http_info(cert_id, **kwargs) # noqa: E501
else:
(data) = self.get_certificate_with_http_info(cert_id, **kwargs) # noqa: E501
return data
|
def get_certificate(self, cert_id, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get trusted certificate by ID. # noqa: E501
An endpoint for retrieving a trusted certificate by ID. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/trusted-certificates/{cert-id} -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_certificate(cert_id, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str cert_id: The ID of the trusted certificate to be retrieved. (required)
:return: TrustedCertificateResp
If the method is called asynchronously,
returns the request thread.
| 1.570433
| 2.132296
| 0.736498
|
return self.get_group_summary_with_http_info(group_id, **kwargs) # noqa: E501
else:
(data) = self.get_group_summary_with_http_info(group_id, **kwargs) # noqa: E501
return data
|
def get_group_summary(self, group_id, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get group information. # noqa: E501
An endpoint for getting general information about the group. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/policy-groups/{group-id} -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_group_summary(group_id, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str group_id: The ID of the group to be retrieved. (required)
:return: GroupSummary
If the method is called asynchronously,
returns the request thread.
| 1.529337
| 2.009548
| 0.761036
|
return self.get_groups_of_my_api_key_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_groups_of_my_api_key_with_http_info(**kwargs) # noqa: E501
return data
|
def get_groups_of_my_api_key(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get groups of the API key. # noqa: E501
An endpoint for retrieving groups of the API key. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/api-keys/me/groups -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_groups_of_my_api_key(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param int limit: The number of results to return (2-1000), default is 50.
:param str after: The entity ID to fetch after the given one.
:param str order: The order of the records based on creation time, ASC or DESC; by default ASC
:param str include: Comma separated additional data to return. Currently supported: total_count
:return: GroupSummaryList
If the method is called asynchronously,
returns the request thread.
| 1.519257
| 1.942107
| 0.782272
|
return self.get_my_account_info_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_my_account_info_with_http_info(**kwargs) # noqa: E501
return data
|
def get_my_account_info(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get account info. # noqa: E501
Returns detailed information about the account. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/accounts/me?include=policies -H 'Authorization: Bearer API_KEY'`. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_my_account_info(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str include: Comma separated additional data to return. Currently supported: limits, policies, sub_accounts.
:param str properties: Property name to be returned from account specific properties.
:return: AccountInfo
If the method is called asynchronously,
returns the request thread.
| 1.604022
| 2.066682
| 0.776134
|
return self.get_my_api_key_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_my_api_key_with_http_info(**kwargs) # noqa: E501
return data
|
def get_my_api_key(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get API key details. # noqa: E501
An endpoint for retrieving API key details. **Example usage:** `curl https://api.us-east-1.mbedcloud.com/v3/api-keys/me -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_my_api_key(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:return: ApiKeyInfoResp
If the method is called asynchronously,
returns the request thread.
| 1.577774
| 2.093881
| 0.753517
|
return self.remove_api_keys_from_group_with_http_info(group_id, body, **kwargs) # noqa: E501
else:
(data) = self.remove_api_keys_from_group_with_http_info(group_id, body, **kwargs) # noqa: E501
return data
|
def remove_api_keys_from_group(self, group_id, body, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Remove API keys from a group. # noqa: E501
An endpoint for removing API keys from groups. **Example usage:** `curl -X DELETE https://api.us-east-1.mbedcloud.com/v3/policy-groups/{group-id}/api-keys -d '[0162056a9a1586f30242590700000000,0117056a9a1586f30242590700000000]' -H 'content-type: application/json' -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.remove_api_keys_from_group(group_id, body, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str group_id: The ID of the group whose API keys are removed. (required)
:param SubjectList body: A list of API keys to be removed from the group. (required)
:return: UpdatedResponse
If the method is called asynchronously,
returns the request thread.
| 1.490899
| 2.02743
| 0.735364
|
return self.remove_my_api_key_from_groups_with_http_info(body, **kwargs) # noqa: E501
else:
(data) = self.remove_my_api_key_from_groups_with_http_info(body, **kwargs) # noqa: E501
return data
|
def remove_my_api_key_from_groups(self, body, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Remove API key from groups. # noqa: E501
An endpoint for removing API key from groups. **Example usage:** `curl -X DELETE https://api.us-east-1.mbedcloud.com/v3/api-keys/me/groups -d '[0162056a9a1586f30242590700000000,0117056a9a1586f30242590700000000]' -H 'content-type: application/json' -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.remove_my_api_key_from_groups(body, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param list[str] body: A list of IDs of the groups to be updated. (required)
:return: UpdatedResponse
If the method is called asynchronously,
returns the request thread.
| 1.510764
| 2.019935
| 0.747927
|
return self.update_api_key_with_http_info(api_key, body, **kwargs) # noqa: E501
else:
(data) = self.update_api_key_with_http_info(api_key, body, **kwargs) # noqa: E501
return data
|
def update_api_key(self, api_key, body, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Update API key details. # noqa: E501
An endpoint for updating API key details. **Example usage:** `curl -X PUT https://api.us-east-1.mbedcloud.com/v3/api-keys/{apikey-id} -d '{\"name\": \"TestApiKey25\"}' -H 'content-type: application/json' -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.update_api_key(api_key, body, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str api_key: The ID of the API key to be updated. (required)
:param ApiKeyUpdateReq body: New API key attributes to be stored. (required)
:return: ApiKeyInfoResp
If the method is called asynchronously,
returns the request thread.
| 1.530517
| 2.09669
| 0.729968
|
return self.update_certificate_with_http_info(cert_id, body, **kwargs) # noqa: E501
else:
(data) = self.update_certificate_with_http_info(cert_id, body, **kwargs) # noqa: E501
return data
|
def update_certificate(self, cert_id, body, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Update trusted certificate. # noqa: E501
An endpoint for updating existing trusted certificates. **Example usage:** `curl -X PUT https://api.us-east-1.mbedcloud.com/v3/trusted-certificates/{cert-id} -d {\"description\": \"very important cert\"} -H 'content-type: application/json' -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.update_certificate(cert_id, body, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str cert_id: The ID of the trusted certificate to be updated. (required)
:param TrustedCertificateUpdateReq body: A trusted certificate object with attributes. (required)
:return: TrustedCertificateResp
If the method is called asynchronously,
returns the request thread.
| 1.573539
| 2.087783
| 0.753689
|
return self.update_my_api_key_with_http_info(body, **kwargs) # noqa: E501
else:
(data) = self.update_my_api_key_with_http_info(body, **kwargs) # noqa: E501
return data
|
def update_my_api_key(self, body, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Update API key details. # noqa: E501
An endpoint for updating API key details. **Example usage:** `curl -X PUT https://api.us-east-1.mbedcloud.com/v3/api-keys/me -d '{\"name\": \"TestApiKey25\"}' -H 'content-type: application/json' -H 'Authorization: Bearer API_KEY'` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.update_my_api_key(body, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param ApiKeyUpdateReq body: New API key attributes to be stored. (required)
:return: ApiKeyInfoResp
If the method is called asynchronously,
returns the request thread.
| 1.574753
| 2.131719
| 0.738724
|
if pattern.endswith('*'):
return item.startswith(pattern[:-1])
else:
return item == pattern
|
def _pattern_match(self, item, pattern)
|
Determine whether the item supplied is matched by the pattern.
| 3.512393
| 2.863848
| 1.226459
|
super(ResourceValues, self).start()
self._api.ensure_notifications_thread()
self._presubs.add(self._sdk_presub_params)
if self._immediacy == FirstValue.on_value_update:
self._subscribe_all_matching()
|
def start(self)
|
Start the channel
| 24.125647
| 23.851818
| 1.01148
|
self._presubs.remove(self._sdk_presub_params)
if self._immediacy == FirstValue.on_value_update:
self._unsubscribe_all_matching()
super(ResourceValues, self).stop()
|
def stop(self)
|
Stop the channel
| 28.994335
| 28.276409
| 1.02539
|
self.current = [
{k: v for k, v in p.to_dict().items() if v is not None}
for p in self.api.list_presubscriptions()
]
|
def load_from_cloud(self)
|
Sync - read
| 6.195311
| 5.90081
| 1.049909
|
with _presub_lock:
self.load_from_cloud()
for entry in utils.ensure_listable(items):
# add new entries, but only if they're unique
if entry not in self.current:
self.current.append(entry)
self.save_to_cloud()
|
def add(self, items)
|
Add entry to global presubs list
| 7.389173
| 5.958107
| 1.240188
|
with _presub_lock:
self.load_from_cloud()
for entry in utils.ensure_listable(items):
# remove all matching entries
while entry in self.current:
self.current.remove(entry)
self.save_to_cloud()
|
def remove(self, items)
|
Remove entry from global presubs list
| 8.193973
| 6.449153
| 1.27055
|
if not isinstance(time, datetime.datetime):
raise CloudValueError("%s should be of type datetime" % (name,))
clip = 6 - precision
timestring = time.isoformat()
if clip:
timestring = timestring[:-clip]
return timestring + "Z"
|
def force_utc(time, name='field', precision=6)
|
Appending 'Z' to isoformatted time - explicit timezone is required for most APIs
| 4.984323
| 4.27995
| 1.164575
|
return self.get_billing_report_with_http_info(month, **kwargs) # noqa: E501
else:
(data) = self.get_billing_report_with_http_info(month, **kwargs) # noqa: E501
return data
|
def get_billing_report(self, month, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get billing report. # noqa: E501
Fetch the billing report generated for the currently authenticated commercial non-subtenant account. Billing reports for subtenant accounts are included in their aggregator's billing report response. **Example usage:** curl -X GET https://api.us-east-1.mbedcloud.com/v3/billing-report?month=2018-07 -H 'authorization: Bearer {api-key}' # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_billing_report(month, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str month: Queried year and month of billing report. (required)
:return: ReportResponse
If the method is called asynchronously,
returns the request thread.
| 1.558218
| 2.085144
| 0.747295
|
return self.get_billing_report_active_devices_with_http_info(month, **kwargs) # noqa: E501
else:
(data) = self.get_billing_report_active_devices_with_http_info(month, **kwargs) # noqa: E501
return data
|
def get_billing_report_active_devices(self, month, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get raw billing data of the active devices for the month. # noqa: E501
Fetch the raw billing data of the active devices for the currently authenticated commercial non-subtenant account. This is supplementary data for the billing report. The raw billing data of the active devices for subtenant accounts are included in their aggregator's raw billing data of the active devices. The endpoint returns the URL to download the gzipped CSV file. The first line is the header providing information on the active devices. For example, the ID of an active device. **Example usage:** curl -X GET https://api.us-east-1.mbedcloud.com/v3/billing-report-active-devices?month=2018-07 -H 'authorization: Bearer {api-key}' # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_billing_report_active_devices(month, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str month: Queried year and month of billing report. (required)
:return: BillingReportRawDataResponse
If the method is called asynchronously,
returns the request thread.
| 1.520504
| 2.039585
| 0.745497
|
return self.get_billing_report_firmware_updates_with_http_info(month, **kwargs) # noqa: E501
else:
(data) = self.get_billing_report_firmware_updates_with_http_info(month, **kwargs) # noqa: E501
return data
|
def get_billing_report_firmware_updates(self, month, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get raw billing data of the firmware updates for the month. # noqa: E501
Fetch raw billing data of the firmware updates for the currently authenticated commercial non-subtenant account. This is supplementary data for the billing report. The raw billing data of the firmware updates for subtenant accounts are included in their aggregator's raw billing data of the firmware updates. The endpoint returns the URL to download the gzipped CSV file. The first line is the header providing information on the firmware updates. For example, the ID of an firmware update. **Example usage:** curl -X GET https://api.us-east-1.mbedcloud.com/v3/billing-report-firmware-updates?month=2018-07 -H 'authorization: Bearer {api-key}' # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_billing_report_firmware_updates(month, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str month: Queried year and month of billing report. (required)
:return: BillingReportRawDataResponse
If the method is called asynchronously,
returns the request thread.
| 1.534932
| 2.036207
| 0.753819
|
return self.get_service_package_quota_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_service_package_quota_with_http_info(**kwargs) # noqa: E501
return data
|
def get_service_package_quota(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Service package quota. # noqa: E501
Get the available firmware update quota for the currently authenticated commercial account. **Example usage:** curl -X GET https://api.us-east-1.mbedcloud.com/v3/service-packages-quota -H 'authorization: Bearer {api-key}' # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_service_package_quota(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:return: ServicePackageQuota
If the method is called asynchronously,
returns the request thread.
| 1.599957
| 1.915678
| 0.835191
|
return self.get_service_package_quota_history_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_service_package_quota_history_with_http_info(**kwargs) # noqa: E501
return data
|
def get_service_package_quota_history(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Service package quota history. # noqa: E501
Get your quota usage history. This API is available for commercial accounts. Aggregator accounts can see own and subtenant quota usage data. History data is ordered in ascending order based on the added timestamp. **Example usage:** curl -X GET https://api.us-east-1.mbedcloud.com/v3/service-packages-quota-history -H 'authorization: Bearer {api-key}' # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_service_package_quota_history(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param int limit: Maximum amount of quota history entries contained in one paged response.
:param str after: To fetch after which quota history ID. The results will contain entries after specified entry.
:return: ServicePackageQuotaHistoryResponse
If the method is called asynchronously,
returns the request thread.
| 1.582922
| 1.915553
| 0.826353
|
return self.get_service_packages_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_service_packages_with_http_info(**kwargs) # noqa: E501
return data
|
def get_service_packages(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get all service packages. # noqa: E501
Get information of all service packages for the currently authenticated commercial account. The response is returned in descending order by service package created timestamp, listing first the pending service package, then the active service package and finally the previous service packages. **Example usage:** curl -X GET https://api.us-east-1.mbedcloud.com/v3/service-packages -H 'authorization: Bearer {api-key}' # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_service_packages(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:return: ServicePackagesResponse
If the method is called asynchronously,
returns the request thread.
| 1.616347
| 2.119704
| 0.762534
|
def wrap(fn):
@functools.wraps(fn)
def wrapped_f(*args, **kwargs):
try:
return fn(*args, **kwargs)
except exceptions:
t, value, traceback = sys.exc_info()
# If any resource does not exist, return None instead of raising
if str(value.status) == '404':
return None
e = CloudApiException(str(value), value.reason, value.status)
raise_(CloudApiException, e, traceback)
return wrapped_f
return wrap
|
def catch_exceptions(*exceptions)
|
Catch all exceptions provided as arguments, and raise CloudApiException instead.
| 3.261772
| 2.82706
| 1.153768
|
if endpoint_name is not None and len(endpoint_name) > 64:
raise ValueError("Invalid value for `endpoint_name`, length must be less than or equal to `64`")
self._endpoint_name = endpoint_name
|
def endpoint_name(self, endpoint_name)
|
Sets the endpoint_name of this DeviceDataPostRequest.
The endpoint name given to the device.
:param endpoint_name: The endpoint_name of this DeviceDataPostRequest.
:type: str
| 1.853514
| 2.239996
| 0.827463
|
if firmware_checksum is not None and len(firmware_checksum) > 64:
raise ValueError("Invalid value for `firmware_checksum`, length must be less than or equal to `64`")
self._firmware_checksum = firmware_checksum
|
def firmware_checksum(self, firmware_checksum)
|
Sets the firmware_checksum of this DeviceDataPostRequest.
The SHA256 checksum of the current firmware image.
:param firmware_checksum: The firmware_checksum of this DeviceDataPostRequest.
:type: str
| 2.02801
| 2.380867
| 0.851795
|
if serial_number is not None and len(serial_number) > 64:
raise ValueError("Invalid value for `serial_number`, length must be less than or equal to `64`")
self._serial_number = serial_number
|
def serial_number(self, serial_number)
|
Sets the serial_number of this DeviceDataPostRequest.
The serial number of the device.
:param serial_number: The serial_number of this DeviceDataPostRequest.
:type: str
| 1.961559
| 2.233265
| 0.878337
|
if vendor_id is not None and len(vendor_id) > 255:
raise ValueError("Invalid value for `vendor_id`, length must be less than or equal to `255`")
self._vendor_id = vendor_id
|
def vendor_id(self, vendor_id)
|
Sets the vendor_id of this DeviceDataPostRequest.
The device vendor ID.
:param vendor_id: The vendor_id of this DeviceDataPostRequest.
:type: str
| 1.819072
| 2.21406
| 0.8216
|
source_files = (
('integration', r'results/results.xml'),
('unittests', r'results/unittests.xml'),
('coverage', r'results/coverage.xml')
)
parsed = {k: ElementTree.parse(v).getroot().attrib for k, v in source_files}
with open(r'results/summary.json', 'w') as fh:
json.dump(parsed, fh)
|
def main()
|
Collects results from CI run
| 3.597386
| 3.361277
| 1.070244
|
kwargs = self._verify_sort_options(kwargs)
kwargs = self._verify_filters(kwargs, Device, True)
api = self._get_api(device_directory.DefaultApi)
return PaginatedResponse(api.device_list, lwrap_type=Device, **kwargs)
|
def list_devices(self, **kwargs)
|
List devices in the device catalog.
Example usage, listing all registered devices in the catalog:
.. code-block:: python
filters = { 'state': {'$eq': 'registered' } }
devices = api.list_devices(order='asc', filters=filters)
for idx, d in enumerate(devices):
print(idx, d.id)
:param int limit: The number of devices to retrieve.
:param str order: The ordering direction, ascending (asc) or
descending (desc)
:param str after: Get devices after/starting at given `device_id`
:param filters: Dictionary of filters to apply.
:returns: a list of :py:class:`Device` objects registered in the catalog.
:rtype: PaginatedResponse
| 8.261547
| 8.775257
| 0.941459
|
api = self._get_api(device_directory.DefaultApi)
return Device(api.device_retrieve(device_id))
|
def get_device(self, device_id)
|
Get device details from catalog.
:param str device_id: the ID of the device to retrieve (Required)
:returns: device object matching the `device_id`.
:rtype: Device
| 11.871156
| 13.070073
| 0.90827
|
api = self._get_api(device_directory.DefaultApi)
device = Device._create_request_map(kwargs)
body = DeviceDataPostRequest(**device)
return Device(api.device_update(device_id, body))
|
def update_device(self, device_id, **kwargs)
|
Update existing device in catalog.
.. code-block:: python
existing_device = api.get_device(...)
updated_device = api.update_device(
existing_device.id,
certificate_fingerprint = "something new"
)
:param str device_id: The ID of the device to update (Required)
:param obj custom_attributes: Up to 5 custom JSON attributes
:param str description: The description of the device
:param str name: The name of the device
:param str alias: The alias of the device
:param str device_type: The endpoint type of the device - e.g. if the device is a gateway
:param str host_gateway: The endpoint_name of the host gateway, if appropriate
:param str certificate_fingerprint: Fingerprint of the device certificate
:param str certificate_issuer_id: ID of the issuer of the certificate
:returns: the updated device object
:rtype: Device
| 10.764474
| 14.337047
| 0.750815
|
api = self._get_api(device_directory.DefaultApi)
device = Device._create_request_map(kwargs)
device = DeviceData(**device)
return Device(api.device_create(device))
|
def add_device(self, **kwargs)
|
Add a new device to catalog.
.. code-block:: python
device = {
"mechanism": "connector",
"certificate_fingerprint": "<certificate>",
"name": "New device name",
"certificate_issuer_id": "<id>"
}
resp = api.add_device(**device)
print(resp.created_at)
:param str certificate_fingerprint: Fingerprint of the device certificate
:param str certificate_issuer_id: ID of the issuer of the certificate
:param str name: The name of the device
:param str account_id: The owning Identity and Access Managment (IAM) account ID
:param obj custom_attributes: Up to 5 custom JSON attributes
:param str description: The description of the device
:param str device_class: Class of the device
:param str id: The ID of the device
:param str manifest_url: URL for the current device manifest
:param str mechanism: The ID of the channel used to communicate with the device
:param str mechanism_url: The address of the connector to use
:param str serial_number: The serial number of the device
:param str state: The current state of the device
:param int trust_class: The device trust class
:param str vendor_id: The device vendor ID
:param str alias: The alias of the device
:parama str device_type: The endpoint type of the device - e.g. if the device is a gateway
:param str host_gateway: The endpoint_name of the host gateway, if appropriate
:param datetime bootstrap_certificate_expiration:
:param datetime connector_certificate_expiration: Expiration date of the certificate
used to connect to connector server
:param int device_execution_mode: The device class
:param str firmware_checksum: The SHA256 checksum of the current firmware image
:param datetime manifest_timestamp: The timestamp of the current manifest version
:return: the newly created device object.
:rtype: Device
| 11.677409
| 14.147957
| 0.825378
|
api = self._get_api(device_directory.DefaultApi)
return api.device_destroy(id=device_id)
|
def delete_device(self, device_id)
|
Delete device from catalog.
:param str device_id: ID of device in catalog to delete (Required)
:return: void
| 10.814703
| 13.387383
| 0.807828
|
kwargs = self._verify_sort_options(kwargs)
kwargs = self._verify_filters(kwargs, Query, True)
api = self._get_api(device_directory.DefaultApi)
return PaginatedResponse(api.device_query_list, lwrap_type=Query, **kwargs)
|
def list_queries(self, **kwargs)
|
List queries in device query service.
:param int limit: The number of devices to retrieve.
:param str order: The ordering direction, ascending (asc) or
descending (desc)
:param str after: Get devices after/starting at given `device_id`
:param filters: Dictionary of filters to apply.
:returns: a list of :py:class:`Query` objects.
:rtype: PaginatedResponse
| 8.514985
| 8.318137
| 1.023665
|
# Ensure we have the correct types and get the new query object
filter_obj = filters.legacy_filter_formatter(
dict(filter=filter),
Device._get_attributes_map()
) if filter else None
query_map = Query._create_request_map(kwargs)
# Create the DeviceQuery object
f = DeviceQuery(name=name, query=filter_obj['filter'], **query_map)
api = self._get_api(device_directory.DefaultApi)
return Query(api.device_query_create(f))
|
def add_query(self, name, filter, **kwargs)
|
Add a new query to device query service.
.. code-block:: python
f = api.add_query(
name = "Query name",
filter = {
"device_id": {"$eq": "01234"},
custom_attributes = {
"foo": {"$eq": "bar"}
}
}
)
print(f.created_at)
:param str name: Name of query (Required)
:param dict filter: Filter properties to apply (Required)
:param return: The newly created query object.
:return: the newly created query object
:rtype: Query
| 9.72616
| 9.345939
| 1.040683
|
# Get urlencoded query attribute
filter_obj = filters.legacy_filter_formatter(
dict(filter=filter),
Device._get_attributes_map()
) if filter else None
query_map = Query._create_request_map(kwargs)
# The filter option is optional on update but DeviceQueryPostPutRequest sets it None, which is invalid.
# Manually create a resource body without the filter parameter if only the name is provided.
if filter is None:
body = {"name": name}
else:
body = DeviceQueryPostPutRequest(name=name, query=filter_obj['filter'], **query_map)
api = self._get_api(device_directory.DefaultApi)
return Query(api.device_query_update(query_id, body))
|
def update_query(self, query_id, name=None, filter=None, **kwargs)
|
Update existing query in device query service.
.. code-block:: python
q = api.get_query(...)
q.filter["custom_attributes"]["foo"] = {
"$eq": "bar"
}
new_q = api.update_query(
query_id = q.id,
name = "new name",
filter = q.filter
)
:param str query_id: Existing query ID to update (Required)
:param str name: name of query
:param dict filter: query properties to apply
:return: the newly updated query object.
:rtype: Query
| 10.915496
| 11.130084
| 0.98072
|
api = self._get_api(device_directory.DefaultApi)
api.device_query_destroy(query_id)
return
|
def delete_query(self, query_id)
|
Delete query in device query service.
:param int query_id: ID of the query to delete (Required)
:return: void
| 13.239276
| 12.518101
| 1.057611
|
api = self._get_api(device_directory.DefaultApi)
return Query(api.device_query_retrieve(query_id))
|
def get_query(self, query_id)
|
Get query in device query service.
:param int query_id: ID of the query to get (Required)
:returns: device query object
:rtype: Query
| 16.046745
| 14.660301
| 1.094571
|
kwargs = self._verify_sort_options(kwargs)
kwargs = self._verify_filters(kwargs, DeviceEvent, True)
api = self._get_api(device_directory.DefaultApi)
return PaginatedResponse(api.device_log_list, lwrap_type=DeviceEvent, **kwargs)
|
def list_device_events(self, **kwargs)
|
List all device logs.
:param int limit: The number of logs to retrieve.
:param str order: The ordering direction, ascending (asc) or
descending (desc)
:param str after: Get logs after/starting at given `device_event_id`
:param dict filters: Dictionary of filters to apply.
:return: list of :py:class:`DeviceEvent` objects
:rtype: PaginatedResponse
| 8.295775
| 8.077405
| 1.027035
|
api = self._get_api(device_directory.DefaultApi)
return DeviceEvent(api.device_log_retrieve(device_event_id))
|
def get_device_event(self, device_event_id)
|
Get device event with provided ID.
:param int device_event_id: id of the event to get (Required)
:rtype: DeviceEvent
| 10.259137
| 13.468665
| 0.761704
|
if isinstance(self._filter, str):
return self._decode_query(self._filter)
return self._filter
|
def filter(self)
|
Get the query of this Query.
The device query
:return: The query of this Query.
:rtype: dict
| 6.19517
| 7.304487
| 0.848132
|
for metadata_key in ('METADATA', 'PKG-INFO'):
try:
metadata_lines = item.get_metadata_lines(metadata_key)
break
except (KeyError, IOError):
# The package will be shown in the report without any license information
# if a metadata key is not found.
metadata_lines = []
return metadata_lines
|
def get_metadata(item)
|
Get metadata information from the distribution.
Depending on the package this may either be in METADATA or PKG-INFO
:param item: pkg_resources WorkingSet item
:returns: metadata resource as list of non-blank non-comment lines
| 5.923338
| 5.356882
| 1.105744
|
if not text:
return None
text = text.rsplit(':', 1)[-1]
replacements = [
'licenses',
'license',
'licences',
'licence',
'software',
',',
]
for replacement in replacements:
text = text.replace(replacement, '')
text = text.strip().upper()
text = text.replace(' ', '_')
text = text.replace('-', '_')
if any(trigger.upper() in text for trigger in BAD_LICENSES):
return None
return text
|
def license_cleanup(text)
|
Tidy up a license string
e.g. "::OSI:: mit software license" -> "MIT"
| 3.304552
| 3.308922
| 0.998679
|
lower_line = line.lower()
try:
metadata_key, metadata_value = lower_line.split(':', 1)
except ValueError:
return
metadata_key = metadata_key.strip()
metadata_value = metadata_value.strip()
if metadata_value == 'unknown':
return
# extract exact matches
if metadata_key in TPIP_FIELD_MAPPINGS:
tpip_pkg[TPIP_FIELD_MAPPINGS[metadata_key]] = metadata_value
return
if metadata_key.startswith('version') and not tpip_pkg.get('PkgVersion'):
# ... but if not, we'll use whatever we find
tpip_pkg['PkgVersion'] = metadata_value
return
# Handle british and american spelling of licence/license
if 'licen' in lower_line:
if metadata_key.startswith('classifier') or '::' in metadata_value:
license = lower_line.rsplit(':')[-1].strip().lower()
license = license_cleanup(license)
if license:
tpip_pkg.setdefault('PkgLicenses', []).append(license)
|
def get_package_info_from_line(tpip_pkg, line)
|
Given a line of text from metadata, extract semantic info
| 3.7524
| 3.692783
| 1.016144
|
# Initialise a dictionary with all the fields to report on.
tpip_pkg = dict(
PkgName=pkg_name,
PkgType='python package',
PkgMgrURL='https://pypi.org/project/%s/' % pkg_name,
)
# Extract the metadata into a list for each field as there may be multiple
# entries for each one.
for line in metadata_lines:
get_package_info_from_line(tpip_pkg, line)
# condense PkgAuthorEmail into the Originator field
if 'PkgAuthorEmail' in tpip_pkg:
tpip_pkg['PkgOriginator'] = '%s <%s>' % (
tpip_pkg['PkgOriginator'],
tpip_pkg.pop('PkgAuthorEmail')
)
explicit_license = license_cleanup(tpip_pkg.get('PkgLicense'))
license_candidates = tpip_pkg.pop('PkgLicenses', [])
if explicit_license:
tpip_pkg['PkgLicense'] = explicit_license
else:
tpip_pkg['PkgLicense'] = ' '.join(set(license_candidates))
return tpip_pkg
|
def process_metadata(pkg_name, metadata_lines)
|
Create a dictionary containing the relevant fields.
The following is an example of the generated dictionary:
:Example:
{
'name': 'six',
'version': '1.11.0',
'repository': 'pypi.python.org/pypi/six',
'licence': 'MIT',
'classifier': 'MIT License'
}
:param str pkg_name: name of the package
:param metadata_lines: metadata resource as list of non-blank non-comment lines
:returns: Dictionary of each of the fields
:rtype: Dict[str, str]
| 3.974915
| 4.094305
| 0.97084
|
dirname = os.path.dirname(os.path.abspath(os.path.expanduser(output_filename)))
if dirname and not os.path.exists(dirname):
os.makedirs(dirname)
with open(output_filename, 'w', newline='') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=FIELDNAMES)
writer.writeheader()
writer.writerows(tpip_pkgs)
|
def write_csv_file(output_filename, tpip_pkgs)
|
Write the TPIP report out to a CSV file.
:param str output_filename: filename for CSV.
:param List tpip_pkgs: a list of dictionaries compatible with DictWriter.
| 1.707028
| 1.974624
| 0.864483
|
return {
k: v.encode('utf8').decode('ascii', 'backslashreplace')
for k, v in data.items()
}
|
def force_ascii_values(data)
|
Ensures each value is ascii-only
| 3.304755
| 3.257144
| 1.014617
|
parser = argparse.ArgumentParser(description='Generate a TPIP report as a CSV file.')
parser.add_argument('output_filename', type=str, metavar='output-file',
help='the output path and filename', nargs='?')
parser.add_argument('--only', type=str, help='only parse this package')
args = parser.parse_args()
output_path = os.path.abspath(args.output_filename) if args.output_filename else None
skips = []
tpip_pkgs = []
for pkg_name, pkg_item in sorted(pkg_resources.working_set.by_key.items()):
if args.only and args.only not in pkg_name.lower():
continue
if pkg_name in EXCLUDED_PACKAGES:
skips.append(pkg_name)
continue
metadata_lines = get_metadata(pkg_item)
tpip_pkg = process_metadata(pkg_name, metadata_lines)
tpip_pkgs.append(force_ascii_values(tpip_pkg))
print(json.dumps(tpip_pkgs, indent=2, sort_keys=True))
print('Parsed %s packages\nOutput to CSV: `%s`\nIgnored packages: %s' % (
len(tpip_pkgs),
output_path,
', '.join(skips),
))
output_path and write_csv_file(output_path, tpip_pkgs)
|
def main()
|
Generate a TPIP report.
| 3.132672
| 2.876114
| 1.089203
|
if remaining_quota is None:
raise ValueError("Invalid value for `remaining_quota`, must not be `None`")
if remaining_quota is not None and remaining_quota < 0:
raise ValueError("Invalid value for `remaining_quota`, must be a value greater than or equal to `0`")
self._remaining_quota = remaining_quota
|
def remaining_quota(self, remaining_quota)
|
Sets the remaining_quota of this ServicePackageMetadata.
Current available service package quota.
:param remaining_quota: The remaining_quota of this ServicePackageMetadata.
:type: int
| 1.591117
| 1.547196
| 1.028387
|
if reserved_quota is None:
raise ValueError("Invalid value for `reserved_quota`, must not be `None`")
if reserved_quota is not None and reserved_quota < 0:
raise ValueError("Invalid value for `reserved_quota`, must be a value greater than or equal to `0`")
self._reserved_quota = reserved_quota
|
def reserved_quota(self, reserved_quota)
|
Sets the reserved_quota of this ServicePackageMetadata.
Sum of all open reservations for this account.
:param reserved_quota: The reserved_quota of this ServicePackageMetadata.
:type: int
| 1.546917
| 1.484119
| 1.042314
|
return self.create_bulk_device_enrollment_with_http_info(enrollment_identities, **kwargs) # noqa: E501
else:
(data) = self.create_bulk_device_enrollment_with_http_info(enrollment_identities, **kwargs) # noqa: E501
return data
|
def create_bulk_device_enrollment(self, enrollment_identities, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Bulk upload # noqa: E501
With bulk upload, you can upload a `CSV` file containing a number of enrollment IDs. **Example usage:** ``` curl -X POST \\ -H 'Authorization: Bearer <valid access token>' \\ -F 'enrollment_identities=@/path/to/enrollments/enrollments.csv' \\ https://api.us-east-1.mbedcloud.com/v3/device-enrollments-bulk-uploads ``` **An example `CSV` file:** 1. The first line is assumed to be the header. The content of the header is not validated. 2. Each line can contain comma-separated values, where the first value is always assumed to be the Enrollment ID. 3. Only one enrollment ID is expected per line. 4. Valid enrollments begin with A followed by a - and 95 characters in the format as below. 5. Valid enrollment identities may be enclosed within quotes. 6. UTF-8 encoding is expected. ``` \"enrollment_identity\" \"A-4E:63:2D:AE:14:BC:D1:09:77:21:95:44:ED:34:06:57:1E:03:B1:EF:0E:F2:59:44:71:93:23:22:15:43:23:12\", \"A-4E:63:2D:AE:14:BC:D1:09:77:21:95:44:ED:34:06:57:1E:03:B1:EF:0E:F2:59:25:48:44:71:22:15:43:23:12\", ``` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.create_bulk_device_enrollment(enrollment_identities, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param file enrollment_identities: The `CSV` file containing the enrollment IDs. The maximum file size is 10MB. (required)
:return: BulkResponse
If the method is called asynchronously,
returns the request thread.
| 1.49069
| 2.017015
| 0.739057
|
return self.create_device_enrollment_with_http_info(enrollment_identity, **kwargs) # noqa: E501
else:
(data) = self.create_device_enrollment_with_http_info(enrollment_identity, **kwargs) # noqa: E501
return data
|
def create_device_enrollment(self, enrollment_identity, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Place an enrollment claim for one or several devices. # noqa: E501
When the device connects to the bootstrap server and provides the enrollment ID, it will be assigned to your account. <br> **Example usage:** ``` curl -X POST \\ -H 'Authorization: Bearer <valid access token>' \\ -H 'content-type: application/json' \\ https://api.us-east-1.mbedcloud.com/v3/device-enrollments \\ -d '{\"enrollment_identity\": \"A-35:e7:72:8a:07:50:3b:3d:75:96:57:52:72:41:0d:78:cc:c6:e5:53:48:c6:65:58:5b:fa:af:4d:2d:73:95:c5\"}' ``` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.create_device_enrollment(enrollment_identity, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param EnrollmentId enrollment_identity: (required)
:return: EnrollmentIdentity
If the method is called asynchronously,
returns the request thread.
| 1.532872
| 2.110068
| 0.726456
|
return self.delete_bulk_device_enrollment_with_http_info(enrollment_identities, **kwargs) # noqa: E501
else:
(data) = self.delete_bulk_device_enrollment_with_http_info(enrollment_identities, **kwargs) # noqa: E501
return data
|
def delete_bulk_device_enrollment(self, enrollment_identities, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Bulk delete # noqa: E501
With bulk delete, you can upload a `CSV` file containing a number of enrollment IDs to be deleted. **Example usage:** ``` curl -X POST \\ -H 'Authorization: Bearer <valid access token>' \\ -F 'enrollment_identities=@/path/to/enrollments/enrollments.csv' \\ https://api.us-east-1.mbedcloud.com/v3/device-enrollments-bulk-deletes ``` **An example `CSV` file:** 1. The first line is assumed to be the header. The content of the header is not validated. 2. Each line can contain comma-separated values, where the first value is always assumed to be the Enrollment ID. 3. Only one enrollment ID is expected per line. 4. Valid enrollments begin with A followed by a - and 95 characters in the format as below. 5. Valid enrollment identities may be enclosed within quotes. 6. UTF-8 encoding is expected. ``` \"enrollment_identity\" \"A-4E:63:2D:AE:14:BC:D1:09:77:21:95:44:ED:34:06:57:1E:03:B1:EF:0E:F2:59:44:71:93:23:22:15:43:23:12\", \"A-4E:63:2D:AE:14:BC:D1:09:77:21:95:44:ED:34:06:57:1E:03:B1:EF:0E:F2:59:25:48:44:71:22:15:43:23:12\", ``` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.delete_bulk_device_enrollment(enrollment_identities, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param file enrollment_identities: The `CSV` file containing the enrollment IDs. The maximum file size is 10MB. (required)
:return: BulkResponse
If the method is called asynchronously,
returns the request thread.
| 1.503904
| 2.000756
| 0.751668
|
return self.delete_device_enrollment_with_http_info(id, **kwargs) # noqa: E501
else:
(data) = self.delete_device_enrollment_with_http_info(id, **kwargs) # noqa: E501
return data
|
def delete_device_enrollment(self, id, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Delete an enrollment by ID. # noqa: E501
To free a device from your account you can delete the enrollment claim. To bypass the device ownership, you need to delete the enrollment and do a factory reset for the device. For more information, see [Transferring the ownership using First-to-Claim](/docs/current/connecting/device-ownership.html). <br> **Example usage:** ``` curl -X DELETE \\ -H 'Authorization: Bearer <valid access token>' \\ https://api.us-east-1.mbedcloud.com/v3/device-enrollments/{id} ``` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.delete_device_enrollment(id, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str id: Enrollment identity. (required)
:return: None
If the method is called asynchronously,
returns the request thread.
| 1.588778
| 2.314543
| 0.686432
|
return self.get_bulk_device_enrollment_with_http_info(id, **kwargs) # noqa: E501
else:
(data) = self.get_bulk_device_enrollment_with_http_info(id, **kwargs) # noqa: E501
return data
|
def get_bulk_device_enrollment(self, id, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get bulk upload entity # noqa: E501
Provides information on bulk upload for the given ID. For example, the bulk status and the number of processed enrollment identities. Also links to the bulk upload reports are provided. **Example usage:** ``` curl -X GET \\ -H 'Authorization: Bearer <valid access token>' \\ https://api.us-east-1.mbedcloud.com/v3/device-enrollments-bulk-uploads/{id} ``` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_bulk_device_enrollment(id, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str id: Bulk create task entity ID (required)
:return: BulkResponse
If the method is called asynchronously,
returns the request thread.
| 1.545117
| 2.175193
| 0.710335
|
return self.get_bulk_device_enrollment_delete_with_http_info(id, **kwargs) # noqa: E501
else:
(data) = self.get_bulk_device_enrollment_delete_with_http_info(id, **kwargs) # noqa: E501
return data
|
def get_bulk_device_enrollment_delete(self, id, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get bulk delete entity # noqa: E501
Provides information on bulk delete for the given ID. For example, the bulk status and the number of processed enrollment identities. Also links to the bulk delete reports are provided. **Example usage:** ``` curl -X GET \\ -H 'Authorization: Bearer <valid access token>' \\ https://api.us-east-1.mbedcloud.com/v3/device-enrollments-bulk-deletes/{id} ``` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_bulk_device_enrollment_delete(id, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str id: Bulk delete task entity ID (required)
:return: BulkResponse
If the method is called asynchronously,
returns the request thread.
| 1.500546
| 2.098638
| 0.71501
|
return self.get_device_enrollment_with_http_info(id, **kwargs) # noqa: E501
else:
(data) = self.get_device_enrollment_with_http_info(id, **kwargs) # noqa: E501
return data
|
def get_device_enrollment(self, id, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get details of an enrollment by ID. # noqa: E501
To check the enrollment info in detail, for example date of claim and expiration date. **Example usage:** ``` curl -X GET \\ -H 'Authorization: Bearer <valid access token>' \\ https://api.us-east-1.mbedcloud.com/v3/device-enrollments/{id} ``` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_device_enrollment(id, asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param str id: Enrollment identity. (required)
:return: EnrollmentIdentity
If the method is called asynchronously,
returns the request thread.
| 1.588045
| 2.22233
| 0.714586
|
return self.get_device_enrollments_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_device_enrollments_with_http_info(**kwargs) # noqa: E501
return data
|
def get_device_enrollments(self, **kwargs): # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('asynchronous')
|
Get enrollment list. # noqa: E501
Provides a list of pending and claimed enrollments. **Example usage:** ``` curl -X GET \\ -H 'Authorization: Bearer <valid access token>' \\ https://api.us-east-1.mbedcloud.com/v3/device-enrollments ``` With query parameters: ``` curl -X GET \\ -H 'Authorization: Bearer <valid access token>' \\ 'https://api.us-east-1.mbedcloud.com/v3/device-enrollments?limit=10' ``` # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass asynchronous=True
>>> thread = api.get_device_enrollments(asynchronous=True)
>>> result = thread.get()
:param asynchronous bool
:param int limit: Number of results to be returned. Between 2 and 1000, inclusive.
:param str after: Entity ID to fetch after.
:param str order: ASC or DESC
:param str include: Comma-separated additional data to return. Currently supported: total_count.
:return: EnrollmentIdentities
If the method is called asynchronously,
returns the request thread.
| 1.625
| 2.10679
| 0.771316
|
if root_manifest_id is not None and len(root_manifest_id) > 32:
raise ValueError("Invalid value for `root_manifest_id`, length must be less than or equal to `32`")
self._root_manifest_id = root_manifest_id
|
def root_manifest_id(self, root_manifest_id)
|
Sets the root_manifest_id of this UpdateCampaignPutRequest.
:param root_manifest_id: The root_manifest_id of this UpdateCampaignPutRequest.
:type: str
| 1.801847
| 2.133709
| 0.844467
|
allowed_values = ["draft", "scheduled", "allocatingquota", "allocatedquota", "quotaallocationfailed", "checkingmanifest", "checkedmanifest", "devicefetch", "devicecopy", "devicecheck", "publishing", "deploying", "deployed", "manifestremoved", "expired", "stopping", "autostopped", "userstopped", "conflict"]
if state not in allowed_values:
raise ValueError(
"Invalid value for `state` ({0}), must be one of {1}"
.format(state, allowed_values)
)
self._state = state
|
def state(self, state)
|
Sets the state of this UpdateCampaignPutRequest.
The state of the campaign
:param state: The state of this UpdateCampaignPutRequest.
:type: str
| 6.032921
| 5.760643
| 1.047265
|
LOG.debug('notify received: %s', data)
self._notify_count += 1
if self._cancelled:
LOG.debug('notify skipping due to `cancelled`')
return self
if self._once_done and self._once:
LOG.debug('notify skipping due to `once`')
return self
with self._lock:
try:
# notify next consumer immediately
self._waitables.get_nowait().put_nowait(data)
LOG.debug('found a consumer, notifying')
except queue.Empty:
# store the notification
try:
self._notifications.put_nowait(data)
LOG.debug('no consumers, queueing data')
except queue.Full:
LOG.warning('notification queue full - discarding new data')
# callbacks are sent straight away
# bombproofing should be handled by individual callbacks
for callback in self._callbacks:
LOG.debug('callback: %s', callback)
callback(data)
self._once_done = True
return self
|
def notify(self, data)
|
Notify this observer that data has arrived
| 4.60674
| 4.631355
| 0.994685
|
LOG.debug('cancelling %s', self)
self._cancelled = True
self.clear_callbacks() # not strictly necessary, but may release references
while True:
try:
self._waitables.get_nowait().put_nowait(self.sentinel)
except queue.Empty:
break
|
def cancel(self)
|
Cancels the observer
No more notifications will be passed on
| 6.202012
| 6.336852
| 0.978721
|
if hmac_hex_key is None:
raise ValueError("Invalid value for `hmac_hex_key`, must not be `None`")
if hmac_hex_key is not None and len(hmac_hex_key) > 64:
raise ValueError("Invalid value for `hmac_hex_key`, length must be less than or equal to `64`")
if hmac_hex_key is not None and not re.search('^([a-fA-F0-9][a-fA-F0-9]){1,32}$', hmac_hex_key):
raise ValueError("Invalid value for `hmac_hex_key`, must be a follow pattern or equal to `/^([a-fA-F0-9][a-fA-F0-9]){1,32}$/`")
self._hmac_hex_key = hmac_hex_key
|
def hmac_hex_key(self, hmac_hex_key)
|
Sets the hmac_hex_key of this CfsslAuthCredentials.
The key that is used to compute the HMAC of the request using the HMAC-SHA-256 algorithm. Must contain an even number of hexadecimal characters.
:param hmac_hex_key: The hmac_hex_key of this CfsslAuthCredentials.
:type: str
| 1.480936
| 1.430237
| 1.035448
|
if name is None:
raise ValueError("Invalid value for `name`, must not be `None`")
if name is not None and len(name) > 200:
raise ValueError("Invalid value for `name`, length must be less than or equal to `200`")
self._name = name
|
def name(self, name)
|
Sets the name of this DeviceQueryPostPutRequest.
The name of the query.
:param name: The name of this DeviceQueryPostPutRequest.
:type: str
| 1.815494
| 1.66993
| 1.087167
|
if query is None:
raise ValueError("Invalid value for `query`, must not be `None`")
if query is not None and len(query) > 1000:
raise ValueError("Invalid value for `query`, length must be less than or equal to `1000`")
self._query = query
|
def query(self, query)
|
Sets the query of this DeviceQueryPostPutRequest.
The device query.
:param query: The query of this DeviceQueryPostPutRequest.
:type: str
| 1.95222
| 1.705691
| 1.144534
|
kwargs = self._verify_sort_options(kwargs)
kwargs = self._verify_filters(kwargs, ApiKey)
api = self._get_api(iam.DeveloperApi)
# Return the data array
return PaginatedResponse(api.get_all_api_keys, lwrap_type=ApiKey, **kwargs)
|
def list_api_keys(self, **kwargs)
|
List the API keys registered in the organisation.
List api keys Example:
.. code-block:: python
account_management_api = AccountManagementAPI()
# List api keys
api_keys_paginated_response = account_management_api.list_api_keys()
# get single api key
api_keys_paginated_response.data[0]
:param int limit: Number of API keys to get
:param str after: Entity ID after which to start fetching
:param str order: Order of the records to return (asc|desc)
:param dict filters: Dictionary of filters to apply: str owner (eq)
:returns: a list of :class:`ApiKey` objects
:rtype: PaginatedResponse
:raises: ApiException
| 8.940153
| 10.06916
| 0.887875
|
api = self._get_api(iam.DeveloperApi)
return ApiKey(api.get_api_key(api_key_id))
|
def get_api_key(self, api_key_id)
|
Get API key details for key registered in organisation.
:param str api_key_id: The ID of the API key to be updated (Required)
:returns: API key object
:rtype: ApiKey
| 7.794384
| 9.621185
| 0.810127
|
api = self._get_api(iam.DeveloperApi)
api.delete_api_key(api_key_id)
return
|
def delete_api_key(self, api_key_id)
|
Delete an API key registered in the organisation.
:param str api_key_id: The ID of the API key (Required)
:returns: void
| 6.726893
| 8.233634
| 0.817002
|
api = self._get_api(iam.DeveloperApi)
kwargs.update({'name': name})
api_key = ApiKey._create_request_map(kwargs)
body = iam.ApiKeyInfoReq(**api_key)
return ApiKey(api.create_api_key(body))
|
def add_api_key(self, name, **kwargs)
|
Create new API key registered to organisation.
:param str name: The name of the API key (Required)
:param list groups: List of group IDs (`str`)
:param str owner: User ID owning the API key
:param str status: The status of the API key. Values: ACTIVE, INACTIVE
:returns: Newly created API key object
:rtype: ApiKey
| 8.031859
| 8.12216
| 0.988882
|
api = self._get_api(iam.DeveloperApi)
apikey = ApiKey._create_request_map(kwargs)
body = iam.ApiKeyUpdateReq(**apikey)
return ApiKey(api.update_api_key(api_key_id, body))
|
def update_api_key(self, api_key_id, **kwargs)
|
Update API key.
:param str api_key_id: The ID of the API key to be updated (Required)
:param str name: The name of the API key
:param str owner: User ID owning the API key
:param str status: The status of the API key. Values: ACTIVE, INACTIVE
:returns: Newly created API key object
:rtype: ApiKey
| 7.572565
| 8.814113
| 0.859141
|
kwargs = self._verify_sort_options(kwargs)
kwargs = self._verify_filters(kwargs, User)
api = self._get_api(iam.AccountAdminApi)
return PaginatedResponse(api.get_all_users, lwrap_type=User, **kwargs)
|
def list_users(self, **kwargs)
|
List all users in organisation.
:param int limit: The number of users to retrieve
:param str order: The ordering direction, ascending (asc) or descending (desc)
:param str after: Get users after/starting at given user ID
:param dict filters: Dictionary of filters to apply: str status (eq)
:returns: a list of :py:class:`User` objects
:rtype: PaginatedResponse
| 7.243546
| 7.420323
| 0.976177
|
api = self._get_api(iam.AccountAdminApi)
return User(api.get_user(user_id))
|
def get_user(self, user_id)
|
Get user details of specified user.
:param str user_id: the ID of the user to get (Required)
:returns: the user object with details about the user.
:rtype: User
| 9.325348
| 9.353215
| 0.997021
|
api = self._get_api(iam.AccountAdminApi)
user = User._create_request_map(kwargs)
body = iam.UserUpdateReq(**user)
return User(api.update_user(user_id, body))
|
def update_user(self, user_id, **kwargs)
|
Update user properties of specified user.
:param str user_id: The ID of the user to update (Required)
:param str username: The unique username of the user
:param str email: The unique email of the user
:param str full_name: The full name of the user
:param str password: The password string of the user.
:param str phone_number: Phone number of the user
:param bool terms_accepted: Is 'General Terms & Conditions' accepted
:param bool marketing_accepted: Is receiving marketing information accepted?
:returns: the updated user object
:rtype: User
| 8.080228
| 8.53816
| 0.946366
|
api = self._get_api(iam.AccountAdminApi)
api.delete_user(user_id)
return
|
def delete_user(self, user_id)
|
Delete user specified user.
:param str user_id: the ID of the user to delete (Required)
:returns: void
| 8.209035
| 8.046391
| 1.020213
|
api = self._get_api(iam.AccountAdminApi)
kwargs.update({'username': username, 'email': email})
user = User._create_request_map(kwargs)
body = iam.UserUpdateReq(**user)
return User(api.create_user(body))
|
def add_user(self, username, email, **kwargs)
|
Create a new user with provided details.
Add user example:
.. code-block:: python
account_management_api = AccountManagementAPI()
# Add user
user = {
"username": "test_user",
"email": "test@gmail.com",
"phone_number": "0123456789"
}
new_user = account_management_api.add_user(**user)
:param str username: The unique username of the user (Required)
:param str email: The unique email of the user (Required)
:param str full_name: The full name of the user
:param list groups: List of group IDs (`str`) which this user belongs to
:param str password: The password string of the user
:param str phone_number: Phone number of the user
:param bool terms_accepted: 'General Terms & Conditions' have been accepted
:param bool marketing_accepted: Marketing Information opt-in
:returns: the new user object
:rtype: User
| 8.211436
| 9.696623
| 0.846835
|
api = self._get_api(iam.DeveloperApi)
return Account(api.get_my_account_info(include="limits, policies"))
|
def get_account(self)
|
Get details of the current account.
:returns: an account object.
:rtype: Account
| 22.799433
| 26.282881
| 0.867463
|
api = self._get_api(iam.AccountAdminApi)
account = Account._create_request_map(kwargs)
body = AccountUpdateReq(**account)
return Account(api.update_my_account(body))
|
def update_account(self, **kwargs)
|
Update details of account associated with current API key.
:param str address_line1: Postal address line 1.
:param str address_line2: Postal address line 2.
:param str city: The city part of the postal address.
:param str display_name: The display name for the account.
:param str country: The country part of the postal address.
:param str company: The name of the company.
:param str state: The state part of the postal address.
:param str contact: The name of the contact person for this account.
:param str postal_code: The postal code part of the postal address.
:param str parent_id: The ID of the parent account.
:param str phone_number: The phone number of the company.
:param str email: Email address for this account.
:param list[str] aliases: List of aliases
:returns: an account object.
:rtype: Account
| 11.634185
| 11.250213
| 1.03413
|
kwargs = self._verify_sort_options(kwargs)
api = self._get_api(iam.DeveloperApi)
return PaginatedResponse(api.get_all_groups, lwrap_type=Group, **kwargs)
|
def list_groups(self, **kwargs)
|
List all groups in organisation.
:param int limit: The number of groups to retrieve
:param str order: The ordering direction, ascending (asc) or descending (desc)
:param str after: Get groups after/starting at given group ID
:returns: a list of :py:class:`Group` objects.
:rtype: PaginatedResponse
| 9.92619
| 11.514712
| 0.862044
|
api = self._get_api(iam.DeveloperApi)
return Group(api.get_group_summary(group_id))
|
def get_group(self, group_id)
|
Get details of the group.
:param str group_id: The group ID (Required)
:returns: :py:class:`Group` object.
:rtype: Group
| 12.08779
| 10.593426
| 1.141065
|
kwargs["group_id"] = group_id
kwargs = self._verify_sort_options(kwargs)
api = self._get_api(iam.AccountAdminApi)
return PaginatedResponse(api.get_users_of_group, lwrap_type=User, **kwargs)
|
def list_group_users(self, group_id, **kwargs)
|
List users of a group.
:param str group_id: The group ID (Required)
:param int limit: The number of users to retrieve
:param str order: The ordering direction, ascending (asc) or descending (desc)
:param str after: Get API keys after/starting at given user ID
:returns: a list of :py:class:`User` objects.
:rtype: PaginatedResponse
| 7.193313
| 7.90224
| 0.910288
|
kwargs["group_id"] = group_id
kwargs = self._verify_sort_options(kwargs)
api = self._get_api(iam.DeveloperApi)
return PaginatedResponse(api.get_api_keys_of_group, lwrap_type=ApiKey, **kwargs)
|
def list_group_api_keys(self, group_id, **kwargs)
|
List API keys of a group.
:param str group_id: The group ID (Required)
:param int limit: The number of api keys to retrieve.
:param str order: The ordering direction, ascending (asc) or descending (desc).
:param str after: Get API keys after/starting at given api key ID.
:returns: a list of :py:class:`ApiKey` objects.
:rtype: PaginatedResponse
| 7.490344
| 7.878332
| 0.950752
|
LOG.debug(
'%s on %s (awaitable %s async %s provider %s)',
'deferring',
self._func,
self._is_awaitable,
self._is_asyncio_provider,
self._concurrency_provider
)
if self._blocked:
raise RuntimeError('Already activated this deferred call by blocking on it')
with self._lock:
if not self._deferable:
func_partial = functools.partial(self._func, *args, **kwargs)
# we are either:
# - pure asyncio
# - asyncio but with blocking function
# - not asyncio, use threadpool
self._deferable = (
# pure asyncio
asyncio.ensure_future(func_partial(), loop=self._concurrency_provider)
if self._is_awaitable else (
# asyncio blocked
self._concurrency_provider.run_in_executor(
func=func_partial,
executor=None
)
if self._is_asyncio_provider else (
# not asyncio
self._concurrency_provider.apply_async(func_partial)
)
)
)
return self._deferable
|
def defer(self, *args, **kwargs)
|
Call the function and immediately return an asynchronous object.
The calling code will need to check for the result at a later time using:
In Python 2/3 using ThreadPools - an AsyncResult
(https://docs.python.org/2/library/multiprocessing.html#multiprocessing.pool.AsyncResult)
In Python 3 using Asyncio - a Future
(https://docs.python.org/3/library/asyncio-task.html#future)
:param args:
:param kwargs:
:return:
| 4.855536
| 4.871974
| 0.996626
|
LOG.debug(
'%s on %s (awaitable %s async %s provider %s)',
'blocking',
self._func,
self._is_awaitable,
self._is_asyncio_provider,
self._concurrency_provider
)
if self._deferable:
raise RuntimeError('Already activated this call by deferring it')
with self._lock:
if not hasattr(self, '_result'):
try:
self._result = (
self._concurrency_provider.run_until_complete(self.defer(*args, **kwargs))
if self._is_asyncio_provider else self._func(*args, **kwargs)
)
except queue.Empty:
raise CloudTimeoutError("No data received after %.1f seconds." % kwargs.get("timeout", 0))
self._blocked = True
return self._result
|
def block(self, *args, **kwargs)
|
Call the wrapped function, and wait for the result in a blocking fashion
Returns the result of the function call.
:param args:
:param kwargs:
:return: result of function call
| 6.419798
| 6.135214
| 1.046385
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.