-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
864 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from typing import Optional | ||
from azext_iot.common.utility import handle_service_exception | ||
from azext_iot.digitaltwins.providers.base import DigitalTwinsProvider | ||
from azext_iot.digitaltwins.providers import ErrorResponseException | ||
from azext_iot.common.embedded_cli import EmbeddedCLI | ||
from knack.log import get_logger | ||
from uuid import uuid4 | ||
|
||
DEFAULT_DELETE_JOB_ID_PREFIX = "delete-job-" | ||
logger = get_logger(__name__) | ||
|
||
|
||
class DeletionJobProvider(DigitalTwinsProvider): | ||
def __init__(self, cmd, name: str, rg: str = None): | ||
super(DeletionJobProvider, self).__init__(cmd=cmd, name=name, rg=rg) | ||
self.sdk = self.get_sdk().delete_jobs | ||
self.cli = EmbeddedCLI(cli_ctx=cmd.cli_ctx) | ||
|
||
def get(self, job_id: str): | ||
try: | ||
return self.sdk.get_by_id(job_id) | ||
except ErrorResponseException as e: | ||
handle_service_exception(e) | ||
|
||
def list(self, top: int = None): # top is guarded for int() in arg def | ||
from azext_iot.sdk.digitaltwins.dataplane.models import DeleteJobsListOptions | ||
|
||
list_options = DeleteJobsListOptions(max_items_per_page=top) | ||
|
||
try: | ||
return self.sdk.list(import_jobs_list_options=list_options,) | ||
except ErrorResponseException as e: | ||
handle_service_exception(e) | ||
|
||
def create(self, job_id: Optional[str] = None): | ||
job_id = job_id if job_id else DEFAULT_DELETE_JOB_ID_PREFIX + str(uuid4()).replace("-", "") | ||
self.sdk.config.operation_id = job_id | ||
try: | ||
return self.sdk.add(polling=False) | ||
except ErrorResponseException as e: | ||
handle_service_exception(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
azext_iot/sdk/digitaltwins/dataplane/models/delete_job_paged.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from msrest.paging import Paged | ||
|
||
|
||
class DeleteJobPaged(Paged): | ||
""" | ||
A paging container for iterating over a list of :class:`DeleteJob <dataplane.models.DeleteJob>` object | ||
""" | ||
|
||
_attribute_map = { | ||
'next_link': {'key': 'nextLink', 'type': 'str'}, | ||
'current_page': {'key': 'value', 'type': '[DeleteJob]'} | ||
} | ||
|
||
def __init__(self, *args, **kwargs): | ||
|
||
super(DeleteJobPaged, self).__init__(*args, **kwargs) |
Oops, something went wrong.