Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions sdk/digitaltwins/azure-digitaltwins-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# Release History

## 1.2.0 (Unreleased)
## 1.2.0 (2022-05-31)
- GA release

### Features Added

### Breaking Changes
## 1.2.0b1 (2022-03-31)

### Bugs Fixed

- Update `azure-core` dependency to avoid inconsistent dependencies from being installed.

### Other Changes

- Python 2.7 and 3.6 are no longer supported. Please use Python version 3.7 or later.


## 1.1.0 (2020-11-24)

- The is the GA release containing the following changes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
# --------------------------------------------------------------------------

from ._azure_digital_twins_api import AzureDigitalTwinsAPI
from ._version import VERSION

__version__ = VERSION
__all__ = ['AzureDigitalTwinsAPI']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
# `._patch.py` is used for handwritten extensions to the generated code
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
from ._patch import patch_sdk
patch_sdk()
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,23 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from copy import deepcopy
from typing import TYPE_CHECKING

from azure.core import PipelineClient
from msrest import Deserializer, Serializer

from azure.core import PipelineClient

from . import models
from ._configuration import AzureDigitalTwinsAPIConfiguration
from .operations import DigitalTwinModelsOperations, DigitalTwinsOperations, EventRoutesOperations, QueryOperations

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Optional
from typing import Any

from azure.core.credentials import TokenCredential

from ._configuration import AzureDigitalTwinsAPIConfiguration
from .operations import DigitalTwinModelsOperations
from .operations import QueryOperations
from .operations import DigitalTwinsOperations
from .operations import EventRoutesOperations
from . import models

from azure.core.rest import HttpRequest, HttpResponse

class AzureDigitalTwinsAPI(object):
"""A service for managing and querying digital twins and digital twin models.
Expand All @@ -38,34 +37,59 @@ class AzureDigitalTwinsAPI(object):
:vartype event_routes: azure.digitaltwins.core.operations.EventRoutesOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param str base_url: Service URL
:param base_url: Service URL. Default value is "https://digitaltwins-hostname".
:type base_url: str
:keyword api_version: Api Version. Default value is "2022-05-31". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
self,
credential, # type: "TokenCredential"
base_url=None, # type: Optional[str]
base_url="https://digitaltwins-hostname", # type: str
**kwargs # type: Any
):
# type: (...) -> None
if not base_url:
base_url = 'https://digitaltwins-name.digitaltwins.azure.net'
self._config = AzureDigitalTwinsAPIConfiguration(credential, **kwargs)
self._config = AzureDigitalTwinsAPIConfiguration(credential=credential, **kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.digital_twin_models = DigitalTwinModelsOperations(self._client, self._config, self._serialize, self._deserialize)
self.query = QueryOperations(self._client, self._config, self._serialize, self._deserialize)
self.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize)
self.event_routes = EventRoutesOperations(self._client, self._config, self._serialize, self._deserialize)


def _send_request(
self,
request, # type: HttpRequest
**kwargs # type: Any
):
# type: (...) -> HttpResponse
"""Runs the network request through the client's chained policies.

