diff --git a/sdk/agrifood/azure-mgmt-agrifood/CHANGELOG.md b/sdk/agrifood/azure-mgmt-agrifood/CHANGELOG.md new file mode 100644 index 000000000000..207c85154776 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/CHANGELOG.md @@ -0,0 +1,6 @@ +# Release History + +## 1.0.0b1 (2021-06-09) + +* Initial Release + diff --git a/sdk/agrifood/azure-mgmt-agrifood/MANIFEST.in b/sdk/agrifood/azure-mgmt-agrifood/MANIFEST.in new file mode 100644 index 000000000000..3a9b6517412b --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/MANIFEST.in @@ -0,0 +1,6 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py + diff --git a/sdk/agrifood/azure-mgmt-agrifood/README.md b/sdk/agrifood/azure-mgmt-agrifood/README.md new file mode 100644 index 000000000000..3073d0367598 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/README.md @@ -0,0 +1,27 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure Agrifood Management Client Library. +This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [Agrifood Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-agrifood%2FREADME.png) diff --git a/sdk/agrifood/azure-mgmt-agrifood/_meta.json b/sdk/agrifood/azure-mgmt-agrifood/_meta.json new file mode 100644 index 000000000000..b3f2f06ce9d7 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.4.2", + "use": [ + "@autorest/python@5.8.0", + "@autorest/modelerfour@4.19.2" + ], + "commit": "5ee4aa771330a0120416c066386e6d86693978b4", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/agfood/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.0 --use=@autorest/modelerfour@4.19.2 --version=3.4.2", + "readme": "specification/agfood/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/__init__.py b/sdk/agrifood/azure-mgmt-agrifood/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/__init__.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/__init__.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/__init__.py new file mode 100644 index 000000000000..4fcfb2a1473a --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/__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_agri_food_rp_service import AzureAgriFoodRPService +from ._version import VERSION + +__version__ = VERSION +__all__ = ['AzureAgriFoodRPService'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_azure_agri_food_rp_service.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_azure_agri_food_rp_service.py new file mode 100644 index 000000000000..169943642901 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_azure_agri_food_rp_service.py @@ -0,0 +1,108 @@ +# 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.mgmt.core import ARMPipelineClient +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 azure.core.pipeline.transport import HttpRequest, HttpResponse + +from ._configuration import AzureAgriFoodRPServiceConfiguration +from .operations import ExtensionsOperations +from .operations import FarmBeatsExtensionsOperations +from .operations import FarmBeatsModelsOperations +from .operations import LocationsOperations +from .operations import Operations +from . import models + + +class AzureAgriFoodRPService(object): + """APIs documentation for Azure AgriFood Resource Provider Service. + + :ivar extensions: ExtensionsOperations operations + :vartype extensions: azure.mgmt.agrifood.operations.ExtensionsOperations + :ivar farm_beats_extensions: FarmBeatsExtensionsOperations operations + :vartype farm_beats_extensions: azure.mgmt.agrifood.operations.FarmBeatsExtensionsOperations + :ivar farm_beats_models: FarmBeatsModelsOperations operations + :vartype farm_beats_models: azure.mgmt.agrifood.operations.FarmBeatsModelsOperations + :ivar locations: LocationsOperations operations + :vartype locations: azure.mgmt.agrifood.operations.LocationsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.agrifood.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = AzureAgriFoodRPServiceConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.extensions = ExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.farm_beats_extensions = FarmBeatsExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.farm_beats_models = FarmBeatsModelsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.locations = LocationsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AzureAgriFoodRPService + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_configuration.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_configuration.py new file mode 100644 index 000000000000..ed8612f63772 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_configuration.py @@ -0,0 +1,71 @@ +# 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 azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class AzureAgriFoodRPServiceConfiguration(Configuration): + """Configuration for AzureAgriFoodRPService. + + 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 subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(AzureAgriFoodRPServiceConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-05-12-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-agrifood/{}'.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 ARMHttpLoggingPolicy(**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 self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_metadata.json b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_metadata.json new file mode 100644 index 000000000000..cd0d729c4e21 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_metadata.json @@ -0,0 +1,107 @@ +{ + "chosen_version": "2020-05-12-preview", + "total_api_version_list": ["2020-05-12-preview"], + "client": { + "name": "AzureAgriFoodRPService", + "filename": "_azure_agri_food_rp_service", + "description": "APIs documentation for Azure AgriFood Resource Provider Service.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureAgriFoodRPServiceConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureAgriFoodRPServiceConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "extensions": "ExtensionsOperations", + "farm_beats_extensions": "FarmBeatsExtensionsOperations", + "farm_beats_models": "FarmBeatsModelsOperations", + "locations": "LocationsOperations", + "operations": "Operations" + } +} \ No newline at end of file diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_version.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_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.0b1" diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/__init__.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/__init__.py new file mode 100644 index 000000000000..c487b62feac1 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/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_agri_food_rp_service import AzureAgriFoodRPService +__all__ = ['AzureAgriFoodRPService'] diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/_azure_agri_food_rp_service.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/_azure_agri_food_rp_service.py new file mode 100644 index 000000000000..70ef0291a186 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/_azure_agri_food_rp_service.py @@ -0,0 +1,101 @@ +# 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import AzureAgriFoodRPServiceConfiguration +from .operations import ExtensionsOperations +from .operations import FarmBeatsExtensionsOperations +from .operations import FarmBeatsModelsOperations +from .operations import LocationsOperations +from .operations import Operations +from .. import models + + +class AzureAgriFoodRPService(object): + """APIs documentation for Azure AgriFood Resource Provider Service. + + :ivar extensions: ExtensionsOperations operations + :vartype extensions: azure.mgmt.agrifood.aio.operations.ExtensionsOperations + :ivar farm_beats_extensions: FarmBeatsExtensionsOperations operations + :vartype farm_beats_extensions: azure.mgmt.agrifood.aio.operations.FarmBeatsExtensionsOperations + :ivar farm_beats_models: FarmBeatsModelsOperations operations + :vartype farm_beats_models: azure.mgmt.agrifood.aio.operations.FarmBeatsModelsOperations + :ivar locations: LocationsOperations operations + :vartype locations: azure.mgmt.agrifood.aio.operations.LocationsOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.agrifood.aio.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = AzureAgriFoodRPServiceConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.extensions = ExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.farm_beats_extensions = FarmBeatsExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.farm_beats_models = FarmBeatsModelsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.locations = LocationsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AzureAgriFoodRPService": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/_configuration.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/_configuration.py new file mode 100644 index 000000000000..a6d4c3c11f1a --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/_configuration.py @@ -0,0 +1,67 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AzureAgriFoodRPServiceConfiguration(Configuration): + """Configuration for AzureAgriFoodRPService. + + 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 subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(AzureAgriFoodRPServiceConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-05-12-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-agrifood/{}'.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 ARMHttpLoggingPolicy(**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 self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/__init__.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/__init__.py new file mode 100644 index 000000000000..e652e7185ae6 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/__init__.py @@ -0,0 +1,21 @@ +# 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 ._extensions_operations import ExtensionsOperations +from ._farm_beats_extensions_operations import FarmBeatsExtensionsOperations +from ._farm_beats_models_operations import FarmBeatsModelsOperations +from ._locations_operations import LocationsOperations +from ._operations import Operations + +__all__ = [ + 'ExtensionsOperations', + 'FarmBeatsExtensionsOperations', + 'FarmBeatsModelsOperations', + 'LocationsOperations', + 'Operations', +] diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_extensions_operations.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_extensions_operations.py new file mode 100644 index 000000000000..c0a08187a777 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_extensions_operations.py @@ -0,0 +1,387 @@ +# 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 +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ExtensionsOperations: + """ExtensionsOperations 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.mgmt.agrifood.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 create( + self, + extension_id: str, + farm_beats_resource_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.Extension": + """Install extension. + + :param extension_id: Id of extension resource. + :type extension_id: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.Extension + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'extensionId': self._serialize.url("extension_id", extension_id, 'str'), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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 [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Extension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}'} # type: ignore + + async def get( + self, + extension_id: str, + farm_beats_resource_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.Extension": + """Get installed extension details by extension id. + + :param extension_id: Id of extension resource. + :type extension_id: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.Extension + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'extensionId': self._serialize.url("extension_id", extension_id, 'str'), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Extension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}'} # type: ignore + + async def update( + self, + extension_id: str, + farm_beats_resource_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.Extension": + """Upgrade to latest extension. + + :param extension_id: Id of extension resource. + :type extension_id: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.Extension + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'extensionId': self._serialize.url("extension_id", extension_id, 'str'), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.patch(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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Extension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}'} # type: ignore + + async def delete( + self, + extension_id: str, + farm_beats_resource_name: str, + resource_group_name: str, + **kwargs: Any + ) -> None: + """Uninstall extension. + + :param extension_id: Id of extension resource. + :type extension_id: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'extensionId': self._serialize.url("extension_id", extension_id, 'str'), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}'} # type: ignore + + def list_by_farm_beats( + self, + resource_group_name: str, + farm_beats_resource_name: str, + extension_ids: Optional[List[str]] = None, + extension_categories: Optional[List[str]] = None, + max_page_size: Optional[int] = 50, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ExtensionListResponse"]: + """Get installed extensions details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param extension_ids: Installed extension ids. + :type extension_ids: list[str] + :param extension_categories: Installed extension categories. + :type extension_categories: list[str] + :param max_page_size: Maximum number of items needed (inclusive). + Minimum = 10, Maximum = 1000, Default value = 50. + :type max_page_size: int + :param skip_token: Skip token for getting next set of results. + :type skip_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.agrifood.models.ExtensionListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_farm_beats.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if extension_ids is not None: + query_parameters['extensionIds'] = [self._serialize.query("extension_ids", q, 'str') if q is not None else '' for q in extension_ids] + if extension_categories is not None: + query_parameters['extensionCategories'] = [self._serialize.query("extension_categories", q, 'str') if q is not None else '' for q in extension_categories] + if max_page_size is not None: + query_parameters['$maxPageSize'] = self._serialize.query("max_page_size", max_page_size, 'int', maximum=1000, minimum=10) + if skip_token is not None: + query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ExtensionListResponse', pipeline_response) + list_of_elem = deserialized.value + 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.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_farm_beats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions'} # type: ignore diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_farm_beats_extensions_operations.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_farm_beats_extensions_operations.py new file mode 100644 index 000000000000..3eac9ce7992b --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_farm_beats_extensions_operations.py @@ -0,0 +1,185 @@ +# 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 +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class FarmBeatsExtensionsOperations: + """FarmBeatsExtensionsOperations 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.mgmt.agrifood.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 + + def list( + self, + farm_beats_extension_ids: Optional[List[str]] = None, + farm_beats_extension_names: Optional[List[str]] = None, + extension_categories: Optional[List[str]] = None, + publisher_ids: Optional[List[str]] = None, + max_page_size: Optional[int] = 50, + **kwargs: Any + ) -> AsyncIterable["_models.FarmBeatsExtensionListResponse"]: + """Get list of farmBeats extension. + + :param farm_beats_extension_ids: FarmBeatsExtension ids. + :type farm_beats_extension_ids: list[str] + :param farm_beats_extension_names: FarmBeats extension names. + :type farm_beats_extension_names: list[str] + :param extension_categories: Extension categories. + :type extension_categories: list[str] + :param publisher_ids: Publisher ids. + :type publisher_ids: list[str] + :param max_page_size: Maximum number of items needed (inclusive). + Minimum = 10, Maximum = 1000, Default value = 50. + :type max_page_size: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FarmBeatsExtensionListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.agrifood.models.FarmBeatsExtensionListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeatsExtensionListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if farm_beats_extension_ids is not None: + query_parameters['farmBeatsExtensionIds'] = [self._serialize.query("farm_beats_extension_ids", q, 'str') if q is not None else '' for q in farm_beats_extension_ids] + if farm_beats_extension_names is not None: + query_parameters['farmBeatsExtensionNames'] = [self._serialize.query("farm_beats_extension_names", q, 'str') if q is not None else '' for q in farm_beats_extension_names] + if extension_categories is not None: + query_parameters['extensionCategories'] = [self._serialize.query("extension_categories", q, 'str') if q is not None else '' for q in extension_categories] + if publisher_ids is not None: + query_parameters['publisherIds'] = [self._serialize.query("publisher_ids", q, 'str') if q is not None else '' for q in publisher_ids] + if max_page_size is not None: + query_parameters['$maxPageSize'] = self._serialize.query("max_page_size", max_page_size, 'int', maximum=1000, minimum=10) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('FarmBeatsExtensionListResponse', pipeline_response) + list_of_elem = deserialized.value + 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.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.AgFoodPlatform/farmBeatsExtensionDefinitions'} # type: ignore + + async def get( + self, + farm_beats_extension_id: str, + **kwargs: Any + ) -> "_models.FarmBeatsExtension": + """Get farmBeats extension. + + :param farm_beats_extension_id: farmBeatsExtensionId to be queried. + :type farm_beats_extension_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FarmBeatsExtension, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.FarmBeatsExtension + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeatsExtension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'farmBeatsExtensionId': self._serialize.url("farm_beats_extension_id", farm_beats_extension_id, 'str', pattern=r'^[A-za-z]{3,50}[.][A-za-z]{3,100}$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FarmBeatsExtension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.AgFoodPlatform/farmBeatsExtensionDefinitions/{farmBeatsExtensionId}'} # type: ignore diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_farm_beats_models_operations.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_farm_beats_models_operations.py new file mode 100644 index 000000000000..9130a4e1c96a --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_farm_beats_models_operations.py @@ -0,0 +1,455 @@ +# 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, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class FarmBeatsModelsOperations: + """FarmBeatsModelsOperations 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.mgmt.agrifood.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 get( + self, + resource_group_name: str, + farm_beats_resource_name: str, + **kwargs: Any + ) -> "_models.FarmBeats": + """Get FarmBeats resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FarmBeats, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.FarmBeats + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeats"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FarmBeats', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}'} # type: ignore + + async def create_or_update( + self, + farm_beats_resource_name: str, + resource_group_name: str, + body: "_models.FarmBeats", + **kwargs: Any + ) -> "_models.FarmBeats": + """Create or update FarmBeats resource. + + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param body: FarmBeats resource create or update request object. + :type body: ~azure.mgmt.agrifood.models.FarmBeats + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FarmBeats, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.FarmBeats + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeats"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'FarmBeats') + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('FarmBeats', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('FarmBeats', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}'} # type: ignore + + async def update( + self, + farm_beats_resource_name: str, + resource_group_name: str, + body: "_models.FarmBeatsUpdateRequestModel", + **kwargs: Any + ) -> "_models.FarmBeats": + """Update a FarmBeats resource. + + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param body: Request object. + :type body: ~azure.mgmt.agrifood.models.FarmBeatsUpdateRequestModel + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FarmBeats, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.FarmBeats + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeats"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'FarmBeatsUpdateRequestModel') + body_content_kwargs['content'] = body_content + request = self._client.patch(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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FarmBeats', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + farm_beats_resource_name: str, + **kwargs: Any + ) -> None: + """Delete a FarmBeats resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}'} # type: ignore + + def list_by_subscription( + self, + max_page_size: Optional[int] = 50, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.FarmBeatsListResponse"]: + """Lists the FarmBeats instances for a subscription. + + :param max_page_size: Maximum number of items needed (inclusive). + Minimum = 10, Maximum = 1000, Default value = 50. + :type max_page_size: int + :param skip_token: Skip token for getting next set of results. + :type skip_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FarmBeatsListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.agrifood.models.FarmBeatsListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeatsListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if max_page_size is not None: + query_parameters['$maxPageSize'] = self._serialize.query("max_page_size", max_page_size, 'int', maximum=1000, minimum=10) + if skip_token is not None: + query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('FarmBeatsListResponse', pipeline_response) + list_of_elem = deserialized.value + 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.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AgFoodPlatform/farmBeats'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + max_page_size: Optional[int] = 50, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.FarmBeatsListResponse"]: + """Lists the FarmBeats instances for a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param max_page_size: Maximum number of items needed (inclusive). + Minimum = 10, Maximum = 1000, Default value = 50. + :type max_page_size: int + :param skip_token: Continuation token for getting next set of results. + :type skip_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FarmBeatsListResponse or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.agrifood.models.FarmBeatsListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeatsListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if max_page_size is not None: + query_parameters['$maxPageSize'] = self._serialize.query("max_page_size", max_page_size, 'int', maximum=1000, minimum=10) + if skip_token is not None: + query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('FarmBeatsListResponse', pipeline_response) + list_of_elem = deserialized.value + 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.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats'} # type: ignore diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_locations_operations.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_locations_operations.py new file mode 100644 index 000000000000..8945fd477bef --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_locations_operations.py @@ -0,0 +1,100 @@ +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class LocationsOperations: + """LocationsOperations 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.mgmt.agrifood.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 check_name_availability( + self, + body: "_models.CheckNameAvailabilityRequest", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResponse": + """Checks the name availability of the resource with requested resource name. + + :param body: NameAvailabilityRequest object. + :type body: ~azure.mgmt.agrifood.models.CheckNameAvailabilityRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.CheckNameAvailabilityResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_name_availability.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'CheckNameAvailabilityRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CheckNameAvailabilityResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AgFoodPlatform/checkNameAvailability'} # type: ignore diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_operations.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_operations.py new file mode 100644 index 000000000000..b06846411fb4 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/aio/operations/_operations.py @@ -0,0 +1,105 @@ +# 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, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations 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.mgmt.agrifood.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 + + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """Lists the available operations of Microsoft.AgFoodPlatform resource provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.agrifood.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + 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.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.AgFoodPlatform/operations'} # type: ignore diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/models/__init__.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/models/__init__.py new file mode 100644 index 000000000000..1fd95721b298 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/models/__init__.py @@ -0,0 +1,89 @@ +# 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 CheckNameAvailabilityRequest + from ._models_py3 import CheckNameAvailabilityResponse + from ._models_py3 import DetailedInformation + from ._models_py3 import ErrorAdditionalInfo + from ._models_py3 import ErrorDetail + from ._models_py3 import ErrorResponse + from ._models_py3 import Extension + from ._models_py3 import ExtensionListResponse + from ._models_py3 import FarmBeats + from ._models_py3 import FarmBeatsExtension + from ._models_py3 import FarmBeatsExtensionListResponse + from ._models_py3 import FarmBeatsListResponse + from ._models_py3 import FarmBeatsUpdateRequestModel + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult + from ._models_py3 import ProxyResource + from ._models_py3 import Resource + from ._models_py3 import SystemData + from ._models_py3 import TrackedResource + from ._models_py3 import UnitSystemsInfo +except (SyntaxError, ImportError): + from ._models import CheckNameAvailabilityRequest # type: ignore + from ._models import CheckNameAvailabilityResponse # type: ignore + from ._models import DetailedInformation # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorDetail # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import Extension # type: ignore + from ._models import ExtensionListResponse # type: ignore + from ._models import FarmBeats # type: ignore + from ._models import FarmBeatsExtension # type: ignore + from ._models import FarmBeatsExtensionListResponse # type: ignore + from ._models import FarmBeatsListResponse # type: ignore + from ._models import FarmBeatsUpdateRequestModel # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ProxyResource # type: ignore + from ._models import Resource # type: ignore + from ._models import SystemData # type: ignore + from ._models import TrackedResource # type: ignore + from ._models import UnitSystemsInfo # type: ignore + +from ._azure_agri_food_rp_service_enums import ( + ActionType, + CheckNameAvailabilityReason, + CreatedByType, + Origin, + ProvisioningState, +) + +__all__ = [ + 'CheckNameAvailabilityRequest', + 'CheckNameAvailabilityResponse', + 'DetailedInformation', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'Extension', + 'ExtensionListResponse', + 'FarmBeats', + 'FarmBeatsExtension', + 'FarmBeatsExtensionListResponse', + 'FarmBeatsListResponse', + 'FarmBeatsUpdateRequestModel', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'ProxyResource', + 'Resource', + 'SystemData', + 'TrackedResource', + 'UnitSystemsInfo', + 'ActionType', + 'CheckNameAvailabilityReason', + 'CreatedByType', + 'Origin', + 'ProvisioningState', +] diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/models/_azure_agri_food_rp_service_enums.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/models/_azure_agri_food_rp_service_enums.py new file mode 100644 index 000000000000..ab2c44fae3be --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/models/_azure_agri_food_rp_service_enums.py @@ -0,0 +1,65 @@ +# 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 ActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class CheckNameAvailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The reason why the given name is not available. + """ + + INVALID = "Invalid" + ALREADY_EXISTS = "AlreadyExists" + +class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class Origin(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """FarmBeats instance provisioning state. + """ + + SUCCEEDED = "Succeeded" + FAILED = "Failed" diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/models/_models.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/models/_models.py new file mode 100644 index 000000000000..0cbcff067e3e --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/models/_models.py @@ -0,0 +1,830 @@ +# 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 CheckNameAvailabilityRequest(msrest.serialization.Model): + """The check availability request body. + + :param name: The name of the resource for which availability needs to be checked. + :type name: str + :param type: The resource type. + :type type: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CheckNameAvailabilityRequest, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.type = kwargs.get('type', None) + + +class CheckNameAvailabilityResponse(msrest.serialization.Model): + """The check availability result. + + :param name_available: Indicates if the resource name is available. + :type name_available: bool + :param reason: The reason why the given name is not available. Possible values include: + "Invalid", "AlreadyExists". + :type reason: str or ~azure.mgmt.agrifood.models.CheckNameAvailabilityReason + :param message: Detailed reason why the given name is available. + :type message: str + """ + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CheckNameAvailabilityResponse, self).__init__(**kwargs) + self.name_available = kwargs.get('name_available', None) + self.reason = kwargs.get('reason', None) + self.message = kwargs.get('message', None) + + +class DetailedInformation(msrest.serialization.Model): + """Model to capture detailed information for farmBeatsExtensions. + + :param api_name: ApiName available for the farmBeatsExtension. + :type api_name: str + :param custom_parameters: List of customParameters. + :type custom_parameters: list[str] + :param platform_parameters: List of platformParameters. + :type platform_parameters: list[str] + :param units_supported: Unit systems info for the data provider. + :type units_supported: ~azure.mgmt.agrifood.models.UnitSystemsInfo + :param api_input_parameters: List of apiInputParameters. + :type api_input_parameters: list[str] + """ + + _attribute_map = { + 'api_name': {'key': 'apiName', 'type': 'str'}, + 'custom_parameters': {'key': 'customParameters', 'type': '[str]'}, + 'platform_parameters': {'key': 'platformParameters', 'type': '[str]'}, + 'units_supported': {'key': 'unitsSupported', 'type': 'UnitSystemsInfo'}, + 'api_input_parameters': {'key': 'apiInputParameters', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(DetailedInformation, self).__init__(**kwargs) + self.api_name = kwargs.get('api_name', None) + self.custom_parameters = kwargs.get('custom_parameters', None) + self.platform_parameters = kwargs.get('platform_parameters', None) + self.units_supported = kwargs.get('units_supported', None) + self.api_input_parameters = kwargs.get('api_input_parameters', None) + + +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.agrifood.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.agrifood.models.ErrorAdditionalInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :param error: The error object. + :type error: ~azure.mgmt.agrifood.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProxyResource, self).__init__(**kwargs) + + +class Extension(ProxyResource): + """Extension resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.agrifood.models.SystemData + :ivar e_tag: The ETag value to implement optimistic concurrency. + :vartype e_tag: str + :ivar extension_id: Extension Id. + :vartype extension_id: str + :ivar extension_category: Extension category. e.g. weather/sensor/satellite. + :vartype extension_category: str + :ivar installed_extension_version: Installed extension version. + :vartype installed_extension_version: str + :ivar extension_auth_link: Extension auth link. + :vartype extension_auth_link: str + :ivar extension_api_docs_link: Extension api docs link. + :vartype extension_api_docs_link: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'e_tag': {'readonly': True}, + 'extension_id': {'readonly': True, 'pattern': r'^[A-za-z]{3,50}[.][A-za-z]{3,100}$'}, + 'extension_category': {'readonly': True}, + 'installed_extension_version': {'readonly': True, 'pattern': r'^([1-9]|10).\d$'}, + 'extension_auth_link': {'readonly': True}, + 'extension_api_docs_link': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'extension_id': {'key': 'properties.extensionId', 'type': 'str'}, + 'extension_category': {'key': 'properties.extensionCategory', 'type': 'str'}, + 'installed_extension_version': {'key': 'properties.installedExtensionVersion', 'type': 'str'}, + 'extension_auth_link': {'key': 'properties.extensionAuthLink', 'type': 'str'}, + 'extension_api_docs_link': {'key': 'properties.extensionApiDocsLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Extension, self).__init__(**kwargs) + self.system_data = None + self.e_tag = None + self.extension_id = None + self.extension_category = None + self.installed_extension_version = None + self.extension_auth_link = None + self.extension_api_docs_link = None + + +class ExtensionListResponse(msrest.serialization.Model): + """Paged response contains list of requested objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: List of requested objects. + :type value: list[~azure.mgmt.agrifood.models.Extension] + :ivar next_link: Continuation link (absolute URI) to the next page of results in the list. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Extension]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExtensionListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + + 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 id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: Required. The geo-location where the resource lives. + :type location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TrackedResource, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.location = kwargs['location'] + + +class FarmBeats(TrackedResource): + """FarmBeats ARM Resource. + + 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 id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: Required. The geo-location where the resource lives. + :type location: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.agrifood.models.SystemData + :ivar instance_uri: Uri of the FarmBeats instance. + :vartype instance_uri: str + :ivar provisioning_state: FarmBeats instance provisioning state. Possible values include: + "Succeeded", "Failed". + :vartype provisioning_state: str or ~azure.mgmt.agrifood.models.ProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'instance_uri': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'instance_uri': {'key': 'properties.instanceUri', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(FarmBeats, self).__init__(**kwargs) + self.system_data = None + self.instance_uri = None + self.provisioning_state = None + + +class FarmBeatsExtension(ProxyResource): + """FarmBeats extension resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.agrifood.models.SystemData + :ivar target_resource_type: Target ResourceType of the farmBeatsExtension. + :vartype target_resource_type: str + :ivar farm_beats_extension_id: FarmBeatsExtension ID. + :vartype farm_beats_extension_id: str + :ivar farm_beats_extension_name: FarmBeatsExtension name. + :vartype farm_beats_extension_name: str + :ivar farm_beats_extension_version: FarmBeatsExtension version. + :vartype farm_beats_extension_version: str + :ivar publisher_id: Publisher ID. + :vartype publisher_id: str + :ivar description: Textual description. + :vartype description: str + :ivar extension_category: Category of the extension. e.g. weather/sensor/satellite. + :vartype extension_category: str + :ivar extension_auth_link: FarmBeatsExtension auth link. + :vartype extension_auth_link: str + :ivar extension_api_docs_link: FarmBeatsExtension api docs link. + :vartype extension_api_docs_link: str + :ivar detailed_information: Detailed information which shows summary of requested data. + Used in descriptive get extension metadata call. + Information for weather category per api included are apisSupported, + customParameters, PlatformParameters and Units supported. + :vartype detailed_information: list[~azure.mgmt.agrifood.models.DetailedInformation] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'target_resource_type': {'readonly': True}, + 'farm_beats_extension_id': {'readonly': True, 'max_length': 100, 'min_length': 2, 'pattern': r'^[A-za-z]{3,50}[.][A-za-z]{3,100}$'}, + 'farm_beats_extension_name': {'readonly': True, 'max_length': 100, 'min_length': 2}, + 'farm_beats_extension_version': {'readonly': True, 'max_length': 100, 'min_length': 2, 'pattern': r'^([1-9]|10).\d$'}, + 'publisher_id': {'readonly': True, 'max_length': 100, 'min_length': 2}, + 'description': {'readonly': True, 'max_length': 500, 'min_length': 2}, + 'extension_category': {'readonly': True, 'max_length': 100, 'min_length': 2}, + 'extension_auth_link': {'readonly': True}, + 'extension_api_docs_link': {'readonly': True}, + 'detailed_information': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'target_resource_type': {'key': 'properties.targetResourceType', 'type': 'str'}, + 'farm_beats_extension_id': {'key': 'properties.farmBeatsExtensionId', 'type': 'str'}, + 'farm_beats_extension_name': {'key': 'properties.farmBeatsExtensionName', 'type': 'str'}, + 'farm_beats_extension_version': {'key': 'properties.farmBeatsExtensionVersion', 'type': 'str'}, + 'publisher_id': {'key': 'properties.publisherId', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'extension_category': {'key': 'properties.extensionCategory', 'type': 'str'}, + 'extension_auth_link': {'key': 'properties.extensionAuthLink', 'type': 'str'}, + 'extension_api_docs_link': {'key': 'properties.extensionApiDocsLink', 'type': 'str'}, + 'detailed_information': {'key': 'properties.detailedInformation', 'type': '[DetailedInformation]'}, + } + + def __init__( + self, + **kwargs + ): + super(FarmBeatsExtension, self).__init__(**kwargs) + self.system_data = None + self.target_resource_type = None + self.farm_beats_extension_id = None + self.farm_beats_extension_name = None + self.farm_beats_extension_version = None + self.publisher_id = None + self.description = None + self.extension_category = None + self.extension_auth_link = None + self.extension_api_docs_link = None + self.detailed_information = None + + +class FarmBeatsExtensionListResponse(msrest.serialization.Model): + """Paged response contains list of requested objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: List of requested objects. + :type value: list[~azure.mgmt.agrifood.models.FarmBeatsExtension] + :ivar next_link: Continuation link (absolute URI) to the next page of results in the list. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[FarmBeatsExtension]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(FarmBeatsExtensionListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class FarmBeatsListResponse(msrest.serialization.Model): + """Paged response contains list of requested objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: List of requested objects. + :type value: list[~azure.mgmt.agrifood.models.FarmBeats] + :ivar next_link: Continuation link (absolute URI) to the next page of results in the list. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[FarmBeats]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(FarmBeatsListResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class FarmBeatsUpdateRequestModel(msrest.serialization.Model): + """FarmBeats update request. + + :param location: Geo-location where the resource lives. + :type location: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(FarmBeatsUpdateRequestModel, self).__init__(**kwargs) + self.location = kwargs.get('location', None) + self.tags = kwargs.get('tags', None) + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :param display: Localized display information for this particular operation. + :type display: ~azure.mgmt.agrifood.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", + "system", "user,system". + :vartype origin: str or ~azure.mgmt.agrifood.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Possible values include: "Internal". + :vartype action_type: str or ~azure.mgmt.agrifood.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = kwargs.get('display', None) + self.origin = None + self.action_type = None + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.agrifood.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~azure.mgmt.agrifood.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~azure.mgmt.agrifood.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(SystemData, self).__init__(**kwargs) + self.created_by = kwargs.get('created_by', None) + self.created_by_type = kwargs.get('created_by_type', None) + self.created_at = kwargs.get('created_at', None) + self.last_modified_by = kwargs.get('last_modified_by', None) + self.last_modified_by_type = kwargs.get('last_modified_by_type', None) + self.last_modified_at = kwargs.get('last_modified_at', None) + + +class UnitSystemsInfo(msrest.serialization.Model): + """Unit systems info for the data provider. + + All required parameters must be populated in order to send to Azure. + + :param key: Required. UnitSystem key sent as part of ProviderInput. + :type key: str + :param values: Required. List of unit systems supported by this data provider. + :type values: list[str] + """ + + _validation = { + 'key': {'required': True, 'max_length': 100, 'min_length': 2}, + 'values': {'required': True}, + } + + _attribute_map = { + 'key': {'key': 'key', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(UnitSystemsInfo, self).__init__(**kwargs) + self.key = kwargs['key'] + self.values = kwargs['values'] diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/models/_models_py3.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/models/_models_py3.py new file mode 100644 index 000000000000..1caf4a77a5cf --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/models/_models_py3.py @@ -0,0 +1,877 @@ +# 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, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._azure_agri_food_rp_service_enums import * + + +class CheckNameAvailabilityRequest(msrest.serialization.Model): + """The check availability request body. + + :param name: The name of the resource for which availability needs to be checked. + :type name: str + :param type: The resource type. + :type type: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + super(CheckNameAvailabilityRequest, self).__init__(**kwargs) + self.name = name + self.type = type + + +class CheckNameAvailabilityResponse(msrest.serialization.Model): + """The check availability result. + + :param name_available: Indicates if the resource name is available. + :type name_available: bool + :param reason: The reason why the given name is not available. Possible values include: + "Invalid", "AlreadyExists". + :type reason: str or ~azure.mgmt.agrifood.models.CheckNameAvailabilityReason + :param message: Detailed reason why the given name is available. + :type message: str + """ + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + name_available: Optional[bool] = None, + reason: Optional[Union[str, "CheckNameAvailabilityReason"]] = None, + message: Optional[str] = None, + **kwargs + ): + super(CheckNameAvailabilityResponse, self).__init__(**kwargs) + self.name_available = name_available + self.reason = reason + self.message = message + + +class DetailedInformation(msrest.serialization.Model): + """Model to capture detailed information for farmBeatsExtensions. + + :param api_name: ApiName available for the farmBeatsExtension. + :type api_name: str + :param custom_parameters: List of customParameters. + :type custom_parameters: list[str] + :param platform_parameters: List of platformParameters. + :type platform_parameters: list[str] + :param units_supported: Unit systems info for the data provider. + :type units_supported: ~azure.mgmt.agrifood.models.UnitSystemsInfo + :param api_input_parameters: List of apiInputParameters. + :type api_input_parameters: list[str] + """ + + _attribute_map = { + 'api_name': {'key': 'apiName', 'type': 'str'}, + 'custom_parameters': {'key': 'customParameters', 'type': '[str]'}, + 'platform_parameters': {'key': 'platformParameters', 'type': '[str]'}, + 'units_supported': {'key': 'unitsSupported', 'type': 'UnitSystemsInfo'}, + 'api_input_parameters': {'key': 'apiInputParameters', 'type': '[str]'}, + } + + def __init__( + self, + *, + api_name: Optional[str] = None, + custom_parameters: Optional[List[str]] = None, + platform_parameters: Optional[List[str]] = None, + units_supported: Optional["UnitSystemsInfo"] = None, + api_input_parameters: Optional[List[str]] = None, + **kwargs + ): + super(DetailedInformation, self).__init__(**kwargs) + self.api_name = api_name + self.custom_parameters = custom_parameters + self.platform_parameters = platform_parameters + self.units_supported = units_supported + self.api_input_parameters = api_input_parameters + + +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.agrifood.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.agrifood.models.ErrorAdditionalInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :param error: The error object. + :type error: ~azure.mgmt.agrifood.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProxyResource, self).__init__(**kwargs) + + +class Extension(ProxyResource): + """Extension resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.agrifood.models.SystemData + :ivar e_tag: The ETag value to implement optimistic concurrency. + :vartype e_tag: str + :ivar extension_id: Extension Id. + :vartype extension_id: str + :ivar extension_category: Extension category. e.g. weather/sensor/satellite. + :vartype extension_category: str + :ivar installed_extension_version: Installed extension version. + :vartype installed_extension_version: str + :ivar extension_auth_link: Extension auth link. + :vartype extension_auth_link: str + :ivar extension_api_docs_link: Extension api docs link. + :vartype extension_api_docs_link: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'e_tag': {'readonly': True}, + 'extension_id': {'readonly': True, 'pattern': r'^[A-za-z]{3,50}[.][A-za-z]{3,100}$'}, + 'extension_category': {'readonly': True}, + 'installed_extension_version': {'readonly': True, 'pattern': r'^([1-9]|10).\d$'}, + 'extension_auth_link': {'readonly': True}, + 'extension_api_docs_link': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'extension_id': {'key': 'properties.extensionId', 'type': 'str'}, + 'extension_category': {'key': 'properties.extensionCategory', 'type': 'str'}, + 'installed_extension_version': {'key': 'properties.installedExtensionVersion', 'type': 'str'}, + 'extension_auth_link': {'key': 'properties.extensionAuthLink', 'type': 'str'}, + 'extension_api_docs_link': {'key': 'properties.extensionApiDocsLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Extension, self).__init__(**kwargs) + self.system_data = None + self.e_tag = None + self.extension_id = None + self.extension_category = None + self.installed_extension_version = None + self.extension_auth_link = None + self.extension_api_docs_link = None + + +class ExtensionListResponse(msrest.serialization.Model): + """Paged response contains list of requested objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: List of requested objects. + :type value: list[~azure.mgmt.agrifood.models.Extension] + :ivar next_link: Continuation link (absolute URI) to the next page of results in the list. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Extension]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Extension"]] = None, + **kwargs + ): + super(ExtensionListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + + 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 id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: Required. The geo-location where the resource lives. + :type location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(TrackedResource, self).__init__(**kwargs) + self.tags = tags + self.location = location + + +class FarmBeats(TrackedResource): + """FarmBeats ARM Resource. + + 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 id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: Required. The geo-location where the resource lives. + :type location: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.agrifood.models.SystemData + :ivar instance_uri: Uri of the FarmBeats instance. + :vartype instance_uri: str + :ivar provisioning_state: FarmBeats instance provisioning state. Possible values include: + "Succeeded", "Failed". + :vartype provisioning_state: str or ~azure.mgmt.agrifood.models.ProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'instance_uri': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'instance_uri': {'key': 'properties.instanceUri', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(FarmBeats, self).__init__(tags=tags, location=location, **kwargs) + self.system_data = None + self.instance_uri = None + self.provisioning_state = None + + +class FarmBeatsExtension(ProxyResource): + """FarmBeats extension resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.agrifood.models.SystemData + :ivar target_resource_type: Target ResourceType of the farmBeatsExtension. + :vartype target_resource_type: str + :ivar farm_beats_extension_id: FarmBeatsExtension ID. + :vartype farm_beats_extension_id: str + :ivar farm_beats_extension_name: FarmBeatsExtension name. + :vartype farm_beats_extension_name: str + :ivar farm_beats_extension_version: FarmBeatsExtension version. + :vartype farm_beats_extension_version: str + :ivar publisher_id: Publisher ID. + :vartype publisher_id: str + :ivar description: Textual description. + :vartype description: str + :ivar extension_category: Category of the extension. e.g. weather/sensor/satellite. + :vartype extension_category: str + :ivar extension_auth_link: FarmBeatsExtension auth link. + :vartype extension_auth_link: str + :ivar extension_api_docs_link: FarmBeatsExtension api docs link. + :vartype extension_api_docs_link: str + :ivar detailed_information: Detailed information which shows summary of requested data. + Used in descriptive get extension metadata call. + Information for weather category per api included are apisSupported, + customParameters, PlatformParameters and Units supported. + :vartype detailed_information: list[~azure.mgmt.agrifood.models.DetailedInformation] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'target_resource_type': {'readonly': True}, + 'farm_beats_extension_id': {'readonly': True, 'max_length': 100, 'min_length': 2, 'pattern': r'^[A-za-z]{3,50}[.][A-za-z]{3,100}$'}, + 'farm_beats_extension_name': {'readonly': True, 'max_length': 100, 'min_length': 2}, + 'farm_beats_extension_version': {'readonly': True, 'max_length': 100, 'min_length': 2, 'pattern': r'^([1-9]|10).\d$'}, + 'publisher_id': {'readonly': True, 'max_length': 100, 'min_length': 2}, + 'description': {'readonly': True, 'max_length': 500, 'min_length': 2}, + 'extension_category': {'readonly': True, 'max_length': 100, 'min_length': 2}, + 'extension_auth_link': {'readonly': True}, + 'extension_api_docs_link': {'readonly': True}, + 'detailed_information': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'target_resource_type': {'key': 'properties.targetResourceType', 'type': 'str'}, + 'farm_beats_extension_id': {'key': 'properties.farmBeatsExtensionId', 'type': 'str'}, + 'farm_beats_extension_name': {'key': 'properties.farmBeatsExtensionName', 'type': 'str'}, + 'farm_beats_extension_version': {'key': 'properties.farmBeatsExtensionVersion', 'type': 'str'}, + 'publisher_id': {'key': 'properties.publisherId', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'extension_category': {'key': 'properties.extensionCategory', 'type': 'str'}, + 'extension_auth_link': {'key': 'properties.extensionAuthLink', 'type': 'str'}, + 'extension_api_docs_link': {'key': 'properties.extensionApiDocsLink', 'type': 'str'}, + 'detailed_information': {'key': 'properties.detailedInformation', 'type': '[DetailedInformation]'}, + } + + def __init__( + self, + **kwargs + ): + super(FarmBeatsExtension, self).__init__(**kwargs) + self.system_data = None + self.target_resource_type = None + self.farm_beats_extension_id = None + self.farm_beats_extension_name = None + self.farm_beats_extension_version = None + self.publisher_id = None + self.description = None + self.extension_category = None + self.extension_auth_link = None + self.extension_api_docs_link = None + self.detailed_information = None + + +class FarmBeatsExtensionListResponse(msrest.serialization.Model): + """Paged response contains list of requested objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: List of requested objects. + :type value: list[~azure.mgmt.agrifood.models.FarmBeatsExtension] + :ivar next_link: Continuation link (absolute URI) to the next page of results in the list. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[FarmBeatsExtension]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["FarmBeatsExtension"]] = None, + **kwargs + ): + super(FarmBeatsExtensionListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class FarmBeatsListResponse(msrest.serialization.Model): + """Paged response contains list of requested objects and a URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: List of requested objects. + :type value: list[~azure.mgmt.agrifood.models.FarmBeats] + :ivar next_link: Continuation link (absolute URI) to the next page of results in the list. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[FarmBeats]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["FarmBeats"]] = None, + **kwargs + ): + super(FarmBeatsListResponse, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class FarmBeatsUpdateRequestModel(msrest.serialization.Model): + """FarmBeats update request. + + :param location: Geo-location where the resource lives. + :type location: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(FarmBeatsUpdateRequestModel, self).__init__(**kwargs) + self.location = location + self.tags = tags + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :param display: Localized display information for this particular operation. + :type display: ~azure.mgmt.agrifood.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", + "system", "user,system". + :vartype origin: str or ~azure.mgmt.agrifood.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Possible values include: "Internal". + :vartype action_type: str or ~azure.mgmt.agrifood.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["OperationDisplay"] = None, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.agrifood.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~azure.mgmt.agrifood.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~azure.mgmt.agrifood.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class UnitSystemsInfo(msrest.serialization.Model): + """Unit systems info for the data provider. + + All required parameters must be populated in order to send to Azure. + + :param key: Required. UnitSystem key sent as part of ProviderInput. + :type key: str + :param values: Required. List of unit systems supported by this data provider. + :type values: list[str] + """ + + _validation = { + 'key': {'required': True, 'max_length': 100, 'min_length': 2}, + 'values': {'required': True}, + } + + _attribute_map = { + 'key': {'key': 'key', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + } + + def __init__( + self, + *, + key: str, + values: List[str], + **kwargs + ): + super(UnitSystemsInfo, self).__init__(**kwargs) + self.key = key + self.values = values diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/__init__.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/__init__.py new file mode 100644 index 000000000000..e652e7185ae6 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/__init__.py @@ -0,0 +1,21 @@ +# 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 ._extensions_operations import ExtensionsOperations +from ._farm_beats_extensions_operations import FarmBeatsExtensionsOperations +from ._farm_beats_models_operations import FarmBeatsModelsOperations +from ._locations_operations import LocationsOperations +from ._operations import Operations + +__all__ = [ + 'ExtensionsOperations', + 'FarmBeatsExtensionsOperations', + 'FarmBeatsModelsOperations', + 'LocationsOperations', + 'Operations', +] diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_extensions_operations.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_extensions_operations.py new file mode 100644 index 000000000000..74ee8b5017fa --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_extensions_operations.py @@ -0,0 +1,396 @@ +# 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 ClientAuthenticationError, 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ExtensionsOperations(object): + """ExtensionsOperations 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.mgmt.agrifood.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 create( + self, + extension_id, # type: str + farm_beats_resource_name, # type: str + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Extension" + """Install extension. + + :param extension_id: Id of extension resource. + :type extension_id: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.Extension + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'extensionId': self._serialize.url("extension_id", extension_id, 'str'), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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 [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Extension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}'} # type: ignore + + def get( + self, + extension_id, # type: str + farm_beats_resource_name, # type: str + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Extension" + """Get installed extension details by extension id. + + :param extension_id: Id of extension resource. + :type extension_id: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.Extension + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'extensionId': self._serialize.url("extension_id", extension_id, 'str'), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Extension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}'} # type: ignore + + def update( + self, + extension_id, # type: str + farm_beats_resource_name, # type: str + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Extension" + """Upgrade to latest extension. + + :param extension_id: Id of extension resource. + :type extension_id: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Extension, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.Extension + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Extension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'extensionId': self._serialize.url("extension_id", extension_id, 'str'), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.patch(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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Extension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}'} # type: ignore + + def delete( + self, + extension_id, # type: str + farm_beats_resource_name, # type: str + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Uninstall extension. + + :param extension_id: Id of extension resource. + :type extension_id: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'extensionId': self._serialize.url("extension_id", extension_id, 'str'), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}'} # type: ignore + + def list_by_farm_beats( + self, + resource_group_name, # type: str + farm_beats_resource_name, # type: str + extension_ids=None, # type: Optional[List[str]] + extension_categories=None, # type: Optional[List[str]] + max_page_size=50, # type: Optional[int] + skip_token=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ExtensionListResponse"] + """Get installed extensions details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param extension_ids: Installed extension ids. + :type extension_ids: list[str] + :param extension_categories: Installed extension categories. + :type extension_categories: list[str] + :param max_page_size: Maximum number of items needed (inclusive). + Minimum = 10, Maximum = 1000, Default value = 50. + :type max_page_size: int + :param skip_token: Skip token for getting next set of results. + :type skip_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExtensionListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.agrifood.models.ExtensionListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_farm_beats.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if extension_ids is not None: + query_parameters['extensionIds'] = [self._serialize.query("extension_ids", q, 'str') if q is not None else '' for q in extension_ids] + if extension_categories is not None: + query_parameters['extensionCategories'] = [self._serialize.query("extension_categories", q, 'str') if q is not None else '' for q in extension_categories] + if max_page_size is not None: + query_parameters['$maxPageSize'] = self._serialize.query("max_page_size", max_page_size, 'int', maximum=1000, minimum=10) + if skip_token is not None: + query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ExtensionListResponse', pipeline_response) + list_of_elem = deserialized.value + 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.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_farm_beats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions'} # type: ignore diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_farm_beats_extensions_operations.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_farm_beats_extensions_operations.py new file mode 100644 index 000000000000..d101e1342bd7 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_farm_beats_extensions_operations.py @@ -0,0 +1,191 @@ +# 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 ClientAuthenticationError, 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class FarmBeatsExtensionsOperations(object): + """FarmBeatsExtensionsOperations 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.mgmt.agrifood.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, + farm_beats_extension_ids=None, # type: Optional[List[str]] + farm_beats_extension_names=None, # type: Optional[List[str]] + extension_categories=None, # type: Optional[List[str]] + publisher_ids=None, # type: Optional[List[str]] + max_page_size=50, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.FarmBeatsExtensionListResponse"] + """Get list of farmBeats extension. + + :param farm_beats_extension_ids: FarmBeatsExtension ids. + :type farm_beats_extension_ids: list[str] + :param farm_beats_extension_names: FarmBeats extension names. + :type farm_beats_extension_names: list[str] + :param extension_categories: Extension categories. + :type extension_categories: list[str] + :param publisher_ids: Publisher ids. + :type publisher_ids: list[str] + :param max_page_size: Maximum number of items needed (inclusive). + Minimum = 10, Maximum = 1000, Default value = 50. + :type max_page_size: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FarmBeatsExtensionListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.agrifood.models.FarmBeatsExtensionListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeatsExtensionListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if farm_beats_extension_ids is not None: + query_parameters['farmBeatsExtensionIds'] = [self._serialize.query("farm_beats_extension_ids", q, 'str') if q is not None else '' for q in farm_beats_extension_ids] + if farm_beats_extension_names is not None: + query_parameters['farmBeatsExtensionNames'] = [self._serialize.query("farm_beats_extension_names", q, 'str') if q is not None else '' for q in farm_beats_extension_names] + if extension_categories is not None: + query_parameters['extensionCategories'] = [self._serialize.query("extension_categories", q, 'str') if q is not None else '' for q in extension_categories] + if publisher_ids is not None: + query_parameters['publisherIds'] = [self._serialize.query("publisher_ids", q, 'str') if q is not None else '' for q in publisher_ids] + if max_page_size is not None: + query_parameters['$maxPageSize'] = self._serialize.query("max_page_size", max_page_size, 'int', maximum=1000, minimum=10) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('FarmBeatsExtensionListResponse', pipeline_response) + list_of_elem = deserialized.value + 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.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.AgFoodPlatform/farmBeatsExtensionDefinitions'} # type: ignore + + def get( + self, + farm_beats_extension_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.FarmBeatsExtension" + """Get farmBeats extension. + + :param farm_beats_extension_id: farmBeatsExtensionId to be queried. + :type farm_beats_extension_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FarmBeatsExtension, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.FarmBeatsExtension + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeatsExtension"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'farmBeatsExtensionId': self._serialize.url("farm_beats_extension_id", farm_beats_extension_id, 'str', pattern=r'^[A-za-z]{3,50}[.][A-za-z]{3,100}$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FarmBeatsExtension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.AgFoodPlatform/farmBeatsExtensionDefinitions/{farmBeatsExtensionId}'} # type: ignore diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_farm_beats_models_operations.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_farm_beats_models_operations.py new file mode 100644 index 000000000000..e58a1a2cfc2b --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_farm_beats_models_operations.py @@ -0,0 +1,465 @@ +# 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 ClientAuthenticationError, 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class FarmBeatsModelsOperations(object): + """FarmBeatsModelsOperations 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.mgmt.agrifood.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 get( + self, + resource_group_name, # type: str + farm_beats_resource_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.FarmBeats" + """Get FarmBeats resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FarmBeats, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.FarmBeats + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeats"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FarmBeats', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}'} # type: ignore + + def create_or_update( + self, + farm_beats_resource_name, # type: str + resource_group_name, # type: str + body, # type: "_models.FarmBeats" + **kwargs # type: Any + ): + # type: (...) -> "_models.FarmBeats" + """Create or update FarmBeats resource. + + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param body: FarmBeats resource create or update request object. + :type body: ~azure.mgmt.agrifood.models.FarmBeats + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FarmBeats, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.FarmBeats + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeats"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'FarmBeats') + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('FarmBeats', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('FarmBeats', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}'} # type: ignore + + def update( + self, + farm_beats_resource_name, # type: str + resource_group_name, # type: str + body, # type: "_models.FarmBeatsUpdateRequestModel" + **kwargs # type: Any + ): + # type: (...) -> "_models.FarmBeats" + """Update a FarmBeats resource. + + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param body: Request object. + :type body: ~azure.mgmt.agrifood.models.FarmBeatsUpdateRequestModel + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FarmBeats, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.FarmBeats + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeats"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'FarmBeatsUpdateRequestModel') + body_content_kwargs['content'] = body_content + request = self._client.patch(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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FarmBeats', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}'} # type: ignore + + def delete( + self, + resource_group_name, # type: str + farm_beats_resource_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Delete a FarmBeats resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param farm_beats_resource_name: FarmBeats resource name. + :type farm_beats_resource_name: 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'farmBeatsResourceName': self._serialize.url("farm_beats_resource_name", farm_beats_resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + 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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}'} # type: ignore + + def list_by_subscription( + self, + max_page_size=50, # type: Optional[int] + skip_token=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.FarmBeatsListResponse"] + """Lists the FarmBeats instances for a subscription. + + :param max_page_size: Maximum number of items needed (inclusive). + Minimum = 10, Maximum = 1000, Default value = 50. + :type max_page_size: int + :param skip_token: Skip token for getting next set of results. + :type skip_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FarmBeatsListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.agrifood.models.FarmBeatsListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeatsListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if max_page_size is not None: + query_parameters['$maxPageSize'] = self._serialize.query("max_page_size", max_page_size, 'int', maximum=1000, minimum=10) + if skip_token is not None: + query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('FarmBeatsListResponse', pipeline_response) + list_of_elem = deserialized.value + 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.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AgFoodPlatform/farmBeats'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name, # type: str + max_page_size=50, # type: Optional[int] + skip_token=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.FarmBeatsListResponse"] + """Lists the FarmBeats instances for a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param max_page_size: Maximum number of items needed (inclusive). + Minimum = 10, Maximum = 1000, Default value = 50. + :type max_page_size: int + :param skip_token: Continuation token for getting next set of results. + :type skip_token: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FarmBeatsListResponse or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.agrifood.models.FarmBeatsListResponse] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FarmBeatsListResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if max_page_size is not None: + query_parameters['$maxPageSize'] = self._serialize.query("max_page_size", max_page_size, 'int', maximum=1000, minimum=10) + if skip_token is not None: + query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('FarmBeatsListResponse', pipeline_response) + list_of_elem = deserialized.value + 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.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats'} # type: ignore diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_locations_operations.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_locations_operations.py new file mode 100644 index 000000000000..3903612ef1b4 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_locations_operations.py @@ -0,0 +1,105 @@ +# 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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _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 LocationsOperations(object): + """LocationsOperations 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.mgmt.agrifood.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 check_name_availability( + self, + body, # type: "_models.CheckNameAvailabilityRequest" + **kwargs # type: Any + ): + # type: (...) -> "_models.CheckNameAvailabilityResponse" + """Checks the name availability of the resource with requested resource name. + + :param body: NameAvailabilityRequest object. + :type body: ~azure.mgmt.agrifood.models.CheckNameAvailabilityRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse, or the result of cls(response) + :rtype: ~azure.mgmt.agrifood.models.CheckNameAvailabilityResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_name_availability.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'CheckNameAvailabilityRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(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.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CheckNameAvailabilityResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AgFoodPlatform/checkNameAvailability'} # type: ignore diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_operations.py b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_operations.py new file mode 100644 index 000000000000..c781c686e1cc --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/operations/_operations.py @@ -0,0 +1,110 @@ +# 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 ClientAuthenticationError, 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 azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations 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.mgmt.agrifood.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: (...) -> Iterable["_models.OperationListResult"] + """Lists the available operations of Microsoft.AgFoodPlatform resource provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.agrifood.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-05-12-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + 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.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.AgFoodPlatform/operations'} # type: ignore diff --git a/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/py.typed b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/agrifood/azure-mgmt-agrifood/sdk_packaging.toml b/sdk/agrifood/azure-mgmt-agrifood/sdk_packaging.toml new file mode 100644 index 000000000000..5e07c4dc5e2d --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-agrifood" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "Agrifood Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/agrifood/azure-mgmt-agrifood/setup.cfg b/sdk/agrifood/azure-mgmt-agrifood/setup.cfg new file mode 100644 index 000000000000..3c6e79cf31da --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/sdk/agrifood/azure-mgmt-agrifood/setup.py b/sdk/agrifood/azure-mgmt-agrifood/setup.py new file mode 100644 index 000000000000..74805515eb3d --- /dev/null +++ b/sdk/agrifood/azure-mgmt-agrifood/setup.py @@ -0,0 +1,91 @@ +#!/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 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-mgmt-agrifood" +PACKAGE_PPRINT_NAME = "Agrifood Management" + +# 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') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else 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() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client 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', + classifiers=[ + 'Development Status :: 4 - Beta', + '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', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.2.0,<2.0.0', + ], + extras_require={ + ":python_version<'3.0'": ['azure-mgmt-nspkg'], + } +) diff --git a/sdk/agrifood/ci.yml b/sdk/agrifood/ci.yml index bbd71662b521..4ed710c2c98e 100644 --- a/sdk/agrifood/ci.yml +++ b/sdk/agrifood/ci.yml @@ -32,4 +32,6 @@ extends: ServiceDirectory: agrifood Artifacts: - name: azure-agrifood-farming - safeName: azureagrifoodfarming \ No newline at end of file + safeName: azureagrifoodfarming + - name: azure-mgmt-agrifood + safeName: azuremgmtagrifood diff --git a/shared_requirements.txt b/shared_requirements.txt index a2fa759bbadf..11178808ab90 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -310,3 +310,4 @@ opentelemetry-sdk<2.0.0,>=1.0.0 #override azure-mgmt-hdinsight msrest>=0.6.21 #override azure-mgmt-batchai msrest>=0.6.21 #override azure-mgmt-costmanagement msrest>=0.6.21 +#override azure-mgmt-agrifood msrest>=0.6.21