diff --git a/sdk/api-learn/azure-computation/CHANGELOG.md b/sdk/api-learn/azure-computation/CHANGELOG.md new file mode 100644 index 000000000000..816f21db092e --- /dev/null +++ b/sdk/api-learn/azure-computation/CHANGELOG.md @@ -0,0 +1,8 @@ + +# Release History + +------------------- + +## 0.0.1 (Unreleased) + +- Training day! diff --git a/sdk/api-learn/azure-computation/MANIFEST.in b/sdk/api-learn/azure-computation/MANIFEST.in new file mode 100644 index 000000000000..7ebdd947f8ff --- /dev/null +++ b/sdk/api-learn/azure-computation/MANIFEST.in @@ -0,0 +1,4 @@ +recursive-include tests *.py +include *.md +include azure/__init__.py +recursive-include samples *.py *.md diff --git a/sdk/api-learn/azure-computation/README.md b/sdk/api-learn/azure-computation/README.md new file mode 100644 index 000000000000..64d1136bd3dd --- /dev/null +++ b/sdk/api-learn/azure-computation/README.md @@ -0,0 +1,89 @@ +# Azure Computation client library for Python SDK Training + +This is a demonstration API for the API design training tutorial. +We will use this example "Computation" service to practice recognizing common API patterns and applying the design guidelines. + +## Tutorial Task + +The objective of this tutorial is to design a "public API" or "customization layer" for this example service. +An SDK namespace, `azure-computation`, has already been set up, with directory structure and packaging scripts in place. +The swagger specification (found at `swagger/computation.json`), and the auto-generated layer has already been pre-generated, and can be found in the `_generated` directory. + +1. Follow the steps in the [API Design tutorial Setup](https://github.com/Azure/azure-sdk-pr/blob/master/training/azure-sdk-apis/tutorials/api-design-intro/setup/setup-python.md) for setting up the environment for this project. +2. Follow the steps in the [API Design tutorial](https://github.com/Azure/azure-sdk-pr/blob/master/training/azure-sdk-apis/tutorials/api-design-intro/api-design-intro/api-design-intro-python.md) for considering hero scenarios, and using them to build a public API. +3. Remember the common-patterns that we covered in the API Design presentation and see whether and how they can be applied to the API. If you wish to use one of these patterns - take a look through the [Python Design Guidelines](https://azure.github.io/azure-sdk/python_design.html#) for specifics. + - [Service Client](https://azure.github.io/azure-sdk/python_design.html#clients) + - [Authentication and `azure-identity`](https://azure.github.io/azure-sdk/python_design.html#authentication) + - [HTTP Abractions](https://azure.github.io/azure-sdk/python_design.html#service-operations) + - [Paged Collections](https://azure.github.io/azure-sdk/python_implementation.html#paged) + + Examples: + - [Azure Search](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/search/azure-search-documents) + - [`list_index_names`](https://github.com/Azure/azure-sdk-for-python/blob/19db374e7ea80f1d034f547e02750b7e3b3264a7/sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/_search_index_client.py#L98) + - [async `list_index_names`](https://github.com/Azure/azure-sdk-for-python/blob/19db374e7ea80f1d034f547e02750b7e3b3264a7/sdk/search/azure-search-documents/azure/search/documents/indexes/_internal/aio/_search_index_client.py#L99) + - [Form Recognizer](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/formrecognizer) + - [`list_custom_models`](https://github.com/Azure/azure-sdk-for-python/blob/19db374e7ea80f1d034f547e02750b7e3b3264a7/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_training_client.py#L208) + - [async `list_custom_models`](https://github.com/Azure/azure-sdk-for-python/blob/19db374e7ea80f1d034f547e02750b7e3b3264a7/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/aio/_form_training_client_async.py#L224) + + - [Long Running Operations](https://azure.github.io/azure-sdk/python_implementation.html#lropoller) + + Examples: + - [Form Recognizer](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/formrecognizer/azure-ai-formrecognizer) + - [`begin_recognize_receipts`](https://github.com/Azure/azure-sdk-for-python/blob/f451b9ec96a8317b8a292bbc664653c04cc62b2c/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_form_recognizer_client.py#L91) + - [async `begin_recognize_receipts`](https://github.com/Azure/azure-sdk-for-python/blob/f451b9ec96a8317b8a292bbc664653c04cc62b2c/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/aio/_form_recognizer_client_async.py#L96) + - [KeyVault Secrets](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/keyvault/azure-keyvault-secrets) + - [`begin_delete_secret`](https://github.com/Azure/azure-sdk-for-python/blob/f451b9ec96a8317b8a292bbc664653c04cc62b2c/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_client.py#L296) + - [async `begin_delete_secret`](https://github.com/Azure/azure-sdk-for-python/blob/f451b9ec96a8317b8a292bbc664653c04cc62b2c/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/aio/_client.py#L266) + +4. If you wish to make adjustments to the swagger specification, follow the instructions in the [API Design tutorial Review](https://github.com/Azure/azure-sdk-pr/blob/master/training/azure-sdk-apis/tutorials/api-design-intro/review-the-api/review-the-api-python.md#regenerate-the-code) for regenerating the code. +5. Follow the instructions in the [API Design tutorial Review](https://github.com/Azure/azure-sdk-pr/blob/master/training/azure-sdk-apis/tutorials/api-design-intro/review-the-api/review-the-api-python.md#building-a-python-wheel) for generating a wheel and uploading it to APIView. + +## API Review + +We will follow-up this tutorial activity with a "mock arch board review" of the APIs. For this session, have an example hero scenario ready (they need not be functioning code) and your API layout in APIView. + +## Structure of the example Computation service API + +### Operations in the Computation service + +This service has 5 APIs. + +- GET `/ComputeNodes` + + Get a list of available compute nodes. +- GET `/ComputeNodes/{nodeName}` + + Get the properties of a single compute node. +- PUT `/ComputeNodes/{nodeName}` + + Create a new compute node. +- POST `/ComputeNodes/{nodeName}/computePi` + + Start a compute pi operation on a compute node. +- GET `/operation/{operationId}` + + Get the compute operation status. + +### Model types +- `ComputeNode` + + Base compute node object. +- `LinuxComputeNote` + + A Linux flavour of the compute node object. + +- `WindowsComputeNode` + + A Windows flavour of the compute node object. + +- `PageOfComputeNodes` + + A collection type that holds a list of compute nodes. + +- `Operation` + + Properties, including the status on a service-side operation. +- `Error` + + A complex error structure that contains information for a failed request. + diff --git a/sdk/api-learn/azure-computation/azure/__init__.py b/sdk/api-learn/azure-computation/azure/__init__.py new file mode 100644 index 000000000000..e7590fb185e8 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/__init__.py @@ -0,0 +1,7 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/api-learn/azure-computation/azure/computation/__init__.py b/sdk/api-learn/azure-computation/azure/computation/__init__.py new file mode 100644 index 000000000000..fab91bee1374 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/__init__.py @@ -0,0 +1,10 @@ +# 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 ._version import VERSION + + +__version__ = VERSION diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/__init__.py b/sdk/api-learn/azure-computation/azure/computation/_generated/__init__.py new file mode 100644 index 000000000000..e9258adcb225 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/__init__.py @@ -0,0 +1,16 @@ +# 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 ._exampleservice import ExampleService +__all__ = ['ExampleService'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/_configuration.py b/sdk/api-learn/azure-computation/azure/computation/_generated/_configuration.py new file mode 100644 index 000000000000..e8d03ed7227a --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/_configuration.py @@ -0,0 +1,74 @@ +# 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 typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class ExampleServiceConfiguration(Configuration): + """Configuration for ExampleService. + + 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 + :param node_name: + :type node_name: str + :param x_ms_client_request_id: Optional client-provided request id. + :type x_ms_client_request_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + node_name, # type: str + x_ms_client_request_id=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if node_name is None: + raise ValueError("Parameter 'node_name' must not be None.") + super(ExampleServiceConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.node_name = node_name + self.x_ms_client_request_id = x_ms_client_request_id + self.credential_scopes = kwargs.pop('credential_scopes', []) + kwargs.setdefault('sdk_moniker', 'exampleservice/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if not self.credential_scopes and not self.authentication_policy: + raise ValueError("You must provide either credential_scopes or authentication_policy as kwargs") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/_exampleservice.py b/sdk/api-learn/azure-computation/azure/computation/_generated/_exampleservice.py new file mode 100644 index 000000000000..1477b7d53231 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/_exampleservice.py @@ -0,0 +1,75 @@ +# 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 typing import TYPE_CHECKING + +from azure.core import PipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + +from ._configuration import ExampleServiceConfiguration +from .operations import ComputeNodeAdministrationOperations +from .operations import ComputationOperations +from .operations import ExampleServiceOperationsMixin +from . import models + + +class ExampleService(ExampleServiceOperationsMixin): + """ExampleService. + + :ivar compute_node_administration: ComputeNodeAdministrationOperations operations + :vartype compute_node_administration: azure.computation.operations.ComputeNodeAdministrationOperations + :ivar computation: ComputationOperations operations + :vartype computation: azure.computation.operations.ComputationOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param node_name: + :type node_name: str + :param x_ms_client_request_id: Optional client-provided request id. + :type x_ms_client_request_id: str + :param str base_url: Service URL + """ + + def __init__( + self, + credential, # type: "TokenCredential" + node_name, # type: str + x_ms_client_request_id=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + base_url = 'None' + self._config = ExampleServiceConfiguration(credential, node_name, x_ms_client_request_id, **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._deserialize = Deserializer(client_models) + + self.compute_node_administration = ComputeNodeAdministrationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.computation = ComputationOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ExampleService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/aio/__init__.py b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/__init__.py new file mode 100644 index 000000000000..78a26ceae818 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 ._exampleservice_async import ExampleService +__all__ = ['ExampleService'] diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/aio/_configuration_async.py b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/_configuration_async.py new file mode 100644 index 000000000000..1efe6fd56002 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/_configuration_async.py @@ -0,0 +1,70 @@ +# 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 typing import Any, Optional, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class ExampleServiceConfiguration(Configuration): + """Configuration for ExampleService. + + 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_async.AsyncTokenCredential + :param node_name: + :type node_name: str + :param x_ms_client_request_id: Optional client-provided request id. + :type x_ms_client_request_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + node_name: str, + x_ms_client_request_id: Optional[str] = None, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if node_name is None: + raise ValueError("Parameter 'node_name' must not be None.") + super(ExampleServiceConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.node_name = node_name + self.x_ms_client_request_id = x_ms_client_request_id + self.credential_scopes = kwargs.pop('credential_scopes', []) + kwargs.setdefault('sdk_moniker', 'exampleservice/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if not self.credential_scopes and not self.authentication_policy: + raise ValueError("You must provide either credential_scopes or authentication_policy as kwargs") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/aio/_exampleservice_async.py b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/_exampleservice_async.py new file mode 100644 index 000000000000..02e8eef236fd --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/_exampleservice_async.py @@ -0,0 +1,69 @@ +# 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 typing import Any, Optional, 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 ._configuration_async import ExampleServiceConfiguration +from .operations_async import ComputeNodeAdministrationOperations +from .operations_async import ComputationOperations +from .operations_async import ExampleServiceOperationsMixin +from .. import models + + +class ExampleService(ExampleServiceOperationsMixin): + """ExampleService. + + :ivar compute_node_administration: ComputeNodeAdministrationOperations operations + :vartype compute_node_administration: azure.computation.aio.operations_async.ComputeNodeAdministrationOperations + :ivar computation: ComputationOperations operations + :vartype computation: azure.computation.aio.operations_async.ComputationOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param node_name: + :type node_name: str + :param x_ms_client_request_id: Optional client-provided request id. + :type x_ms_client_request_id: str + :param str base_url: Service URL + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + node_name: str, + x_ms_client_request_id: Optional[str] = None, + **kwargs: Any + ) -> None: + base_url = 'None' + self._config = ExampleServiceConfiguration(credential, node_name, x_ms_client_request_id, **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._deserialize = Deserializer(client_models) + + self.compute_node_administration = ComputeNodeAdministrationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.computation = ComputationOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ExampleService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/aio/operations_async/__init__.py b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/operations_async/__init__.py new file mode 100644 index 000000000000..6ac289982c08 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/operations_async/__init__.py @@ -0,0 +1,17 @@ +# 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 ._compute_node_administration_operations_async import ComputeNodeAdministrationOperations +from ._computation_operations_async import ComputationOperations +from ._exampleservice_operations_async import ExampleServiceOperationsMixin + +__all__ = [ + 'ComputeNodeAdministrationOperations', + 'ComputationOperations', + 'ExampleServiceOperationsMixin', +] diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/aio/operations_async/_computation_operations_async.py b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/operations_async/_computation_operations_async.py new file mode 100644 index 000000000000..83b2c3963aae --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/operations_async/_computation_operations_async.py @@ -0,0 +1,91 @@ +# 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 typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ComputationOperations: + """ComputationOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.computation.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def compute_pi( + self, + precision: Optional[int] = 17, + **kwargs + ) -> None: + """compute_pi. + + :param precision: + :type precision: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.compute_pi.metadata['url'] # type: ignore + path_format_arguments = { + 'nodeName': self._serialize.url("self._config.node_name", self._config.node_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if precision is not None: + query_parameters['precision'] = self._serialize.query("precision", precision, 'int', minimum=0) + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.x_ms_client_request_id is not None: + header_parameters['x-ms-client-request-id'] = self._serialize.header("self._config.x_ms_client_request_id", self._config.x_ms_client_request_id, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + + if cls: + return cls(pipeline_response, None, response_headers) + + compute_pi.metadata = {'url': '/ComputeNodes/{nodeName}/computePi'} # type: ignore diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/aio/operations_async/_compute_node_administration_operations_async.py b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/operations_async/_compute_node_administration_operations_async.py new file mode 100644 index 000000000000..e89978727564 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/operations_async/_compute_node_administration_operations_async.py @@ -0,0 +1,200 @@ +# 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 typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ComputeNodeAdministrationOperations: + """ComputeNodeAdministrationOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.computation.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list( + self, + **kwargs + ) -> "models.PageOfComputeNodes": + """list. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PageOfComputeNodes, or the result of cls(response) + :rtype: ~azure.computation.models.PageOfComputeNodes + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PageOfComputeNodes"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.list.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.x_ms_client_request_id is not None: + header_parameters['x-ms-client-request-id'] = self._serialize.header("self._config.x_ms_client_request_id", self._config.x_ms_client_request_id, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize('object', response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('PageOfComputeNodes', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/ComputeNodes'} # type: ignore + + async def create( + self, + if_match: Optional[str] = None, + compute_node: Optional["models.ComputeNode"] = None, + **kwargs + ) -> "models.ComputeNode": + """create. + + :param if_match: + :type if_match: str + :param compute_node: + :type compute_node: ~azure.computation.models.ComputeNode + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ComputeNode, or the result of cls(response) + :rtype: ~azure.computation.models.ComputeNode + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ComputeNode"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'nodeName': self._serialize.url("self._config.node_name", self._config.node_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.x_ms_client_request_id is not None: + header_parameters['x-ms-client-request-id'] = self._serialize.header("self._config.x_ms_client_request_id", self._config.x_ms_client_request_id, 'str') + if if_match is not None: + header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + if compute_node is not None: + body_content = self._serialize.body(compute_node, 'ComputeNode') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize('object', response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize('ComputeNode', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ComputeNode', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/ComputeNodes/{nodeName}'} # type: ignore + + async def get( + self, + **kwargs + ) -> "models.ComputeNode": + """get. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ComputeNode, or the result of cls(response) + :rtype: ~azure.computation.models.ComputeNode + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ComputeNode"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'nodeName': self._serialize.url("self._config.node_name", self._config.node_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.x_ms_client_request_id is not None: + header_parameters['x-ms-client-request-id'] = self._serialize.header("self._config.x_ms_client_request_id", self._config.x_ms_client_request_id, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('ComputeNode', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/ComputeNodes/{nodeName}'} # type: ignore diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/aio/operations_async/_exampleservice_operations_async.py b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/operations_async/_exampleservice_operations_async.py new file mode 100644 index 000000000000..ae0899c5a173 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/aio/operations_async/_exampleservice_operations_async.py @@ -0,0 +1,72 @@ +# 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 typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ExampleServiceOperationsMixin: + + async def computation( + self, + operation_id: str, + **kwargs + ) -> "models.Operation": + """computation. + + :param operation_id: + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Operation, or the result of cls(response) + :rtype: ~azure.computation.models.Operation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Operation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.computation.metadata['url'] # type: ignore + path_format_arguments = { + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.x_ms_client_request_id is not None: + header_parameters['x-ms-client-request-id'] = self._serialize.header("self._config.x_ms_client_request_id", self._config.x_ms_client_request_id, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + deserialized = self._deserialize('Operation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + computation.metadata = {'url': '/operations/{operationId}'} # type: ignore diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/models/__init__.py b/sdk/api-learn/azure-computation/azure/computation/_generated/models/__init__.py new file mode 100644 index 000000000000..f6b2455498eb --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/models/__init__.py @@ -0,0 +1,33 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import ComputeNode + from ._models_py3 import LinuxComputeNode + from ._models_py3 import Operation + from ._models_py3 import PageOfComputeNodes + from ._models_py3 import WindowsComputeNode +except (SyntaxError, ImportError): + from ._models import ComputeNode # type: ignore + from ._models import LinuxComputeNode # type: ignore + from ._models import Operation # type: ignore + from ._models import PageOfComputeNodes # type: ignore + from ._models import WindowsComputeNode # type: ignore + +from ._exampleservice_enums import ( + OperationStatus, +) + +__all__ = [ + 'ComputeNode', + 'LinuxComputeNode', + 'Operation', + 'PageOfComputeNodes', + 'WindowsComputeNode', + 'OperationStatus', +] diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/models/_exampleservice_enums.py b/sdk/api-learn/azure-computation/azure/computation/_generated/models/_exampleservice_enums.py new file mode 100644 index 000000000000..d82613b8699a --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/models/_exampleservice_enums.py @@ -0,0 +1,35 @@ +# 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 enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class OperationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + NOTSTARTED = "notstarted" + RUNNING = "running" + SUCCEEDED = "succeeded" + FAILED = "failed" + CANCELLED = "cancelled" diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/models/_models.py b/sdk/api-learn/azure-computation/azure/computation/_generated/models/_models.py new file mode 100644 index 000000000000..aff5d5b6ba79 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/models/_models.py @@ -0,0 +1,198 @@ +# 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. +# -------------------------------------------------------------------------- + +import msrest.serialization + + +class ComputeNode(msrest.serialization.Model): + """ComputeNode. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: LinuxComputeNode, WindowsComputeNode. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar e_tag: + :vartype e_tag: str + :ivar name: + :vartype name: str + :param kind: Required. Constant filled by server. + :type kind: str + """ + + _validation = { + 'e_tag': {'readonly': True}, + 'name': {'readonly': True}, + 'kind': {'required': True}, + } + + _attribute_map = { + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + } + + _subtype_map = { + 'kind': {'LinuxComputeNode': 'LinuxComputeNode', 'WindowsComputeNode': 'WindowsComputeNode'} + } + + def __init__( + self, + **kwargs + ): + super(ComputeNode, self).__init__(**kwargs) + self.e_tag = None + self.name = None + self.kind = None # type: Optional[str] + + +class LinuxComputeNode(ComputeNode): + """LinuxComputeNode. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar e_tag: + :vartype e_tag: str + :ivar name: + :vartype name: str + :param kind: Required. Constant filled by server. + :type kind: str + :param ssh_public_key: Required. + :type ssh_public_key: str + """ + + _validation = { + 'e_tag': {'readonly': True}, + 'name': {'readonly': True}, + 'kind': {'required': True}, + 'ssh_public_key': {'required': True}, + } + + _attribute_map = { + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'ssh_public_key': {'key': 'sshPublicKey', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LinuxComputeNode, self).__init__(**kwargs) + self.kind = 'LinuxComputeNode' # type: str + self.ssh_public_key = kwargs['ssh_public_key'] + + +class Operation(msrest.serialization.Model): + """Operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar created_date_time: + :vartype created_date_time: ~datetime.datetime + :ivar percent_complete: + :vartype percent_complete: float + :ivar status: Possible values include: "notstarted", "running", "succeeded", "failed", + "cancelled". + :vartype status: str or ~azure.computation.models.OperationStatus + """ + + _validation = { + 'created_date_time': {'readonly': True}, + 'percent_complete': {'readonly': True, 'maximum': 100, 'minimum': 0}, + 'status': {'readonly': True}, + } + + _attribute_map = { + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'percent_complete': {'key': 'percentComplete', 'type': 'float'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.created_date_time = None + self.percent_complete = None + self.status = None + + +class PageOfComputeNodes(msrest.serialization.Model): + """PageOfComputeNodes. + + All required parameters must be populated in order to send to Azure. + + :param value: Required. + :type value: list[~azure.computation.models.ComputeNode] + :param next_link: + :type next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ComputeNode]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PageOfComputeNodes, self).__init__(**kwargs) + self.value = kwargs['value'] + self.next_link = kwargs.get('next_link', None) + + +class WindowsComputeNode(ComputeNode): + """WindowsComputeNode. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar e_tag: + :vartype e_tag: str + :ivar name: + :vartype name: str + :param kind: Required. Constant filled by server. + :type kind: str + :param user_name: Required. + :type user_name: str + """ + + _validation = { + 'e_tag': {'readonly': True}, + 'name': {'readonly': True}, + 'kind': {'required': True}, + 'user_name': {'required': True}, + } + + _attribute_map = { + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'user_name': {'key': 'userName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(WindowsComputeNode, self).__init__(**kwargs) + self.kind = 'WindowsComputeNode' # type: str + self.user_name = kwargs['user_name'] diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/models/_models_py3.py b/sdk/api-learn/azure-computation/azure/computation/_generated/models/_models_py3.py new file mode 100644 index 000000000000..12a31452d038 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/models/_models_py3.py @@ -0,0 +1,207 @@ +# 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 typing import List, Optional + +import msrest.serialization + + +class ComputeNode(msrest.serialization.Model): + """ComputeNode. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: LinuxComputeNode, WindowsComputeNode. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar e_tag: + :vartype e_tag: str + :ivar name: + :vartype name: str + :param kind: Required. Constant filled by server. + :type kind: str + """ + + _validation = { + 'e_tag': {'readonly': True}, + 'name': {'readonly': True}, + 'kind': {'required': True}, + } + + _attribute_map = { + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + } + + _subtype_map = { + 'kind': {'LinuxComputeNode': 'LinuxComputeNode', 'WindowsComputeNode': 'WindowsComputeNode'} + } + + def __init__( + self, + **kwargs + ): + super(ComputeNode, self).__init__(**kwargs) + self.e_tag = None + self.name = None + self.kind = None # type: Optional[str] + + +class LinuxComputeNode(ComputeNode): + """LinuxComputeNode. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar e_tag: + :vartype e_tag: str + :ivar name: + :vartype name: str + :param kind: Required. Constant filled by server. + :type kind: str + :param ssh_public_key: Required. + :type ssh_public_key: str + """ + + _validation = { + 'e_tag': {'readonly': True}, + 'name': {'readonly': True}, + 'kind': {'required': True}, + 'ssh_public_key': {'required': True}, + } + + _attribute_map = { + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'ssh_public_key': {'key': 'sshPublicKey', 'type': 'str'}, + } + + def __init__( + self, + *, + ssh_public_key: str, + **kwargs + ): + super(LinuxComputeNode, self).__init__(**kwargs) + self.kind = 'LinuxComputeNode' # type: str + self.ssh_public_key = ssh_public_key + + +class Operation(msrest.serialization.Model): + """Operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar created_date_time: + :vartype created_date_time: ~datetime.datetime + :ivar percent_complete: + :vartype percent_complete: float + :ivar status: Possible values include: "notstarted", "running", "succeeded", "failed", + "cancelled". + :vartype status: str or ~azure.computation.models.OperationStatus + """ + + _validation = { + 'created_date_time': {'readonly': True}, + 'percent_complete': {'readonly': True, 'maximum': 100, 'minimum': 0}, + 'status': {'readonly': True}, + } + + _attribute_map = { + 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, + 'percent_complete': {'key': 'percentComplete', 'type': 'float'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.created_date_time = None + self.percent_complete = None + self.status = None + + +class PageOfComputeNodes(msrest.serialization.Model): + """PageOfComputeNodes. + + All required parameters must be populated in order to send to Azure. + + :param value: Required. + :type value: list[~azure.computation.models.ComputeNode] + :param next_link: + :type next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ComputeNode]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["ComputeNode"], + next_link: Optional[str] = None, + **kwargs + ): + super(PageOfComputeNodes, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class WindowsComputeNode(ComputeNode): + """WindowsComputeNode. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar e_tag: + :vartype e_tag: str + :ivar name: + :vartype name: str + :param kind: Required. Constant filled by server. + :type kind: str + :param user_name: Required. + :type user_name: str + """ + + _validation = { + 'e_tag': {'readonly': True}, + 'name': {'readonly': True}, + 'kind': {'required': True}, + 'user_name': {'required': True}, + } + + _attribute_map = { + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'user_name': {'key': 'userName', 'type': 'str'}, + } + + def __init__( + self, + *, + user_name: str, + **kwargs + ): + super(WindowsComputeNode, self).__init__(**kwargs) + self.kind = 'WindowsComputeNode' # type: str + self.user_name = user_name diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/operations/__init__.py b/sdk/api-learn/azure-computation/azure/computation/_generated/operations/__init__.py new file mode 100644 index 000000000000..882d836aeac3 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/operations/__init__.py @@ -0,0 +1,17 @@ +# 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 ._compute_node_administration_operations import ComputeNodeAdministrationOperations +from ._computation_operations import ComputationOperations +from ._exampleservice_operations import ExampleServiceOperationsMixin + +__all__ = [ + 'ComputeNodeAdministrationOperations', + 'ComputationOperations', + 'ExampleServiceOperationsMixin', +] diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/operations/_computation_operations.py b/sdk/api-learn/azure-computation/azure/computation/_generated/operations/_computation_operations.py new file mode 100644 index 000000000000..145d62a3c198 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/operations/_computation_operations.py @@ -0,0 +1,96 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ComputationOperations(object): + """ComputationOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.computation.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def compute_pi( + self, + precision=17, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> None + """compute_pi. + + :param precision: + :type precision: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.compute_pi.metadata['url'] # type: ignore + path_format_arguments = { + 'nodeName': self._serialize.url("self._config.node_name", self._config.node_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if precision is not None: + query_parameters['precision'] = self._serialize.query("precision", precision, 'int', minimum=0) + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.x_ms_client_request_id is not None: + header_parameters['x-ms-client-request-id'] = self._serialize.header("self._config.x_ms_client_request_id", self._config.x_ms_client_request_id, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) + + if cls: + return cls(pipeline_response, None, response_headers) + + compute_pi.metadata = {'url': '/ComputeNodes/{nodeName}/computePi'} # type: ignore diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/operations/_compute_node_administration_operations.py b/sdk/api-learn/azure-computation/azure/computation/_generated/operations/_compute_node_administration_operations.py new file mode 100644 index 000000000000..54a62daf9eb0 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/operations/_compute_node_administration_operations.py @@ -0,0 +1,207 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ComputeNodeAdministrationOperations(object): + """ComputeNodeAdministrationOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.computation.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> "models.PageOfComputeNodes" + """list. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PageOfComputeNodes, or the result of cls(response) + :rtype: ~azure.computation.models.PageOfComputeNodes + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PageOfComputeNodes"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.list.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.x_ms_client_request_id is not None: + header_parameters['x-ms-client-request-id'] = self._serialize.header("self._config.x_ms_client_request_id", self._config.x_ms_client_request_id, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize('object', response) + raise HttpResponseError(response=response, model=error) + + deserialized = self._deserialize('PageOfComputeNodes', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/ComputeNodes'} # type: ignore + + def create( + self, + if_match=None, # type: Optional[str] + compute_node=None, # type: Optional["models.ComputeNode"] + **kwargs # type: Any + ): + # type: (...) -> "models.ComputeNode" + """create. + + :param if_match: + :type if_match: str + :param compute_node: + :type compute_node: ~azure.computation.models.ComputeNode + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ComputeNode, or the result of cls(response) + :rtype: ~azure.computation.models.ComputeNode + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ComputeNode"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'nodeName': self._serialize.url("self._config.node_name", self._config.node_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.x_ms_client_request_id is not None: + header_parameters['x-ms-client-request-id'] = self._serialize.header("self._config.x_ms_client_request_id", self._config.x_ms_client_request_id, 'str') + if if_match is not None: + header_parameters['if-match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + if compute_node is not None: + body_content = self._serialize.body(compute_node, 'ComputeNode') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize('object', response) + raise HttpResponseError(response=response, model=error) + + if response.status_code == 200: + deserialized = self._deserialize('ComputeNode', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ComputeNode', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/ComputeNodes/{nodeName}'} # type: ignore + + def get( + self, + **kwargs # type: Any + ): + # type: (...) -> "models.ComputeNode" + """get. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ComputeNode, or the result of cls(response) + :rtype: ~azure.computation.models.ComputeNode + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ComputeNode"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'nodeName': self._serialize.url("self._config.node_name", self._config.node_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.x_ms_client_request_id is not None: + header_parameters['x-ms-client-request-id'] = self._serialize.header("self._config.x_ms_client_request_id", self._config.x_ms_client_request_id, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + deserialized = self._deserialize('ComputeNode', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/ComputeNodes/{nodeName}'} # type: ignore diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/operations/_exampleservice_operations.py b/sdk/api-learn/azure-computation/azure/computation/_generated/operations/_exampleservice_operations.py new file mode 100644 index 000000000000..18d3b56ddeee --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/operations/_exampleservice_operations.py @@ -0,0 +1,77 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ExampleServiceOperationsMixin(object): + + def computation( + self, + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Operation" + """computation. + + :param operation_id: + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Operation, or the result of cls(response) + :rtype: ~azure.computation.models.Operation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Operation"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + + # Construct URL + url = self.computation.metadata['url'] # type: ignore + path_format_arguments = { + 'operationId': self._serialize.url("operation_id", operation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.x_ms_client_request_id is not None: + header_parameters['x-ms-client-request-id'] = self._serialize.header("self._config.x_ms_client_request_id", self._config.x_ms_client_request_id, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + deserialized = self._deserialize('Operation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + computation.metadata = {'url': '/operations/{operationId}'} # type: ignore diff --git a/sdk/api-learn/azure-computation/azure/computation/_generated/py.typed b/sdk/api-learn/azure-computation/azure/computation/_generated/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_generated/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/api-learn/azure-computation/azure/computation/_version.py b/sdk/api-learn/azure-computation/azure/computation/_version.py new file mode 100644 index 000000000000..7f78a21da1f9 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/_version.py @@ -0,0 +1,7 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = '0.0.1' \ No newline at end of file diff --git a/sdk/api-learn/azure-computation/azure/computation/aio/__init__.py b/sdk/api-learn/azure-computation/azure/computation/aio/__init__.py new file mode 100644 index 000000000000..006671542af8 --- /dev/null +++ b/sdk/api-learn/azure-computation/azure/computation/aio/__init__.py @@ -0,0 +1,5 @@ +# 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. +# -------------------------------------------------------------------------- diff --git a/sdk/api-learn/azure-computation/dev_requirements.txt b/sdk/api-learn/azure-computation/dev_requirements.txt new file mode 100644 index 000000000000..2a41134e0e0d --- /dev/null +++ b/sdk/api-learn/azure-computation/dev_requirements.txt @@ -0,0 +1,7 @@ +../../core/azure-core +-e ../../../tools/azure-devtools +-e ../../../tools/azure-sdk-tools +-e ../../identity/azure-identity +aiohttp>=3.0; python_version >= '3.5' +aiodns>=2.0; python_version >= '3.5' +msrest>=0.6.10 diff --git a/sdk/api-learn/azure-computation/sdk_packaging.toml b/sdk/api-learn/azure-computation/sdk_packaging.toml new file mode 100644 index 000000000000..b366f78fb41b --- /dev/null +++ b/sdk/api-learn/azure-computation/sdk_packaging.toml @@ -0,0 +1,4 @@ +[packaging] +is_arm = false +need_msrestazure = false +auto_update = false diff --git a/sdk/api-learn/azure-computation/setup.cfg b/sdk/api-learn/azure-computation/setup.cfg new file mode 100644 index 000000000000..3c6e79cf31da --- /dev/null +++ b/sdk/api-learn/azure-computation/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/sdk/api-learn/azure-computation/setup.py b/sdk/api-learn/azure-computation/setup.py new file mode 100644 index 000000000000..acb4cd648ffe --- /dev/null +++ b/sdk/api-learn/azure-computation/setup.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import sys +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-computation" +PACKAGE_PPRINT_NAME = "Computation Training SDK" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +exclude_packages = [ + 'tests', + 'tests.*', + 'samples', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + ] +if sys.version_info < (3, 5, 3): + exclude_packages.extend([ + '*.aio', + '*.aio.*' + ]) + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft {} Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/appconfiguration/azure-appconfiguration', + classifiers=[ + "Development Status :: 5 - Production/Stable", + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=exclude_packages), + install_requires=[ + "msrest>=0.6.10", + "azure-core<2.0.0,>=1.0.0", + ], + extras_require={ + ":python_version<'3.0'": ['azure-nspkg'], + ":python_version<'3.4'": ['enum34>=1.0.4'], + ":python_version<'3.5'": ['typing'], + "async:python_version>='3.5'": [ + 'aiohttp>=3.0', + 'aiodns>=2.0' + ], + } +) \ No newline at end of file diff --git a/sdk/api-learn/azure-computation/swagger/README.md b/sdk/api-learn/azure-computation/swagger/README.md new file mode 100644 index 000000000000..d8b97f1f799d --- /dev/null +++ b/sdk/api-learn/azure-computation/swagger/README.md @@ -0,0 +1,24 @@ +# Azure Queue Storage for Python + +> see https://aka.ms/autorest + + +### Generation +```ps +cd +autorest README.md --use=@autorest/python@5.1.0-preview.7 +``` + +### Settings +```yaml +input-file: computation.json +output-folder: ../azure/computation/_generated +namespace: azure.computation +no-namespace-folders: true +license-header: MICROSOFT_MIT_NO_VERSION +enable-xml: false +vanilla: true +clear-output-folder: true +add-credentials: true +python: true +``` diff --git a/sdk/api-learn/azure-computation/swagger/computation.json b/sdk/api-learn/azure-computation/swagger/computation.json new file mode 100644 index 000000000000..0b03d68a54e8 --- /dev/null +++ b/sdk/api-learn/azure-computation/swagger/computation.json @@ -0,0 +1,281 @@ +{ + "swagger": "2.0", + "info": { + "title": "Example service", + "version": "1.1" + }, + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "paths": { + "/ComputeNodes": { + "parameters": [ + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "get": { + "operationId": "ComputeNodeAdministration_List", + "tags": [ "Administration" ], + "responses": { + "200": { + "description": "Successfully listed (one page of) ComputeNodes", + "schema": { + "$ref": "#/definitions/PageOfComputeNodes" + } + }, + "default": { + "description": "Failed to get ComputeNodes", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/ComputeNodes/{nodeName}": { + "parameters": [ + { + "$ref": "#/parameters/ClientRequestId" + }, + { + "$ref": "#/parameters/NodeName" + } + ], + "put": { + "operationId": "ComputeNodeAdministration_Create", + "tags": [ "Administration" ], + "parameters": [ + { + "name": "computeNode", + "in": "body", + "schema": { + "$ref": "#/definitions/ComputeNode" + } + }, + { + "name": "if-match", + "in": "header", + "type": "string" + } + ], + "responses": { + "201": { + "description": "Successfully created a new ComputeNode", + "schema": { + "$ref": "#/definitions/ComputeNode" + } + }, + "200": { + "description": "Successfully replace an existing ComputeNode", + "schema": { + "$ref": "#/definitions/ComputeNode" + } + }, + "default": { + "description": "Something went wrong", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + }, + "get": { + "operationId": "ComputeNodeAdministration_Get", + "tags": [ "Administration" ], + "responses": { + "200": { + "description": "Successfully got the computeNode", + "schema": { + "$ref": "#/definitions/ComputeNode" + } + } + } + } + }, + "/ComputeNodes/{nodeName}/computePi": { + "parameters": [ + { + "$ref": "#/parameters/ClientRequestId" + }, + { + "$ref": "#/parameters/NodeName" + } + ], + "post": { + "operationId": "Computation_ComputePi", + "tags": [ "Computation" ], + "parameters": [ + { + "name": "precision", + "in": "query", + "type": "integer", + "default": 17, + "minimum": 0 + } + ], + "responses": { + "202": { + "description": "Started long running process", + "headers": { + "Operation-Location": { + "description": "This will point to an operation (/operations/{operationId}) that can be used to monitor the progress", + "type": "string", + "format": "uri" + } + } + } + } + } + }, + "/operations/{operationId}": { + "parameters": [ + { + "name": "operationId", + "type": "string", + "in": "path", + "required": true + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "get": { + "tags": [ "Computation" ], + "responses": { + "200": { + "description": "Successfully got the operation status", + "headers": { + "Location": { + "type": "string", + "format": "uri" + } + }, + "schema": { + "$ref": "#/definitions/Operation" + } + } + } + } + } + }, + "parameters": { + "NodeName": { + "name": "nodeName", + "in": "path", + "type": "string", + "required": true + }, + "ClientRequestId": { + "in": "header", + "type": "string", + "required": false, + "name": "x-ms-client-request-id", + "description": "Optional client-provided request id" + } + }, + "definitions": { + "Error": { + "type": "object" + }, + "PageOfComputeNodes": { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "array", + "items": { + "$ref": "#/definitions/ComputeNode" + } + }, + "nextLink": { + "type": "string" + } + } + }, + "ComputeNode": { + "type": "object", + "required": [ + "kind" + ], + "discriminator": "kind", + "properties": { + "eTag": { + "readOnly": true, + "type": "string" + }, + "name": { + "readOnly": true, + "type": "string" + }, + "kind": { + "type": "string" + } + } + }, + "LinuxComputeNode": { + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/ComputeNode" + } + ], + "required": [ + "sshPublicKey" + ], + "properties": { + "sshPublicKey": { + "type": "string" + } + } + }, + "WindowsComputeNode": { + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/ComputeNode" + } + ], + "required": [ + "userName" + ], + "properties": { + "userName": { + "type": "string" + } + } + }, + "Operation": { + "type": "object", + "properties": { + "createdDateTime": { + "readOnly": true, + "type": "string", + "format": "date-time" + }, + "percentComplete": { + "readOnly": true, + "type": "number", + "minimum": 0, + "maximum": 100 + }, + "status": { + "type": "string", + "readOnly": true, + "enum": [ + "notstarted", + "running", + "succeeded", + "failed", + "cancelled" + ] + } + } + } + } +} \ No newline at end of file diff --git a/sdk/api-learn/azure-learnappconfig/CHANGELOG.md b/sdk/api-learn/azure-learnappconfig/CHANGELOG.md new file mode 100644 index 000000000000..816f21db092e --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/CHANGELOG.md @@ -0,0 +1,8 @@ + +# Release History + +------------------- + +## 0.0.1 (Unreleased) + +- Training day! diff --git a/sdk/api-learn/azure-learnappconfig/MANIFEST.in b/sdk/api-learn/azure-learnappconfig/MANIFEST.in new file mode 100644 index 000000000000..7ebdd947f8ff --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/MANIFEST.in @@ -0,0 +1,4 @@ +recursive-include tests *.py +include *.md +include azure/__init__.py +recursive-include samples *.py *.md diff --git a/sdk/api-learn/azure-learnappconfig/README.md b/sdk/api-learn/azure-learnappconfig/README.md new file mode 100644 index 000000000000..c5012d4038c9 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/README.md @@ -0,0 +1,38 @@ +# Azure App Configuration client library for Python SDK Training + +Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely. + +Modern programs, especially programs running in a cloud, generally have many components that are distributed in nature. Spreading configuration settings across these components can lead to hard-to-troubleshoot errors during an application deployment. Use App Configuration to securely store all the settings for your application in one place. + +Use the client library for App Configuration to create and manage application configuration settings. + +## Prerequisites + +* Python 2.7, or 3.5 or later is required to use this package. +* You need an [Azure subscription][azure_sub], and a [Configuration Store][configuration_store] to use this package. + +To create a Configuration Store, you can use the Azure Portal or [Azure CLI][azure_cli]. + +After that, create the Configuration Store: + +```Powershell +az appconfig create --name --resource-group --location eastus +``` + + +## Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, +see the Code of Conduct FAQ or contact opencode@microsoft.com with any +additional questions or comments. diff --git a/sdk/api-learn/azure-learnappconfig/azure/__init__.py b/sdk/api-learn/azure-learnappconfig/azure/__init__.py new file mode 100644 index 000000000000..e7590fb185e8 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/__init__.py @@ -0,0 +1,7 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/__init__.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/__init__.py new file mode 100644 index 000000000000..0a6d3d2ca2bd --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/__init__.py @@ -0,0 +1,19 @@ +# 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 ._version import VERSION +from ._client import AppConfigurationClient +from ._models import ConfigurationSetting +from ._generated.models import SettingFields + + +__all__ = [ + 'AppConfigurationClient', + 'ConfigurationSetting', + 'SettingFields' +] + +__version__ = VERSION diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_client.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_client.py new file mode 100644 index 000000000000..e24048c24941 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_client.py @@ -0,0 +1,44 @@ +# 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 datetime import datetime + +from ._models import ConfigurationSetting + + +class AppConfigurationClient(object): + """A Client for the AppConfiguration Service. + + :param str account_url: The URL for the service. + :param TokenCredential credential: The credentials to authenticate with the service. + """ + + def __init__(self, account_url, credential, **kwargs): + # type: (str, TokenCredential) -> None + pass + + @classmethod + def from_connection_string(cls, connection_string, **kwargs): + # type: (str) -> AppConfigurationClient + """Build an AppConfigurationClient from a connection string. + + :param str connection_string: A connection string, as retrieved + from the Azure portal. + """ + pass + + def get_configuration_setting(self, key, label=None, **kwargs): + # type: (str, Optional[str]) -> ConfigurationSetting + """Get the value of a particular configuration settings. + + :param str key: The key name of the setting. + :param str label: The label of the setting. + :keyword datetime accept_datetime: The last modified date filter. + :keyword select: The specific properties of the setting that should be returned. + :paramtype select: List[Union[str, ~azure.learnappconfig.SettingFields]] + :raises ~azure.core.exceptions.ResourceNotFoundError: If no matching configuration setting exists. + """ + pass diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/__init__.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/__init__.py new file mode 100644 index 000000000000..2f2c56bbc2b3 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/__init__.py @@ -0,0 +1,19 @@ +# 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 ._azure_app_configuration import AzureAppConfiguration +from ._version import VERSION + +__version__ = VERSION +__all__ = ['AzureAppConfiguration'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/_azure_app_configuration.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/_azure_app_configuration.py new file mode 100644 index 000000000000..17bf12eba058 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/_azure_app_configuration.py @@ -0,0 +1,64 @@ +# 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 typing import TYPE_CHECKING + +from azure.core import PipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + +from ._configuration import AzureAppConfigurationConfiguration +from .operations import AzureAppConfigurationOperationsMixin +from . import models + + +class AzureAppConfiguration(AzureAppConfigurationOperationsMixin): + """AzureAppConfiguration. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param endpoint: The endpoint of the App Configuration instance to send requests to. + :type endpoint: str + :param sync_token: Used to guarantee real-time consistency between requests. + :type sync_token: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + endpoint, # type: str + sync_token=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + base_url = '{endpoint}' + self._config = AzureAppConfigurationConfiguration(credential, endpoint, sync_token, **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._deserialize = Deserializer(client_models) + + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AzureAppConfiguration + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/_configuration.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/_configuration.py new file mode 100644 index 000000000000..2df5c5922b45 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/_configuration.py @@ -0,0 +1,76 @@ +# 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 typing import TYPE_CHECKING + +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, Optional + + from azure.core.credentials import TokenCredential + + +class AzureAppConfigurationConfiguration(Configuration): + """Configuration for AzureAppConfiguration. + + 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 + :param endpoint: The endpoint of the App Configuration instance to send requests to. + :type endpoint: str + :param sync_token: Used to guarantee real-time consistency between requests. + :type sync_token: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + endpoint, # type: str + sync_token=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + super(AzureAppConfigurationConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.endpoint = endpoint + self.sync_token = sync_token + self.api_version = "1.0" + self.credential_scopes = kwargs.pop('credential_scopes', []) + kwargs.setdefault('sdk_moniker', 'azureappconfiguration/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if not self.credential_scopes and not self.authentication_policy: + raise ValueError("You must provide either credential_scopes or authentication_policy as kwargs") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/_version.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/_version.py new file mode 100644 index 000000000000..31ed98425268 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/_version.py @@ -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.0" diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/__init__.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/__init__.py new file mode 100644 index 000000000000..93d93ead1659 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 ._azure_app_configuration_async import AzureAppConfiguration +__all__ = ['AzureAppConfiguration'] diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/_azure_app_configuration_async.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/_azure_app_configuration_async.py new file mode 100644 index 000000000000..f6b91ad5eeab --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/_azure_app_configuration_async.py @@ -0,0 +1,58 @@ +# 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 typing import Any, Optional, 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 ._configuration_async import AzureAppConfigurationConfiguration +from .operations_async import AzureAppConfigurationOperationsMixin +from .. import models + + +class AzureAppConfiguration(AzureAppConfigurationOperationsMixin): + """AzureAppConfiguration. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param endpoint: The endpoint of the App Configuration instance to send requests to. + :type endpoint: str + :param sync_token: Used to guarantee real-time consistency between requests. + :type sync_token: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + endpoint: str, + sync_token: Optional[str] = None, + **kwargs: Any + ) -> None: + base_url = '{endpoint}' + self._config = AzureAppConfigurationConfiguration(credential, endpoint, sync_token, **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._deserialize = Deserializer(client_models) + + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AzureAppConfiguration": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/_configuration_async.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/_configuration_async.py new file mode 100644 index 000000000000..fe0bb2d155be --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/_configuration_async.py @@ -0,0 +1,72 @@ +# 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 typing import Any, Optional, TYPE_CHECKING + +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 azure.core.credentials_async import AsyncTokenCredential + + +class AzureAppConfigurationConfiguration(Configuration): + """Configuration for AzureAppConfiguration. + + 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_async.AsyncTokenCredential + :param endpoint: The endpoint of the App Configuration instance to send requests to. + :type endpoint: str + :param sync_token: Used to guarantee real-time consistency between requests. + :type sync_token: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + endpoint: str, + sync_token: Optional[str] = None, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if endpoint is None: + raise ValueError("Parameter 'endpoint' must not be None.") + super(AzureAppConfigurationConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.endpoint = endpoint + self.sync_token = sync_token + self.api_version = "1.0" + self.credential_scopes = kwargs.pop('credential_scopes', []) + kwargs.setdefault('sdk_moniker', 'azureappconfiguration/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if not self.credential_scopes and not self.authentication_policy: + raise ValueError("You must provide either credential_scopes or authentication_policy as kwargs") + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/operations_async/__init__.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/operations_async/__init__.py new file mode 100644 index 000000000000..560a24b20915 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/operations_async/__init__.py @@ -0,0 +1,13 @@ +# 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 ._azure_app_configuration_operations_async import AzureAppConfigurationOperationsMixin + +__all__ = [ + 'AzureAppConfigurationOperationsMixin', +] diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/operations_async/_azure_app_configuration_operations_async.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/operations_async/_azure_app_configuration_operations_async.py new file mode 100644 index 000000000000..7f1e6e654823 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/aio/operations_async/_azure_app_configuration_operations_async.py @@ -0,0 +1,1182 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AzureAppConfigurationOperationsMixin: + + def get_keys( + self, + name: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.KeyListResult"]: + """Gets a list of keys. + + Gets a list of keys. + + :param name: A filter for the name of the returned keys. + :type name: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KeyListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.learnappconfig.models.KeyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.get_keys.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('KeyListResult', pipeline_response) + list_of_elem = deserialized.items + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_keys.metadata = {'url': '/keys'} # type: ignore + + async def check_keys( + self, + name: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + **kwargs + ) -> None: + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param name: A filter for the name of the returned keys. + :type name: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_keys.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_keys.metadata = {'url': '/keys'} # type: ignore + + def get_key_values( + self, + key: Optional[str] = None, + label: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + select: Optional[List[Union[str, "models.SettingFields"]]] = None, + **kwargs + ) -> AsyncIterable["models.KeyValueListResult"]: + """Gets a list of key-values. + + Gets a list of key-values. + + :param key: A filter used to match keys. + :type key: str + :param label: A filter used to match labels. + :type label: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.learnappconfig.models.SettingFields] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KeyValueListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.learnappconfig.models.KeyValueListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyValueListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.get_key_values.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if key is not None: + query_parameters['key'] = self._serialize.query("key", key, 'str') + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('KeyValueListResult', pipeline_response) + list_of_elem = deserialized.items + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_key_values.metadata = {'url': '/kv'} # type: ignore + + async def check_key_values( + self, + key: Optional[str] = None, + label: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + select: Optional[List[Union[str, "models.SettingFields"]]] = None, + **kwargs + ) -> None: + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param key: A filter used to match keys. + :type key: str + :param label: A filter used to match labels. + :type label: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.learnappconfig.models.SettingFields] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_key_values.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if key is not None: + query_parameters['key'] = self._serialize.query("key", key, 'str') + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_key_values.metadata = {'url': '/kv'} # type: ignore + + async def get_key_value( + self, + key: str, + label: Optional[str] = None, + accept_datetime: Optional[str] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + select: Optional[List[Union[str, "models.SettingFields"]]] = None, + **kwargs + ) -> "models.KeyValue": + """Gets a single key-value. + + Gets a single key-value. + + :param key: The key of the key-value to retrieve. + :type key: str + :param label: The label of the key-value to retrieve. + :type label: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.learnappconfig.models.SettingFields] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: KeyValue, or the result of cls(response) + :rtype: ~azure.learnappconfig.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.get_key_value.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers['Last-Modified']=self._deserialize('str', response.headers.get('Last-Modified')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + async def put_key_value( + self, + key: str, + label: Optional[str] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + entity: Optional["models.KeyValue"] = None, + **kwargs + ) -> "models.KeyValue": + """Creates a key-value. + + Creates a key-value. + + :param key: The key of the key-value to create. + :type key: str + :param label: The label of the key-value to create. + :type label: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: str + :param entity: The key-value to create. + :type entity: ~azure.learnappconfig.models.KeyValue + :keyword callable cls: A custom type or function that will be passed the direct response + :return: KeyValue, or the result of cls(response) + :rtype: ~azure.learnappconfig.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + content_type = kwargs.pop("content_type", "application/vnd.microsoft.appconfig.kv+json") + + # Construct URL + url = self.put_key_value.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + if entity is not None: + body_content = self._serialize.body(entity, 'KeyValue') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + put_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + async def delete_key_value( + self, + key: str, + label: Optional[str] = None, + if_match: Optional[str] = None, + **kwargs + ) -> Optional["models.KeyValue"]: + """Deletes a key-value. + + Deletes a key-value. + + :param key: The key of the key-value to delete. + :type key: str + :param label: The label of the key-value to delete. + :type label: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: KeyValue, or the result of cls(response) + :rtype: ~azure.learnappconfig.models.KeyValue or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.KeyValue"]] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.delete_key_value.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + deserialized = None + if response.status_code == 200: + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if response.status_code == 204: + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + delete_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + async def check_key_value( + self, + key: str, + label: Optional[str] = None, + accept_datetime: Optional[str] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + select: Optional[List[Union[str, "models.SettingFields"]]] = None, + **kwargs + ) -> None: + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param key: The key of the key-value to retrieve. + :type key: str + :param label: The label of the key-value to retrieve. + :type label: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.learnappconfig.models.SettingFields] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_key_value.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers['Last-Modified']=self._deserialize('str', response.headers.get('Last-Modified')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + def get_labels( + self, + name: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + select: Optional[List[str]] = None, + **kwargs + ) -> AsyncIterable["models.LabelListResult"]: + """Gets a list of labels. + + Gets a list of labels. + + :param name: A filter for the name of the returned labels. + :type name: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LabelListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.learnappconfig.models.LabelListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LabelListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.get_labels.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LabelListResult', pipeline_response) + list_of_elem = deserialized.items + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_labels.metadata = {'url': '/labels'} # type: ignore + + async def check_labels( + self, + name: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + select: Optional[List[str]] = None, + **kwargs + ) -> None: + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param name: A filter for the name of the returned labels. + :type name: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_labels.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_labels.metadata = {'url': '/labels'} # type: ignore + + async def put_lock( + self, + key: str, + label: Optional[str] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs + ) -> "models.KeyValue": + """Locks a key-value. + + Locks a key-value. + + :param key: The key of the key-value to lock. + :type key: str + :param label: The label, if any, of the key-value to lock. + :type label: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: KeyValue, or the result of cls(response) + :rtype: ~azure.learnappconfig.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.put_lock.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + put_lock.metadata = {'url': '/locks/{key}'} # type: ignore + + async def delete_lock( + self, + key: str, + label: Optional[str] = None, + if_match: Optional[str] = None, + if_none_match: Optional[str] = None, + **kwargs + ) -> "models.KeyValue": + """Unlocks a key-value. + + Unlocks a key-value. + + :param key: The key of the key-value to unlock. + :type key: str + :param label: The label, if any, of the key-value to unlock. + :type label: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: KeyValue, or the result of cls(response) + :rtype: ~azure.learnappconfig.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.delete_lock.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + delete_lock.metadata = {'url': '/locks/{key}'} # type: ignore + + def get_revisions( + self, + key: Optional[str] = None, + label: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + select: Optional[List[Union[str, "models.SettingFields"]]] = None, + **kwargs + ) -> AsyncIterable["models.KeyValueListResult"]: + """Gets a list of key-value revisions. + + Gets a list of key-value revisions. + + :param key: A filter used to match keys. + :type key: str + :param label: A filter used to match labels. + :type label: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.learnappconfig.models.SettingFields] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KeyValueListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.learnappconfig.models.KeyValueListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyValueListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.get_revisions.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if key is not None: + query_parameters['key'] = self._serialize.query("key", key, 'str') + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('KeyValueListResult', pipeline_response) + list_of_elem = deserialized.items + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + get_revisions.metadata = {'url': '/revisions'} # type: ignore + + async def check_revisions( + self, + key: Optional[str] = None, + label: Optional[str] = None, + after: Optional[str] = None, + accept_datetime: Optional[str] = None, + select: Optional[List[Union[str, "models.SettingFields"]]] = None, + **kwargs + ) -> None: + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param key: A filter used to match keys. + :type key: str + :param label: A filter used to match labels. + :type label: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.learnappconfig.models.SettingFields] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_revisions.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if key is not None: + query_parameters['key'] = self._serialize.query("key", key, 'str') + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_revisions.metadata = {'url': '/revisions'} # type: ignore diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/models/__init__.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/models/__init__.py new file mode 100644 index 000000000000..7409752b644b --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/models/__init__.py @@ -0,0 +1,39 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import Error + from ._models_py3 import Key + from ._models_py3 import KeyListResult + from ._models_py3 import KeyValue + from ._models_py3 import KeyValueListResult + from ._models_py3 import Label + from ._models_py3 import LabelListResult +except (SyntaxError, ImportError): + from ._models import Error # type: ignore + from ._models import Key # type: ignore + from ._models import KeyListResult # type: ignore + from ._models import KeyValue # type: ignore + from ._models import KeyValueListResult # type: ignore + from ._models import Label # type: ignore + from ._models import LabelListResult # type: ignore + +from ._azure_app_configuration_enums import ( + SettingFields, +) + +__all__ = [ + 'Error', + 'Key', + 'KeyListResult', + 'KeyValue', + 'KeyValueListResult', + 'Label', + 'LabelListResult', + 'SettingFields', +] diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/models/_azure_app_configuration_enums.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/models/_azure_app_configuration_enums.py new file mode 100644 index 000000000000..9e502e0a7598 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/models/_azure_app_configuration_enums.py @@ -0,0 +1,38 @@ +# 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 enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class SettingFields(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + KEY = "key" + LABEL = "label" + CONTENT_TYPE = "content_type" + VALUE = "value" + LAST_MODIFIED = "last_modified" + TAGS = "tags" + LOCKED = "locked" + ETAG = "etag" diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/models/_models.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/models/_models.py new file mode 100644 index 000000000000..f043aff3bd6e --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/models/_models.py @@ -0,0 +1,211 @@ +# 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 azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class Error(msrest.serialization.Model): + """Azure App Configuration error object. + + :param type: The type of the error. + :type type: str + :param title: A brief summary of the error. + :type title: str + :param name: The name of the parameter that resulted in the error. + :type name: str + :param detail: A detailed description of the error. + :type detail: str + :param status: The HTTP status code that the error maps to. + :type status: int + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'title': {'key': 'title', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'detail': {'key': 'detail', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'int'}, + } + + def __init__( + self, + **kwargs + ): + super(Error, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.title = kwargs.get('title', None) + self.name = kwargs.get('name', None) + self.detail = kwargs.get('detail', None) + self.status = kwargs.get('status', None) + + +class Key(msrest.serialization.Model): + """Key. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: + :vartype name: str + """ + + _validation = { + 'name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Key, self).__init__(**kwargs) + self.name = None + + +class KeyListResult(msrest.serialization.Model): + """The result of a list request. + + :param items: The collection value. + :type items: list[~azure.learnappconfig.models.Key] + :param next_link: The URI that can be used to request the next set of paged results. + :type next_link: str + """ + + _attribute_map = { + 'items': {'key': 'items', 'type': '[Key]'}, + 'next_link': {'key': '@nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(KeyListResult, self).__init__(**kwargs) + self.items = kwargs.get('items', None) + self.next_link = kwargs.get('next_link', None) + + +class KeyValue(msrest.serialization.Model): + """KeyValue. + + :param key: + :type key: str + :param label: + :type label: str + :param content_type: + :type content_type: str + :param value: + :type value: str + :param last_modified: + :type last_modified: ~datetime.datetime + :param tags: A set of tags. Dictionary of :code:``. + :type tags: dict[str, str] + :param locked: + :type locked: bool + :param etag: + :type etag: str + """ + + _attribute_map = { + 'key': {'key': 'key', 'type': 'str'}, + 'label': {'key': 'label', 'type': 'str'}, + 'content_type': {'key': 'content_type', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'last_modified': {'key': 'last_modified', 'type': 'iso-8601'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'locked': {'key': 'locked', 'type': 'bool'}, + 'etag': {'key': 'etag', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(KeyValue, self).__init__(**kwargs) + self.key = kwargs.get('key', None) + self.label = kwargs.get('label', None) + self.content_type = kwargs.get('content_type', None) + self.value = kwargs.get('value', None) + self.last_modified = kwargs.get('last_modified', None) + self.tags = kwargs.get('tags', None) + self.locked = kwargs.get('locked', None) + self.etag = kwargs.get('etag', None) + + +class KeyValueListResult(msrest.serialization.Model): + """The result of a list request. + + :param items: The collection value. + :type items: list[~azure.learnappconfig.models.KeyValue] + :param next_link: The URI that can be used to request the next set of paged results. + :type next_link: str + """ + + _attribute_map = { + 'items': {'key': 'items', 'type': '[KeyValue]'}, + 'next_link': {'key': '@nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(KeyValueListResult, self).__init__(**kwargs) + self.items = kwargs.get('items', None) + self.next_link = kwargs.get('next_link', None) + + +class Label(msrest.serialization.Model): + """Label. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: + :vartype name: str + """ + + _validation = { + 'name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Label, self).__init__(**kwargs) + self.name = None + + +class LabelListResult(msrest.serialization.Model): + """The result of a list request. + + :param items: The collection value. + :type items: list[~azure.learnappconfig.models.Label] + :param next_link: The URI that can be used to request the next set of paged results. + :type next_link: str + """ + + _attribute_map = { + 'items': {'key': 'items', 'type': '[Label]'}, + 'next_link': {'key': '@nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LabelListResult, self).__init__(**kwargs) + self.items = kwargs.get('items', None) + self.next_link = kwargs.get('next_link', None) diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/models/_models_py3.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/models/_models_py3.py new file mode 100644 index 000000000000..11ba91443dd4 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/models/_models_py3.py @@ -0,0 +1,238 @@ +# 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. +# -------------------------------------------------------------------------- + +import datetime +from typing import Dict, List, Optional + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class Error(msrest.serialization.Model): + """Azure App Configuration error object. + + :param type: The type of the error. + :type type: str + :param title: A brief summary of the error. + :type title: str + :param name: The name of the parameter that resulted in the error. + :type name: str + :param detail: A detailed description of the error. + :type detail: str + :param status: The HTTP status code that the error maps to. + :type status: int + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'title': {'key': 'title', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'detail': {'key': 'detail', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'int'}, + } + + def __init__( + self, + *, + type: Optional[str] = None, + title: Optional[str] = None, + name: Optional[str] = None, + detail: Optional[str] = None, + status: Optional[int] = None, + **kwargs + ): + super(Error, self).__init__(**kwargs) + self.type = type + self.title = title + self.name = name + self.detail = detail + self.status = status + + +class Key(msrest.serialization.Model): + """Key. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: + :vartype name: str + """ + + _validation = { + 'name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Key, self).__init__(**kwargs) + self.name = None + + +class KeyListResult(msrest.serialization.Model): + """The result of a list request. + + :param items: The collection value. + :type items: list[~azure.learnappconfig.models.Key] + :param next_link: The URI that can be used to request the next set of paged results. + :type next_link: str + """ + + _attribute_map = { + 'items': {'key': 'items', 'type': '[Key]'}, + 'next_link': {'key': '@nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + items: Optional[List["Key"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(KeyListResult, self).__init__(**kwargs) + self.items = items + self.next_link = next_link + + +class KeyValue(msrest.serialization.Model): + """KeyValue. + + :param key: + :type key: str + :param label: + :type label: str + :param content_type: + :type content_type: str + :param value: + :type value: str + :param last_modified: + :type last_modified: ~datetime.datetime + :param tags: A set of tags. Dictionary of :code:``. + :type tags: dict[str, str] + :param locked: + :type locked: bool + :param etag: + :type etag: str + """ + + _attribute_map = { + 'key': {'key': 'key', 'type': 'str'}, + 'label': {'key': 'label', 'type': 'str'}, + 'content_type': {'key': 'content_type', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'last_modified': {'key': 'last_modified', 'type': 'iso-8601'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'locked': {'key': 'locked', 'type': 'bool'}, + 'etag': {'key': 'etag', 'type': 'str'}, + } + + def __init__( + self, + *, + key: Optional[str] = None, + label: Optional[str] = None, + content_type: Optional[str] = None, + value: Optional[str] = None, + last_modified: Optional[datetime.datetime] = None, + tags: Optional[Dict[str, str]] = None, + locked: Optional[bool] = None, + etag: Optional[str] = None, + **kwargs + ): + super(KeyValue, self).__init__(**kwargs) + self.key = key + self.label = label + self.content_type = content_type + self.value = value + self.last_modified = last_modified + self.tags = tags + self.locked = locked + self.etag = etag + + +class KeyValueListResult(msrest.serialization.Model): + """The result of a list request. + + :param items: The collection value. + :type items: list[~azure.learnappconfig.models.KeyValue] + :param next_link: The URI that can be used to request the next set of paged results. + :type next_link: str + """ + + _attribute_map = { + 'items': {'key': 'items', 'type': '[KeyValue]'}, + 'next_link': {'key': '@nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + items: Optional[List["KeyValue"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(KeyValueListResult, self).__init__(**kwargs) + self.items = items + self.next_link = next_link + + +class Label(msrest.serialization.Model): + """Label. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: + :vartype name: str + """ + + _validation = { + 'name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Label, self).__init__(**kwargs) + self.name = None + + +class LabelListResult(msrest.serialization.Model): + """The result of a list request. + + :param items: The collection value. + :type items: list[~azure.learnappconfig.models.Label] + :param next_link: The URI that can be used to request the next set of paged results. + :type next_link: str + """ + + _attribute_map = { + 'items': {'key': 'items', 'type': '[Label]'}, + 'next_link': {'key': '@nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + items: Optional[List["Label"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(LabelListResult, self).__init__(**kwargs) + self.items = items + self.next_link = next_link diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/operations/__init__.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/operations/__init__.py new file mode 100644 index 000000000000..b3314598b704 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/operations/__init__.py @@ -0,0 +1,13 @@ +# 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 ._azure_app_configuration_operations import AzureAppConfigurationOperationsMixin + +__all__ = [ + 'AzureAppConfigurationOperationsMixin', +] diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/operations/_azure_app_configuration_operations.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/operations/_azure_app_configuration_operations.py new file mode 100644 index 000000000000..c4e858cf0544 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/operations/_azure_app_configuration_operations.py @@ -0,0 +1,1200 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AzureAppConfigurationOperationsMixin(object): + + def get_keys( + self, + name=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.KeyListResult"] + """Gets a list of keys. + + Gets a list of keys. + + :param name: A filter for the name of the returned keys. + :type name: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KeyListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.learnappconfig.models.KeyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.get_keys.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('KeyListResult', pipeline_response) + list_of_elem = deserialized.items + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_keys.metadata = {'url': '/keys'} # type: ignore + + def check_keys( + self, + name=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param name: A filter for the name of the returned keys. + :type name: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_keys.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_keys.metadata = {'url': '/keys'} # type: ignore + + def get_key_values( + self, + key=None, # type: Optional[str] + label=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + select=None, # type: Optional[List[Union[str, "models.SettingFields"]]] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.KeyValueListResult"] + """Gets a list of key-values. + + Gets a list of key-values. + + :param key: A filter used to match keys. + :type key: str + :param label: A filter used to match labels. + :type label: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.learnappconfig.models.SettingFields] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KeyValueListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.learnappconfig.models.KeyValueListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyValueListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.get_key_values.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if key is not None: + query_parameters['key'] = self._serialize.query("key", key, 'str') + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('KeyValueListResult', pipeline_response) + list_of_elem = deserialized.items + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_key_values.metadata = {'url': '/kv'} # type: ignore + + def check_key_values( + self, + key=None, # type: Optional[str] + label=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + select=None, # type: Optional[List[Union[str, "models.SettingFields"]]] + **kwargs # type: Any + ): + # type: (...) -> None + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param key: A filter used to match keys. + :type key: str + :param label: A filter used to match labels. + :type label: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.learnappconfig.models.SettingFields] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_key_values.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if key is not None: + query_parameters['key'] = self._serialize.query("key", key, 'str') + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_key_values.metadata = {'url': '/kv'} # type: ignore + + def get_key_value( + self, + key, # type: str + label=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + if_match=None, # type: Optional[str] + if_none_match=None, # type: Optional[str] + select=None, # type: Optional[List[Union[str, "models.SettingFields"]]] + **kwargs # type: Any + ): + # type: (...) -> "models.KeyValue" + """Gets a single key-value. + + Gets a single key-value. + + :param key: The key of the key-value to retrieve. + :type key: str + :param label: The label of the key-value to retrieve. + :type label: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.learnappconfig.models.SettingFields] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: KeyValue, or the result of cls(response) + :rtype: ~azure.learnappconfig.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.get_key_value.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers['Last-Modified']=self._deserialize('str', response.headers.get('Last-Modified')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + def put_key_value( + self, + key, # type: str + label=None, # type: Optional[str] + if_match=None, # type: Optional[str] + if_none_match=None, # type: Optional[str] + entity=None, # type: Optional["models.KeyValue"] + **kwargs # type: Any + ): + # type: (...) -> "models.KeyValue" + """Creates a key-value. + + Creates a key-value. + + :param key: The key of the key-value to create. + :type key: str + :param label: The label of the key-value to create. + :type label: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: str + :param entity: The key-value to create. + :type entity: ~azure.learnappconfig.models.KeyValue + :keyword callable cls: A custom type or function that will be passed the direct response + :return: KeyValue, or the result of cls(response) + :rtype: ~azure.learnappconfig.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + content_type = kwargs.pop("content_type", "application/vnd.microsoft.appconfig.kv+json") + + # Construct URL + url = self.put_key_value.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + body_content_kwargs = {} # type: Dict[str, Any] + if entity is not None: + body_content = self._serialize.body(entity, 'KeyValue') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + put_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + def delete_key_value( + self, + key, # type: str + label=None, # type: Optional[str] + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Optional["models.KeyValue"] + """Deletes a key-value. + + Deletes a key-value. + + :param key: The key of the key-value to delete. + :type key: str + :param label: The label of the key-value to delete. + :type label: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: KeyValue, or the result of cls(response) + :rtype: ~azure.learnappconfig.models.KeyValue or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.KeyValue"]] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.delete_key_value.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + deserialized = None + if response.status_code == 200: + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if response.status_code == 204: + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + delete_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + def check_key_value( + self, + key, # type: str + label=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + if_match=None, # type: Optional[str] + if_none_match=None, # type: Optional[str] + select=None, # type: Optional[List[Union[str, "models.SettingFields"]]] + **kwargs # type: Any + ): + # type: (...) -> None + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param key: The key of the key-value to retrieve. + :type key: str + :param label: The label of the key-value to retrieve. + :type label: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.learnappconfig.models.SettingFields] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_key_value.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers['Last-Modified']=self._deserialize('str', response.headers.get('Last-Modified')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_key_value.metadata = {'url': '/kv/{key}'} # type: ignore + + def get_labels( + self, + name=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + select=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.LabelListResult"] + """Gets a list of labels. + + Gets a list of labels. + + :param name: A filter for the name of the returned labels. + :type name: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LabelListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.learnappconfig.models.LabelListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LabelListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.get_labels.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('LabelListResult', pipeline_response) + list_of_elem = deserialized.items + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_labels.metadata = {'url': '/labels'} # type: ignore + + def check_labels( + self, + name=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + select=None, # type: Optional[List[str]] + **kwargs # type: Any + ): + # type: (...) -> None + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param name: A filter for the name of the returned labels. + :type name: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_labels.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if name is not None: + query_parameters['name'] = self._serialize.query("name", name, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_labels.metadata = {'url': '/labels'} # type: ignore + + def put_lock( + self, + key, # type: str + label=None, # type: Optional[str] + if_match=None, # type: Optional[str] + if_none_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.KeyValue" + """Locks a key-value. + + Locks a key-value. + + :param key: The key of the key-value to lock. + :type key: str + :param label: The label, if any, of the key-value to lock. + :type label: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: KeyValue, or the result of cls(response) + :rtype: ~azure.learnappconfig.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.put_lock.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + put_lock.metadata = {'url': '/locks/{key}'} # type: ignore + + def delete_lock( + self, + key, # type: str + label=None, # type: Optional[str] + if_match=None, # type: Optional[str] + if_none_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.KeyValue" + """Unlocks a key-value. + + Unlocks a key-value. + + :param key: The key of the key-value to unlock. + :type key: str + :param label: The label, if any, of the key-value to unlock. + :type label: str + :param if_match: Used to perform an operation only if the targeted resource's etag matches the + value provided. + :type if_match: str + :param if_none_match: Used to perform an operation only if the targeted resource's etag does + not match the value provided. + :type if_none_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: KeyValue, or the result of cls(response) + :rtype: ~azure.learnappconfig.models.KeyValue + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyValue"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.delete_lock.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + 'key': self._serialize.url("key", key, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + if if_none_match is not None: + header_parameters['If-None-Match'] = self._serialize.header("if_none_match", if_none_match, 'str') + header_parameters['Accept'] = 'application/json' + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('KeyValue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + delete_lock.metadata = {'url': '/locks/{key}'} # type: ignore + + def get_revisions( + self, + key=None, # type: Optional[str] + label=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + select=None, # type: Optional[List[Union[str, "models.SettingFields"]]] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.KeyValueListResult"] + """Gets a list of key-value revisions. + + Gets a list of key-value revisions. + + :param key: A filter used to match keys. + :type key: str + :param label: A filter used to match labels. + :type label: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.learnappconfig.models.SettingFields] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either KeyValueListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.learnappconfig.models.KeyValueListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.KeyValueListResult"] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + header_parameters['Accept'] = 'application/json' + + if not next_link: + # Construct URL + url = self.get_revisions.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if key is not None: + query_parameters['key'] = self._serialize.query("key", key, 'str') + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('KeyValueListResult', pipeline_response) + list_of_elem = deserialized.items + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + get_revisions.metadata = {'url': '/revisions'} # type: ignore + + def check_revisions( + self, + key=None, # type: Optional[str] + label=None, # type: Optional[str] + after=None, # type: Optional[str] + accept_datetime=None, # type: Optional[str] + select=None, # type: Optional[List[Union[str, "models.SettingFields"]]] + **kwargs # type: Any + ): + # type: (...) -> None + """Requests the headers and status of the given resource. + + Requests the headers and status of the given resource. + + :param key: A filter used to match keys. + :type key: str + :param label: A filter used to match labels. + :type label: str + :param after: Instructs the server to return elements that appear after the element referred to + by the specified token. + :type after: str + :param accept_datetime: Requests the server to respond with the state of the resource at the + specified time. + :type accept_datetime: str + :param select: Used to select what fields are present in the returned resource(s). + :type select: list[str or ~azure.learnappconfig.models.SettingFields] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0" + + # Construct URL + url = self.check_revisions.metadata['url'] # type: ignore + path_format_arguments = { + 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if key is not None: + query_parameters['key'] = self._serialize.query("key", key, 'str') + if label is not None: + query_parameters['label'] = self._serialize.query("label", label, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if after is not None: + query_parameters['After'] = self._serialize.query("after", after, 'str') + if select is not None: + query_parameters['$Select'] = self._serialize.query("select", select, '[str]', div=',') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if self._config.sync_token is not None: + header_parameters['Sync-Token'] = self._serialize.header("self._config.sync_token", self._config.sync_token, 'str') + if accept_datetime is not None: + header_parameters['Accept-Datetime'] = self._serialize.header("accept_datetime", accept_datetime, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers['Sync-Token']=self._deserialize('str', response.headers.get('Sync-Token')) + + if cls: + return cls(pipeline_response, None, response_headers) + + check_revisions.metadata = {'url': '/revisions'} # type: ignore diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/py.typed b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_generated/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_models.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_models.py new file mode 100644 index 000000000000..8c23547a3272 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_models.py @@ -0,0 +1,77 @@ +# 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. +# -------------------------------------------------------------------------- + + +class DictMixin(object): + + def __setitem__(self, key, item): + self.__dict__[key] = item + + def __getitem__(self, key): + return self.__dict__[key] + + def __repr__(self): + return str(self) + + def __len__(self): + return len(self.keys()) + + def __delitem__(self, key): + self.__dict__[key] = None + + def __eq__(self, other): + """Compare objects by comparing all attributes.""" + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other): + """Compare objects by comparing all attributes.""" + return not self.__eq__(other) + + def __str__(self): + return str({k: v for k, v in self.__dict__.items() if not k.startswith('_')}) + + def __contains__(self, k): + return k in self.__dict__ + + def has_key(self, k): + return k in self.__dict__ + + def update(self, *args, **kwargs): + return self.__dict__.update(*args, **kwargs) + + def keys(self): + return [k for k in self.__dict__ if not k.startswith('_')] + + def values(self): + return [v for k, v in self.__dict__.items() if not k.startswith('_')] + + def items(self): + return [(k, v) for k, v in self.__dict__.items() if not k.startswith('_')] + + def get(self, key, default=None): + if key in self.__dict__: + return self.__dict__[key] + return default + + +class ConfigurationSetting(DictMixin): + """A configuration value. + + :param str key: The key name of the setting. + :param str value: The value of the setting. + :keyword str label: The setting label. + :ivar str etag: Entity tag (etag) of the setting. + :ivar ~datetime.datetime last_modified: The time the setting was last modified. + :ivar bool read_only: Whether the setting is read-only. + :ivar str content_type: The content type of the setting value. + :ivar dict[str, str] tags: User tags added to the setting. + """ + + def __init__(self, key, value, **kwargs): + # type: (str, str, Any) -> None + pass diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_utils.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_utils.py new file mode 100644 index 000000000000..006671542af8 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_utils.py @@ -0,0 +1,5 @@ +# 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. +# -------------------------------------------------------------------------- diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_version.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_version.py new file mode 100644 index 000000000000..f95f18986f48 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/_version.py @@ -0,0 +1,7 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = '0.0.1' diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/aio/__init__.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/aio/__init__.py new file mode 100644 index 000000000000..995bd258a0e0 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 ._client import AppConfigurationClient + + +__all__ = ["AppConfigurationClient"] diff --git a/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/aio/_client.py b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/aio/_client.py new file mode 100644 index 000000000000..2f35649dfee3 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/azure/learnappconfig/aio/_client.py @@ -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 datetime import datetime +from typing import Optional, List, Union + +from azure.core import MatchConditions + +from .._generated.models import SettingFields +from .._models import ConfigurationSetting + +class AppConfigurationClient(object): + """A Client for the AppConfiguration Service. + + :param str account_url: The URL for the service. + :param AsyncTokenCredential credential: The credentials to authenticate with the service. + """ + + def __init__(self, account_url: str, credential: "AsyncTokenCredential", **kwargs): + pass + + async def get_configuration_setting( + self, + key: str, + *, + label: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + etag: Optional[str] = None, + accept_datetime: Optional[datetime] = None, + select: Optional[List[Union[str, SettingFields]]] = None, + **kwargs + ) -> ConfigurationSetting: + """Get the value of a particular configuration settings. + + :param str key: The key name of the setting. + :keyword str label: The label of the setting. + :keyword ~azure.core.MatchConditions match_condition: A condition under which the operation should be completed. + :keyword str etag: The etag by which the match condition should be assessed. + :keyword datetime accept_datetime: The last modified date filter. + :keyword select: The specific properties of the setting that should be returned. + :paramtype select: List[Union[str, ~azure.learnappconfig.SettingFields]] + :raises ~azure.core.exceptions.ResourceNotFoundError: If no matching configuration setting exists. + """ + pass diff --git a/sdk/api-learn/azure-learnappconfig/dev_requirements.txt b/sdk/api-learn/azure-learnappconfig/dev_requirements.txt new file mode 100644 index 000000000000..2a41134e0e0d --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/dev_requirements.txt @@ -0,0 +1,7 @@ +../../core/azure-core +-e ../../../tools/azure-devtools +-e ../../../tools/azure-sdk-tools +-e ../../identity/azure-identity +aiohttp>=3.0; python_version >= '3.5' +aiodns>=2.0; python_version >= '3.5' +msrest>=0.6.10 diff --git a/sdk/api-learn/azure-learnappconfig/samples/sample_conditional_async.py b/sdk/api-learn/azure-learnappconfig/samples/sample_conditional_async.py new file mode 100644 index 000000000000..4983b4bf2f6c --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/samples/sample_conditional_async.py @@ -0,0 +1,48 @@ +# 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. +# -------------------------------------------------------------------------- + +import asyncio +import os +from colorama import init, Style, Fore +init() + +from azure.identity.aio import DefaultAzureCredential +from azure.learnappconfig.aio import AppConfigurationClient +from azure.core.exceptions import ResourceNotFoundError, ResourceNotModifiedError +from azure.core import MatchConditions + + +async def main(): + url = os.environ.get('API-LEARN_ENDPOINT') + credential = DefaultAzureCredential() + async with AppConfigurationClient(account_url=url, credential=credential) as client: + + # Retrieve initial color value + try: + first_color = await client.get_configuration_setting(os.enviorn['API-LEARN_SETTING_COLOR_KEY']) + except ResourceNotFoundError: + raise + + # Get latest color value, only if it has changed + try: + new_color = await client.get_configuration_setting( + key=os.enviorn['API-LEARN_SETTING_COLOR_KEY'], + match_condition=MatchConditions.IfModified, + etag=first_color.etag + ) + except ResourceNotModifiedError: + new_color = first_color + + color = getattr(Fore, new_color.value.upper()) + greeting = 'Hello!' + print(f'{color}{greeting}{Style.RESET_ALL}') + + +if __name__ == "__main__": + loop = asyncio.get_event_loop() + loop.run_until_complete(main()) diff --git a/sdk/api-learn/azure-learnappconfig/samples/sample_hello_world.py b/sdk/api-learn/azure-learnappconfig/samples/sample_hello_world.py new file mode 100644 index 000000000000..242fa88a55b8 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/samples/sample_hello_world.py @@ -0,0 +1,35 @@ +# 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. +# -------------------------------------------------------------------------- + +import os +from colorama import init, Style, Fore +init() + +from azure.identity import DefaultAzureCredential +from azure.learnappconfig import AppConfigurationClient + +def main(): + url = os.environ.get('API-LEARN_ENDPOINT') + credential = DefaultAzureCredential() + client = AppConfigurationClient(account_url=url, credential=credential) + + try: + color_setting = client.get_configuration_setting(os.enviorn['API-LEARN_SETTING_COLOR_KEY']) + color = color_setting.value.upper() + text_setting = client.get_configuration_setting(os.environ['API-LEARN_SETTING_TEXT_KEY']) + greeting = text_setting.value + except: + color = 'RED' + greeting = 'Default greeting' + + color = getattr(Fore, color) + print(f'{color}{greeting}{Style.RESET_ALL}') + + +if __name__ == "__main__": + main() diff --git a/sdk/api-learn/azure-learnappconfig/sdk_packaging.toml b/sdk/api-learn/azure-learnappconfig/sdk_packaging.toml new file mode 100644 index 000000000000..b366f78fb41b --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/sdk_packaging.toml @@ -0,0 +1,4 @@ +[packaging] +is_arm = false +need_msrestazure = false +auto_update = false diff --git a/sdk/api-learn/azure-learnappconfig/setup.cfg b/sdk/api-learn/azure-learnappconfig/setup.cfg new file mode 100644 index 000000000000..3c6e79cf31da --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/sdk/api-learn/azure-learnappconfig/setup.py b/sdk/api-learn/azure-learnappconfig/setup.py new file mode 100644 index 000000000000..f4c80a52c71d --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/setup.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import sys +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-learnappconfig" +PACKAGE_PPRINT_NAME = "App Configuration Data Training SDK" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +exclude_packages = [ + 'tests', + 'tests.*', + 'samples', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + ] +if sys.version_info < (3, 5, 3): + exclude_packages.extend([ + '*.aio', + '*.aio.*' + ]) + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft {} Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/appconfiguration/azure-appconfiguration', + classifiers=[ + "Development Status :: 5 - Production/Stable", + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=exclude_packages), + install_requires=[ + "msrest>=0.6.10", + "azure-core<2.0.0,>=1.0.0", + ], + extras_require={ + ":python_version<'3.0'": ['azure-nspkg'], + ":python_version<'3.4'": ['enum34>=1.0.4'], + ":python_version<'3.5'": ['typing'], + "async:python_version>='3.5'": [ + 'aiohttp>=3.0', + 'aiodns>=2.0' + ], + } +) \ No newline at end of file diff --git a/sdk/api-learn/azure-learnappconfig/swagger/README.md b/sdk/api-learn/azure-learnappconfig/swagger/README.md new file mode 100644 index 000000000000..e79ad0c7f672 --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/swagger/README.md @@ -0,0 +1,25 @@ +# Azure Queue Storage for Python + +> see https://aka.ms/autorest + + +### Generation +```ps +cd +autorest README.md --use=@autorest/python@5.1.0-preview.7 +``` + +### Settings +```yaml +input-file: appconfiguration.json +output-folder: ../azure/learnappconfig/_generated +namespace: azure.learnappconfig +no-namespace-folders: true +license-header: MICROSOFT_MIT_NO_VERSION +enable-xml: false +vanilla: true +clear-output-folder: true +add-credentials: true +python: true +package-version: "1.0" +``` diff --git a/sdk/api-learn/azure-learnappconfig/swagger/appconfiguration.json b/sdk/api-learn/azure-learnappconfig/swagger/appconfiguration.json new file mode 100644 index 000000000000..a2aab91162ed --- /dev/null +++ b/sdk/api-learn/azure-learnappconfig/swagger/appconfiguration.json @@ -0,0 +1,1371 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0", + "title": "Azure App Configuration" + }, + "schemes": [ + "https" + ], + "paths": { + "/keys": { + "get": { + "tags": [ + "Keys" + ], + "summary": "Gets a list of keys.", + "operationId": "GetKeys", + "consumes": [], + "produces": [ + "application/vnd.microsoft.appconfig.keyset+json", + "application/json", + "application/problem+json" + ], + "parameters": [ + { + "name": "name", + "in": "query", + "description": "A filter for the name of the returned keys.", + "type": "string" + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "After", + "in": "query", + "description": "Instructs the server to return elements that appear after the element referred to by the specified token.", + "type": "string" + }, + { + "name": "Accept-Datetime", + "in": "header", + "description": "Requests the server to respond with the state of the resource at the specified time.", + "type": "string" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/KeyListResult" + }, + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "x-ms-examples": { + "GetKeys": { + "$ref": "./examples/GetKeys.json" + } + }, + "x-ms-pageable": { + "itemName": "items", + "nextLinkName": "@nextLink" + } + }, + "head": { + "tags": [ + "Keys" + ], + "summary": "Requests the headers and status of the given resource.", + "operationId": "CheckKeys", + "consumes": [], + "produces": [], + "parameters": [ + { + "name": "name", + "in": "query", + "description": "A filter for the name of the returned keys.", + "type": "string" + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "After", + "in": "query", + "description": "Instructs the server to return elements that appear after the element referred to by the specified token.", + "type": "string" + }, + { + "name": "Accept-Datetime", + "in": "header", + "description": "Requests the server to respond with the state of the resource at the specified time.", + "type": "string" + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed" + } + }, + "x-ms-examples": { + "CheckKeys": { + "$ref": "./examples/CheckKeys.json" + } + } + } + }, + "/kv": { + "get": { + "tags": [ + "KeyValues" + ], + "summary": "Gets a list of key-values.", + "operationId": "GetKeyValues", + "consumes": [], + "produces": [ + "application/vnd.microsoft.appconfig.kvset+json", + "application/json", + "application/problem+json" + ], + "parameters": [ + { + "name": "key", + "in": "query", + "description": "A filter used to match keys.", + "type": "string" + }, + { + "name": "label", + "in": "query", + "description": "A filter used to match labels", + "type": "string" + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "After", + "in": "query", + "description": "Instructs the server to return elements that appear after the element referred to by the specified token.", + "type": "string" + }, + { + "name": "Accept-Datetime", + "in": "header", + "description": "Requests the server to respond with the state of the resource at the specified time.", + "type": "string" + }, + { + "name": "$Select", + "in": "query", + "description": "Used to select what fields are present in the returned resource(s).", + "type": "array", + "items": { + "type": "string", + "enum": [ + "key", + "label", + "content_type", + "value", + "last_modified", + "tags", + "locked", + "etag" + ], + "x-ms-enum": { + "name": "SettingFields", + "modelAsString": true + } + }, + "collectionFormat": "csv" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/KeyValueListResult" + }, + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "x-ms-examples": { + "GetKeyValues": { + "$ref": "./examples/GetKeyValues.json" + } + }, + "x-ms-pageable": { + "itemName": "items", + "nextLinkName": "@nextLink" + } + }, + "head": { + "tags": [ + "KeyValues" + ], + "summary": "Requests the headers and status of the given resource.", + "operationId": "CheckKeyValues", + "consumes": [], + "produces": [], + "parameters": [ + { + "name": "key", + "in": "query", + "description": "A filter used to match keys.", + "type": "string" + }, + { + "name": "label", + "in": "query", + "description": "A filter used to match labels", + "type": "string" + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "After", + "in": "query", + "description": "Instructs the server to return elements that appear after the element referred to by the specified token.", + "type": "string" + }, + { + "name": "Accept-Datetime", + "in": "header", + "description": "Requests the server to respond with the state of the resource at the specified time.", + "type": "string" + }, + { + "name": "$Select", + "in": "query", + "description": "Used to select what fields are present in the returned resource(s).", + "type": "array", + "items": { + "type": "string", + "enum": [ + "key", + "label", + "content_type", + "value", + "last_modified", + "tags", + "locked", + "etag" + ], + "x-ms-enum": { + "name": "SettingFields", + "modelAsString": true + } + }, + "collectionFormat": "csv" + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed" + } + }, + "x-ms-examples": { + "CheckKeyValues": { + "$ref": "./examples/CheckKeyValues.json" + } + } + } + }, + "/kv/{key}": { + "get": { + "tags": [ + "KeyValues" + ], + "summary": "Gets a single key-value.", + "operationId": "GetKeyValue", + "consumes": [], + "produces": [ + "application/vnd.microsoft.appconfig.kv+json", + "application/json", + "application/problem+json" + ], + "parameters": [ + { + "name": "key", + "in": "path", + "description": "The key of the key-value to retrieve.", + "required": true, + "type": "string" + }, + { + "name": "label", + "in": "query", + "description": "The label of the key-value to retrieve.", + "type": "string" + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "Accept-Datetime", + "in": "header", + "description": "Requests the server to respond with the state of the resource at the specified time.", + "type": "string" + }, + { + "name": "If-Match", + "in": "header", + "description": "Used to perform an operation only if the targeted resource's etag matches the value provided.", + "type": "string" + }, + { + "name": "If-None-Match", + "in": "header", + "description": "Used to perform an operation only if the targeted resource's etag does not match the value provided.", + "type": "string" + }, + { + "name": "$Select", + "in": "query", + "description": "Used to select what fields are present in the returned resource(s).", + "type": "array", + "items": { + "type": "string", + "enum": [ + "key", + "label", + "content_type", + "value", + "last_modified", + "tags", + "locked", + "etag" + ], + "x-ms-enum": { + "name": "SettingFields", + "modelAsString": true + } + }, + "collectionFormat": "csv" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/KeyValue" + }, + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + }, + "ETag": { + "description": "An identifier representing the returned state of the resource.", + "type": "string" + }, + "Last-Modified": { + "description": "A UTC datetime that specifies the last time the resource was modified.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "x-ms-examples": { + "GetKeyValue": { + "$ref": "./examples/GetKeyValue.json" + }, + "GetKeyValue_IfMatch": { + "$ref": "./examples/GetKeyValue_IfMatch.json" + }, + "GetKeyValue_IfNoneMatch": { + "$ref": "./examples/GetKeyValue_IfNoneMatch.json" + } + } + }, + "put": { + "tags": [ + "KeyValues" + ], + "summary": "Creates a key-value.", + "operationId": "PutKeyValue", + "consumes": [ + "application/vnd.microsoft.appconfig.kv+json", + "application/vnd.microsoft.appconfig.kvset+json", + "application/json", + "text/json", + "application/*+json", + "application/json-patch+json" + ], + "produces": [ + "application/vnd.microsoft.appconfig.kv+json", + "application/json", + "application/problem+json" + ], + "parameters": [ + { + "name": "key", + "in": "path", + "description": "The key of the key-value to create.", + "required": true, + "type": "string" + }, + { + "name": "label", + "in": "query", + "description": "The label of the key-value to create.", + "type": "string" + }, + { + "name": "entity", + "in": "body", + "description": "The key-value to create.", + "schema": { + "$ref": "#/definitions/KeyValue" + } + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "If-Match", + "in": "header", + "description": "Used to perform an operation only if the targeted resource's etag matches the value provided.", + "type": "string" + }, + { + "name": "If-None-Match", + "in": "header", + "description": "Used to perform an operation only if the targeted resource's etag does not match the value provided.", + "type": "string" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/KeyValue" + }, + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + }, + "ETag": { + "description": "An identifier representing the returned state of the resource.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "x-ms-examples": { + "PutKeyValue": { + "$ref": "./examples/PutKeyValue.json" + }, + "PutKeyValue_IfMatch": { + "$ref": "./examples/PutKeyValue_IfMatch.json" + } + } + }, + "delete": { + "tags": [ + "KeyValues" + ], + "summary": "Deletes a key-value.", + "operationId": "DeleteKeyValue", + "consumes": [], + "produces": [ + "application/vnd.microsoft.appconfig.kv+json", + "application/json", + "application/problem+json" + ], + "parameters": [ + { + "name": "key", + "in": "path", + "description": "The key of the key-value to delete.", + "required": true, + "type": "string" + }, + { + "name": "label", + "in": "query", + "description": "The label of the key-value to delete.", + "type": "string" + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "If-Match", + "in": "header", + "description": "Used to perform an operation only if the targeted resource's etag matches the value provided.", + "type": "string" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/KeyValue" + }, + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + }, + "ETag": { + "description": "An identifier representing the returned state of the resource.", + "type": "string" + } + } + }, + "204": { + "description": "Success", + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "x-ms-examples": { + "DeleteKeyValue": { + "$ref": "./examples/DeleteKeyValue.json" + }, + "DeleteKeyValue_IfMatch": { + "$ref": "./examples/DeleteKeyValue_IfMatch.json" + } + } + }, + "head": { + "tags": [ + "KeyValues" + ], + "summary": "Requests the headers and status of the given resource.", + "operationId": "CheckKeyValue", + "consumes": [], + "produces": [], + "parameters": [ + { + "name": "key", + "in": "path", + "description": "The key of the key-value to retrieve.", + "required": true, + "type": "string" + }, + { + "name": "label", + "in": "query", + "description": "The label of the key-value to retrieve.", + "type": "string" + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "Accept-Datetime", + "in": "header", + "description": "Requests the server to respond with the state of the resource at the specified time.", + "type": "string" + }, + { + "name": "If-Match", + "in": "header", + "description": "Used to perform an operation only if the targeted resource's etag matches the value provided.", + "type": "string" + }, + { + "name": "If-None-Match", + "in": "header", + "description": "Used to perform an operation only if the targeted resource's etag does not match the value provided.", + "type": "string" + }, + { + "name": "$Select", + "in": "query", + "description": "Used to select what fields are present in the returned resource(s).", + "type": "array", + "items": { + "type": "string", + "enum": [ + "key", + "label", + "content_type", + "value", + "last_modified", + "tags", + "locked", + "etag" + ], + "x-ms-enum": { + "name": "SettingFields", + "modelAsString": true + } + }, + "collectionFormat": "csv" + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + }, + "ETag": { + "description": "An identifier representing the returned state of the resource.", + "type": "string" + }, + "Last-Modified": { + "description": "A UTC datetime that specifies the last time the resource was modified.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed" + } + }, + "x-ms-examples": { + "CheckKeyValue": { + "$ref": "./examples/CheckKeyValue.json" + }, + "CheckKeyValue_IfMatch": { + "$ref": "./examples/CheckKeyValue_IfMatch.json" + }, + "CheckKeyValue_IfNoneMatch": { + "$ref": "./examples/CheckKeyValue_IfNoneMatch.json" + } + } + } + }, + "/labels": { + "get": { + "tags": [ + "Labels" + ], + "summary": "Gets a list of labels.", + "operationId": "GetLabels", + "consumes": [], + "produces": [ + "application/vnd.microsoft.appconfig.labelset+json", + "application/json", + "application/problem+json" + ], + "parameters": [ + { + "name": "name", + "in": "query", + "description": "A filter for the name of the returned labels.", + "type": "string" + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "After", + "in": "query", + "description": "Instructs the server to return elements that appear after the element referred to by the specified token.", + "type": "string" + }, + { + "name": "Accept-Datetime", + "in": "header", + "description": "Requests the server to respond with the state of the resource at the specified time.", + "type": "string" + }, + { + "name": "$Select", + "in": "query", + "description": "Used to select what fields are present in the returned resource(s).", + "type": "array", + "items": { + "type": "string", + "enum": [ + "name" + ] + }, + "collectionFormat": "csv" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/LabelListResult" + }, + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "x-ms-examples": { + "GetLabels": { + "$ref": "./examples/GetLabels.json" + } + }, + "x-ms-pageable": { + "itemName": "items", + "nextLinkName": "@nextLink" + } + }, + "head": { + "tags": [ + "Labels" + ], + "summary": "Requests the headers and status of the given resource.", + "operationId": "CheckLabels", + "consumes": [], + "produces": [], + "parameters": [ + { + "name": "name", + "in": "query", + "description": "A filter for the name of the returned labels.", + "type": "string" + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "After", + "in": "query", + "description": "Instructs the server to return elements that appear after the element referred to by the specified token.", + "type": "string" + }, + { + "name": "Accept-Datetime", + "in": "header", + "description": "Requests the server to respond with the state of the resource at the specified time.", + "type": "string" + }, + { + "name": "$Select", + "in": "query", + "description": "Used to select what fields are present in the returned resource(s).", + "type": "array", + "items": { + "type": "string", + "enum": [ + "name" + ] + }, + "collectionFormat": "csv" + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed" + } + }, + "x-ms-examples": { + "CheckLabels": { + "$ref": "./examples/CheckLabels.json" + } + } + } + }, + "/locks/{key}": { + "put": { + "tags": [ + "Locks" + ], + "summary": "Locks a key-value.", + "operationId": "PutLock", + "consumes": [], + "produces": [ + "application/vnd.microsoft.appconfig.kv+json", + "application/json", + "application/problem+json" + ], + "parameters": [ + { + "name": "key", + "in": "path", + "description": "The key of the key-value to lock.", + "required": true, + "type": "string" + }, + { + "name": "label", + "in": "query", + "description": "The label, if any, of the key-value to lock.", + "type": "string" + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "If-Match", + "in": "header", + "description": "Used to perform an operation only if the targeted resource's etag matches the value provided.", + "type": "string" + }, + { + "name": "If-None-Match", + "in": "header", + "description": "Used to perform an operation only if the targeted resource's etag does not match the value provided.", + "type": "string" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/KeyValue" + }, + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + }, + "ETag": { + "description": "An identifier representing the returned state of the resource.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "x-ms-examples": { + "PutLock": { + "$ref": "./examples/PutLock.json" + }, + "PutLock_IfMatch": { + "$ref": "./examples/PutLock_IfMatch.json" + } + } + }, + "delete": { + "tags": [ + "Locks" + ], + "summary": "Unlocks a key-value.", + "operationId": "DeleteLock", + "consumes": [], + "produces": [ + "application/vnd.microsoft.appconfig.kv+json", + "application/json", + "application/problem+json" + ], + "parameters": [ + { + "name": "key", + "in": "path", + "description": "The key of the key-value to unlock.", + "required": true, + "type": "string" + }, + { + "name": "label", + "in": "query", + "description": "The label, if any, of the key-value to unlock.", + "type": "string" + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "If-Match", + "in": "header", + "description": "Used to perform an operation only if the targeted resource's etag matches the value provided.", + "type": "string" + }, + { + "name": "If-None-Match", + "in": "header", + "description": "Used to perform an operation only if the targeted resource's etag does not match the value provided.", + "type": "string" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/KeyValue" + }, + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + }, + "ETag": { + "description": "An identifier representing the returned state of the resource.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "x-ms-examples": { + "DeleteLock": { + "$ref": "./examples/DeleteLock.json" + }, + "DeleteLock_IfMatch": { + "$ref": "./examples/DeleteLock_IfMatch.json" + } + } + } + }, + "/revisions": { + "get": { + "tags": [ + "Revisions" + ], + "summary": "Gets a list of key-value revisions.", + "operationId": "GetRevisions", + "consumes": [], + "produces": [ + "application/vnd.microsoft.appconfig.kvset+json", + "application/json", + "application/problem+json" + ], + "parameters": [ + { + "name": "key", + "in": "query", + "description": "A filter used to match keys.", + "type": "string" + }, + { + "name": "label", + "in": "query", + "description": "A filter used to match labels", + "type": "string" + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "After", + "in": "query", + "description": "Instructs the server to return elements that appear after the element referred to by the specified token.", + "type": "string" + }, + { + "name": "Accept-Datetime", + "in": "header", + "description": "Requests the server to respond with the state of the resource at the specified time.", + "type": "string" + }, + { + "name": "$Select", + "in": "query", + "description": "Used to select what fields are present in the returned resource(s).", + "type": "array", + "items": { + "type": "string", + "enum": [ + "key", + "label", + "content_type", + "value", + "last_modified", + "tags", + "locked", + "etag" + ], + "x-ms-enum": { + "name": "SettingFields", + "modelAsString": true + } + }, + "collectionFormat": "csv" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/KeyValueListResult" + }, + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed", + "schema": { + "$ref": "#/definitions/Error" + } + } + }, + "x-ms-examples": { + "GetRevisions": { + "$ref": "./examples/GetRevisions.json" + } + }, + "x-ms-pageable": { + "itemName": "items", + "nextLinkName": "@nextLink" + } + }, + "head": { + "tags": [ + "Revisions" + ], + "summary": "Requests the headers and status of the given resource.", + "operationId": "CheckRevisions", + "consumes": [], + "produces": [], + "parameters": [ + { + "name": "key", + "in": "query", + "description": "A filter used to match keys.", + "type": "string" + }, + { + "name": "label", + "in": "query", + "description": "A filter used to match labels", + "type": "string" + }, + { + "$ref": "#/parameters/SyncTokens" + }, + { + "$ref": "#/parameters/ApiVersion" + }, + { + "name": "After", + "in": "query", + "description": "Instructs the server to return elements that appear after the element referred to by the specified token.", + "type": "string" + }, + { + "name": "Accept-Datetime", + "in": "header", + "description": "Requests the server to respond with the state of the resource at the specified time.", + "type": "string" + }, + { + "name": "$Select", + "in": "query", + "description": "Used to select what fields are present in the returned resource(s).", + "type": "array", + "items": { + "type": "string", + "enum": [ + "key", + "label", + "content_type", + "value", + "last_modified", + "tags", + "locked", + "etag" + ], + "x-ms-enum": { + "name": "SettingFields", + "modelAsString": true + } + }, + "collectionFormat": "csv" + } + ], + "responses": { + "200": { + "description": "Success", + "headers": { + "Sync-Token": { + "description": "Enables real-time consistency between requests by providing the returned value in the next request made to the server.", + "type": "string" + } + } + }, + "default": { + "description": "Error response describing why the operation failed" + } + }, + "x-ms-examples": { + "CheckRevisions": { + "$ref": "./examples/CheckRevisions.json" + } + } + } + } + }, + "definitions": { + "Key": { + "type": "object", + "properties": { + "name": { + "type": "string", + "readOnly": true + } + } + }, + "KeyValue": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "label": { + "type": "string" + }, + "content_type": { + "type": "string" + }, + "value": { + "type": "string" + }, + "last_modified": { + "format": "date-time", + "type": "string" + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "locked": { + "type": "boolean" + }, + "etag": { + "type": "string" + } + } + }, + "Label": { + "type": "object", + "properties": { + "name": { + "type": "string", + "readOnly": true + } + } + }, + "Error": { + "description": "Azure App Configuration error object.", + "properties": { + "type": { + "description": "The type of the error.", + "type": "string" + }, + "title": { + "description": "A brief summary of the error.", + "type": "string" + }, + "name": { + "description": "The name of the parameter that resulted in the error.", + "type": "string" + }, + "detail": { + "description": "A detailed description of the error.", + "type": "string" + }, + "status": { + "description": "The HTTP status code that the error maps to.", + "type": "integer" + } + }, + "readOnly": true + }, + "KeyListResult": { + "description": "The result of a list request.", + "type": "object", + "properties": { + "items": { + "description": "The collection value.", + "type": "array", + "items": { + "$ref": "#/definitions/Key" + } + }, + "@nextLink": { + "description": "The URI that can be used to request the next set of paged results.", + "type": "string" + } + } + }, + "KeyValueListResult": { + "description": "The result of a list request.", + "type": "object", + "properties": { + "items": { + "description": "The collection value.", + "type": "array", + "items": { + "$ref": "#/definitions/KeyValue" + } + }, + "@nextLink": { + "description": "The URI that can be used to request the next set of paged results.", + "type": "string" + } + } + }, + "LabelListResult": { + "description": "The result of a list request.", + "type": "object", + "properties": { + "items": { + "description": "The collection value.", + "type": "array", + "items": { + "$ref": "#/definitions/Label" + } + }, + "@nextLink": { + "description": "The URI that can be used to request the next set of paged results.", + "type": "string" + } + } + } + }, + "parameters": { + "SyncTokens": { + "name": "Sync-Token", + "in": "header", + "description": "Used to guarantee real-time consistency between requests.", + "type": "string" + }, + "ApiVersion": { + "name": "api-version", + "in": "query", + "description": "The API version to be used with the HTTP request.", + "required": true, + "type": "string" + }, + "Endpoint": { + "name": "endpoint", + "in": "path", + "description": "The endpoint of the App Configuration instance to send requests to.", + "required": true, + "type": "string", + "x-ms-skip-url-encoding": true, + "x-ms-parameter-location": "client" + } + }, + "x-ms-parameterized-host": { + "hostTemplate": "{endpoint}", + "useSchemePrefix": false, + "parameters": [ + { + "$ref": "#/parameters/Endpoint" + } + ] + } +} diff --git a/sdk/api-learn/ci.yml b/sdk/api-learn/ci.yml new file mode 100644 index 000000000000..1e07d8fd5218 --- /dev/null +++ b/sdk/api-learn/ci.yml @@ -0,0 +1,33 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - master + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/api-learn/ + - eng/common/ + +pr: + branches: + include: + - master + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/api-learn/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: api-learn + Artifacts: + - name: azure_learnappconfig + safeName: azurelearnappconfig diff --git a/sdk/api-learn/tests.yml b/sdk/api-learn/tests.yml new file mode 100644 index 000000000000..23005eb6c08c --- /dev/null +++ b/sdk/api-learn/tests.yml @@ -0,0 +1,13 @@ +trigger: none + +jobs: + - template: ../../eng/pipelines/templates/jobs/archetype-sdk-tests.yml + parameters: + AllocateResourceGroup: 'false' + BuildTargetingString: $(BuildTargetingString) + ServiceDirectory: api-learn + EnvVars: + AZURE_CLIENT_ID: $(aad-azure-sdk-test-client-id) + AZURE_CLIENT_SECRET: $(aad-azure-sdk-test-client-secret) + AZURE_TENANT_ID: $(aad-azure-sdk-test-tenant-id) + TEST_MODE: 'RunLiveNoRecord' \ No newline at end of file