>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.HttpResponse
"""

self.digital_twin_models = DigitalTwinModelsOperations(
self._client, self._config, self._serialize, self._deserialize)
self.query = QueryOperations(
self._client, self._config, self._serialize, self._deserialize)
self.digital_twins = DigitalTwinsOperations(
self._client, self._config, self._serialize, self._deserialize)
self.event_routes = EventRoutesOperations(
self._client, self._config, self._serialize, self._deserialize)
request_copy = deepcopy(request)
request_copy.url = self._client.format_url(request_copy.url)
return self._client.send_request(request_copy, **kwargs)

def close(self):
# type: () -> None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,26 @@
from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from ._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

from azure.core.credentials import TokenCredential

VERSION = "unknown"

class AzureDigitalTwinsAPIConfiguration(Configuration):
class AzureDigitalTwinsAPIConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureDigitalTwinsAPI.

Note that all parameters used to create this instance are saved as instance
attributes.

:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:keyword api_version: Api Version. Default value is "2022-05-31". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
Expand All @@ -35,12 +39,14 @@ def __init__(
**kwargs # type: Any
):
# type: (...) -> None
super(AzureDigitalTwinsAPIConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop('api_version', "2022-05-31") # type: str

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
super(AzureDigitalTwinsAPIConfiguration, self).__init__(**kwargs)

self.credential = credential
self.api_version = "2020-10-31"
self.api_version = api_version
self.credential_scopes = kwargs.pop('credential_scopes', ['https://digitaltwins.azure.net/.default'])
kwargs.setdefault('sdk_moniker', 'azuredigitaltwinsapi/{}'.format(VERSION))
self._configure(**kwargs)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# coding=utf-8
# --------------------------------------------------------------------------
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the ""Software""), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
# --------------------------------------------------------------------------

# This file is used for handwritten extensions to the generated code. Example:
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
def patch_sdk():
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# --------------------------------------------------------------------------
# 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 azure.core.pipeline.transport import HttpRequest

def _convert_request(request, files=None):
data = request.content if not files else None
request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data)
if files:
request.set_formdata_body(files)
return request

def _format_url_section(template, **kwargs):
components = template.split("/")
while components:
try:
return template.format(**kwargs)
except KeyError as key:
formatted_components = template.split("/")
components = [
c for c in formatted_components if "{}".format(key.args[0]) not in c
]
template = "/".join(components)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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.
# --------------------------------------------------------------------------

VERSION = "1.2.0"
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@

from ._azure_digital_twins_api import AzureDigitalTwinsAPI
__all__ = ['AzureDigitalTwinsAPI']

# `._patch.py` is used for handwritten extensions to the generated code
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
from ._patch import patch_sdk
patch_sdk()
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any, Optional, TYPE_CHECKING
from copy import deepcopy
from typing import Any, Awaitable, TYPE_CHECKING

from azure.core import AsyncPipelineClient
from msrest import Deserializer, Serializer

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
from azure.core import AsyncPipelineClient
from azure.core.rest import AsyncHttpResponse, HttpRequest

from ._configuration import AzureDigitalTwinsAPIConfiguration
from .operations import DigitalTwinModelsOperations
from .operations import QueryOperations
from .operations import DigitalTwinsOperations
from .operations import EventRoutesOperations
from .. import models
from ._configuration import AzureDigitalTwinsAPIConfiguration
from .operations import DigitalTwinModelsOperations, DigitalTwinsOperations, EventRoutesOperations, QueryOperations

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential

class AzureDigitalTwinsAPI(object):
class AzureDigitalTwinsAPI:
"""A service for managing and querying digital twins and digital twin models.

:ivar digital_twin_models: DigitalTwinModelsOperations operations
:vartype digital_twin_models: azure.digitaltwins.core.aio.operations.DigitalTwinModelsOperations
:vartype digital_twin_models:
azure.digitaltwins.core.aio.operations.DigitalTwinModelsOperations
:ivar query: QueryOperations operations
:vartype query: azure.digitaltwins.core.aio.operations.QueryOperations
:ivar digital_twins: DigitalTwinsOperations operations
Expand All @@ -36,33 +36,57 @@ class AzureDigitalTwinsAPI(object):
:vartype event_routes: azure.digitaltwins.core.aio.operations.EventRoutesOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param str base_url: Service URL
:param base_url: Service URL. Default value is "https://digitaltwins-hostname".
:type base_url: str
:keyword api_version: Api Version. Default value is "2022-05-31". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(
self,
credential: "AsyncTokenCredential",
base_url: Optional[str] = None,
base_url: str = "https://digitaltwins-hostname",
**kwargs: Any
) -> None:
if not base_url:
base_url = 'https://digitaltwins-name.digitaltwins.azure.net'
self._config = AzureDigitalTwinsAPIConfiguration(credential, **kwargs)
self._config = AzureDigitalTwinsAPIConfiguration(credential=credential, **kwargs)
self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.digital_twin_models = DigitalTwinModelsOperations(self._client, self._config, self._serialize, self._deserialize)
self.query = QueryOperations(self._client, self._config, self._serialize, self._deserialize)
self.digital_twins = DigitalTwinsOperations(self._client, self._config, self._serialize, self._deserialize)
self.event_routes = EventRoutesOperations(self._client, self._config, self._serialize, self._deserialize)


def _send_request(
self,
request: HttpRequest,
**kwargs: Any
) -> Awaitable[AsyncHttpResponse]:
"""Runs the network request through the client's chained policies.

>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client._send_request(request)
<AsyncHttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart

:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.AsyncHttpResponse
"""

self.digital_twin_models = DigitalTwinModelsOperations(
self._client, self._config, self._serialize, self._deserialize)
self.query = QueryOperations(
self._client, self._config, self._serialize, self._deserialize)
self.digital_twins = DigitalTwinsOperations(
self._client, self._config, self._serialize, self._deserialize)
self.event_routes = EventRoutesOperations(
self._client, self._config, self._serialize, self._deserialize)
request_copy = deepcopy(request)
request_copy.url = self._client.format_url(request_copy.url)
return self._client.send_request(request_copy, **kwargs)

async def close(self) -> None:
await self._client.close()
Expand Down
Loading