diff --git a/sdk/resources/azure-mgmt-resourcegraph/_meta.json b/sdk/resources/azure-mgmt-resourcegraph/_meta.json index 7f6c0233e380..13dcf65c2198 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/_meta.json +++ b/sdk/resources/azure-mgmt-resourcegraph/_meta.json @@ -1,8 +1,11 @@ { - "autorest": "3.3.0", - "use": "@autorest/python@5.6.6", - "commit": "a144e3b668c2712808ddf0025005cc13becad93a", + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "5a1b7262be0a4f6a9004d35403b854429475cdf4", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/resourcegraph/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.6.6 --version=3.3.0", + "autorest_command": "autorest specification/resourcegraph/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/resourcegraph/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/__init__.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/__init__.py index 7df07d418732..ea96e3ece4be 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/__init__.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ResourceGraphClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_configuration.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_configuration.py index b007839cb9db..0e46905b8b56 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_configuration.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -33,15 +31,15 @@ class ResourceGraphClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(ResourceGraphClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(ResourceGraphClientConfiguration, self).__init__(**kwargs) self.credential = credential + self.api_version = "2021-06-01-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-resourcegraph/{}'.format(VERSION)) self._configure(**kwargs) @@ -61,4 +59,4 @@ def _configure( 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_metadata.json b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_metadata.json index d0d13f7972d3..853196d51b11 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_metadata.json +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "", - "total_api_version_list": ["2020-04-01-preview", "2020-09-01-preview", "2021-03-01"], + "chosen_version": "2021-06-01-preview", + "total_api_version_list": ["2021-06-01-preview"], "client": { "name": "ResourceGraphClient", "filename": "_resource_graph_client", "description": "Azure Resource Graph API Reference.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": 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\": [\"ResourceGraphClientConfiguration\"], \"._operations_mixin\": [\"ResourceGraphClientOperationsMixin\"]}}, \"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\": [\"ResourceGraphClientConfiguration\"], \"._operations_mixin\": [\"ResourceGraphClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"ResourceGraphClientConfiguration\"], \"._operations_mixin\": [\"ResourceGraphClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ResourceGraphClientConfiguration\"], \"._operations_mixin\": [\"ResourceGraphClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,64 +79,39 @@ "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\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"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\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations" }, "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"List\", \"Optional\", \"TypeVar\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"List\", \"Optional\", \"TypeVar\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", "operations": { - "resource_changes" : { - "sync": { - "signature": "def resource_changes(\n self,\n parameters, # type: \"_models.ResourceChangesRequestParameters\"\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"List changes to a resource for a given time interval.\n\n:param parameters: the parameters for this request for changes.\n:type parameters: ~azure.mgmt.resourcegraph.models.ResourceChangesRequestParameters\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ResourceChangeList, or the result of cls(response)\n:rtype: ~azure.mgmt.resourcegraph.models.ResourceChangeList\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def resource_changes(\n self,\n parameters: \"_models.ResourceChangesRequestParameters\",\n **kwargs\n) -\u003e \"_models.ResourceChangeList\":\n", - "doc": "\"\"\"List changes to a resource for a given time interval.\n\n:param parameters: the parameters for this request for changes.\n:type parameters: ~azure.mgmt.resourcegraph.models.ResourceChangesRequestParameters\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ResourceChangeList, or the result of cls(response)\n:rtype: ~azure.mgmt.resourcegraph.models.ResourceChangeList\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "parameters" - }, - "resource_change_details" : { - "sync": { - "signature": "def resource_change_details(\n self,\n parameters, # type: \"_models.ResourceChangeDetailsRequestParameters\"\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Get resource change details.\n\n:param parameters: The parameters for this request for resource change details.\n:type parameters: ~azure.mgmt.resourcegraph.models.ResourceChangeDetailsRequestParameters\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: list of ResourceChangeData, or the result of cls(response)\n:rtype: list[~azure.mgmt.resourcegraph.models.ResourceChangeData]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def resource_change_details(\n self,\n parameters: \"_models.ResourceChangeDetailsRequestParameters\",\n **kwargs\n) -\u003e List[\"_models.ResourceChangeData\"]:\n", - "doc": "\"\"\"Get resource change details.\n\n:param parameters: The parameters for this request for resource change details.\n:type parameters: ~azure.mgmt.resourcegraph.models.ResourceChangeDetailsRequestParameters\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: list of ResourceChangeData, or the result of cls(response)\n:rtype: list[~azure.mgmt.resourcegraph.models.ResourceChangeData]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "parameters" - }, "resources" : { "sync": { - "signature": "def resources(\n self,\n query, # type: \"_models.QueryRequest\"\n **kwargs # type: Any\n):\n", + "signature": "def resources(\n self,\n query, # type: \"_models.QueryRequest\"\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.QueryResponse\"\n", "doc": "\"\"\"Queries the resources managed by Azure Resource Manager for scopes specified in the request.\n\n:param query: Request specifying query and its options.\n:type query: ~azure.mgmt.resourcegraph.models.QueryRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: QueryResponse, or the result of cls(response)\n:rtype: ~azure.mgmt.resourcegraph.models.QueryResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, - "signature": "async def resources(\n self,\n query: \"_models.QueryRequest\",\n **kwargs\n) -\u003e \"_models.QueryResponse\":\n", + "signature": "async def resources(\n self,\n query: \"_models.QueryRequest\",\n **kwargs: Any\n) -\u003e \"_models.QueryResponse\":\n", "doc": "\"\"\"Queries the resources managed by Azure Resource Manager for scopes specified in the request.\n\n:param query: Request specifying query and its options.\n:type query: ~azure.mgmt.resourcegraph.models.QueryRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: QueryResponse, or the result of cls(response)\n:rtype: ~azure.mgmt.resourcegraph.models.QueryResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "query" }, "resources_history" : { "sync": { - "signature": "def resources_history(\n self,\n request, # type: \"_models.ResourcesHistoryRequest\"\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"List all snapshots of a resource for a given time interval.\n\n:param request:\n:type request: ~azure.mgmt.resourcegraph.models.ResourcesHistoryRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: object, or the result of cls(response)\n:rtype: object\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "def resources_history(\n self,\n request, # type: \"_models.ResourcesHistoryRequest\"\n **kwargs # type: Any\n):\n # type: (...) -\u003e Any\n", + "doc": "\"\"\"List all snapshots of a resource for a given time interval.\n\n:param request: Request specifying the query and its options.\n:type request: ~azure.mgmt.resourcegraph.models.ResourcesHistoryRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: any, or the result of cls(response)\n:rtype: any\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "async": { "coroutine": true, - "signature": "async def resources_history(\n self,\n request: \"_models.ResourcesHistoryRequest\",\n **kwargs\n) -\u003e object:\n", - "doc": "\"\"\"List all snapshots of a resource for a given time interval.\n\n:param request:\n:type request: ~azure.mgmt.resourcegraph.models.ResourcesHistoryRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: object, or the result of cls(response)\n:rtype: object\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + "signature": "async def resources_history(\n self,\n request: \"_models.ResourcesHistoryRequest\",\n **kwargs: Any\n) -\u003e Any:\n", + "doc": "\"\"\"List all snapshots of a resource for a given time interval.\n\n:param request: Request specifying the query and its options.\n:type request: ~azure.mgmt.resourcegraph.models.ResourcesHistoryRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: any, or the result of cls(response)\n:rtype: any\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "request" } diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_patch.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_resource_graph_client.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_resource_graph_client.py index 4209cc5a1b34..8f5270a0695a 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_resource_graph_client.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_resource_graph_client.py @@ -6,23 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ResourceGraphClientConfiguration +from .operations import Operations, ResourceGraphClientOperationsMixin + 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 ResourceGraphClientConfiguration -from .operations import ResourceGraphClientOperationsMixin -from .operations import Operations -from . import models - class ResourceGraphClient(ResourceGraphClientOperationsMixin): """Azure Resource Graph API Reference. @@ -31,43 +28,51 @@ class ResourceGraphClient(ResourceGraphClientOperationsMixin): :vartype operations: azure.mgmt.resourcegraph.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceGraphClientConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ResourceGraphClientConfiguration(credential=credential, **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._serialize.client_side_validation = False + self.operations = Operations(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 + def _send_request( + self, + request, # type: HttpRequest + **kwargs: 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. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_vendor.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_vendor.py new file mode 100644 index 000000000000..9a223d15524c --- /dev/null +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_vendor.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_version.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_version.py index aa6530bfe9d9..c47f66669f1b 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_version.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0b1" +VERSION = "1.0.0" diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/__init__.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/__init__.py index ec4d8b3a968c..0d1bf05a86a6 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/__init__.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/__init__.py @@ -8,3 +8,8 @@ from ._resource_graph_client import ResourceGraphClient __all__ = ['ResourceGraphClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/_configuration.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/_configuration.py index 62fe1a2d0829..6f546d2906bd 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/_configuration.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -34,11 +34,12 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(ResourceGraphClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(ResourceGraphClientConfiguration, self).__init__(**kwargs) self.credential = credential + self.api_version = "2021-06-01-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-resourcegraph/{}'.format(VERSION)) self._configure(**kwargs) @@ -57,4 +58,4 @@ def _configure( 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) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/_patch.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/_resource_graph_client.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/_resource_graph_client.py index 9105adb198f5..2a2f2dfdb96d 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/_resource_graph_client.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/_resource_graph_client.py @@ -6,22 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import ResourceGraphClientConfiguration +from .operations import Operations, ResourceGraphClientOperationsMixin + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ResourceGraphClientConfiguration -from .operations import ResourceGraphClientOperationsMixin -from .operations import Operations -from .. import models - - class ResourceGraphClient(ResourceGraphClientOperationsMixin): """Azure Resource Graph API Reference. @@ -29,41 +28,51 @@ class ResourceGraphClient(ResourceGraphClientOperationsMixin): :vartype operations: azure.mgmt.resourcegraph.aio.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ResourceGraphClientConfiguration(credential, **kwargs) + self._config = ResourceGraphClientConfiguration(credential=credential, **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._serialize.client_side_validation = False + self.operations = Operations(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: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[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. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/operations/_operations.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/operations/_operations.py index eb1abdc9219a..88f0cd03e23a 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools 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.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,15 +46,17 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.OperationListResult"]: """Lists all of the available REST API operations. :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.resourcegraph.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcegraph.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01" - 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 = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/operations/_resource_graph_client_operations.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/operations/_resource_graph_client_operations.py index 4a5f9c37108f..0832c47315b4 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/operations/_resource_graph_client_operations.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/aio/operations/_resource_graph_client_operations.py @@ -5,135 +5,30 @@ # 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, List, Optional, TypeVar +import functools +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.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_graph_client_operations import build_resources_history_request, build_resources_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ResourceGraphClientOperationsMixin: - async def resource_changes( - self, - parameters: "_models.ResourceChangesRequestParameters", - **kwargs - ) -> "_models.ResourceChangeList": - """List changes to a resource for a given time interval. - - :param parameters: the parameters for this request for changes. - :type parameters: ~azure.mgmt.resourcegraph.models.ResourceChangesRequestParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceChangeList, or the result of cls(response) - :rtype: ~azure.mgmt.resourcegraph.models.ResourceChangeList - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceChangeList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.resource_changes.metadata['url'] # type: ignore - - # 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(parameters, 'ResourceChangesRequestParameters') - 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('ResourceChangeList', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - resource_changes.metadata = {'url': '/providers/Microsoft.ResourceGraph/resourceChanges'} # type: ignore - - async def resource_change_details( - self, - parameters: "_models.ResourceChangeDetailsRequestParameters", - **kwargs - ) -> List["_models.ResourceChangeData"]: - """Get resource change details. - - :param parameters: The parameters for this request for resource change details. - :type parameters: ~azure.mgmt.resourcegraph.models.ResourceChangeDetailsRequestParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of ResourceChangeData, or the result of cls(response) - :rtype: list[~azure.mgmt.resourcegraph.models.ResourceChangeData] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ResourceChangeData"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.resource_change_details.metadata['url'] # type: ignore - - # 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(parameters, 'ResourceChangeDetailsRequestParameters') - 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('[ResourceChangeData]', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - resource_change_details.metadata = {'url': '/providers/Microsoft.ResourceGraph/resourceChangeDetails'} # type: ignore - + @distributed_trace_async async def resources( self, query: "_models.QueryRequest", - **kwargs + **kwargs: Any ) -> "_models.QueryResponse": """Queries the resources managed by Azure Resource Manager for scopes specified in the request. @@ -149,32 +44,25 @@ async def resources( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.resources.metadata['url'] # type: ignore - - # 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(query, 'QueryRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(query, 'QueryRequest') + + request = build_resources_request( + content_type=content_type, + json=_json, + template_url=self.resources.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QueryResponse', pipeline_response) @@ -183,53 +71,49 @@ async def resources( return cls(pipeline_response, deserialized, {}) return deserialized + resources.metadata = {'url': '/providers/Microsoft.ResourceGraph/resources'} # type: ignore + + @distributed_trace_async async def resources_history( self, request: "_models.ResourcesHistoryRequest", - **kwargs - ) -> object: + **kwargs: Any + ) -> Any: """List all snapshots of a resource for a given time interval. - :param request: + :param request: Request specifying the query and its options. :type request: ~azure.mgmt.resourcegraph.models.ResourcesHistoryRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: object, or the result of cls(response) - :rtype: object + :return: any, or the result of cls(response) + :rtype: any :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[object] + cls = kwargs.pop('cls', None) # type: ClsType[Any] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.resources_history.metadata['url'] # type: ignore - - # 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(request, 'ResourcesHistoryRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(request, 'ResourcesHistoryRequest') + + request = build_resources_history_request( + content_type=content_type, + json=_json, + template_url=self.resources_history.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('object', pipeline_response) @@ -238,4 +122,6 @@ async def resources_history( return cls(pipeline_response, deserialized, {}) return deserialized + resources_history.metadata = {'url': '/providers/Microsoft.ResourceGraph/resourcesHistory'} # type: ignore + diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/__init__.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/__init__.py index feaa061b61d8..71c2ab5e9bcc 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/__init__.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/__init__.py @@ -6,72 +6,31 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Column - from ._models_py3 import DateTimeInterval - from ._models_py3 import Error - from ._models_py3 import ErrorDetails - from ._models_py3 import ErrorResponse - from ._models_py3 import Facet - from ._models_py3 import FacetError - from ._models_py3 import FacetRequest - from ._models_py3 import FacetRequestOptions - from ._models_py3 import FacetResult - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import QueryRequest - from ._models_py3 import QueryRequestOptions - from ._models_py3 import QueryResponse - from ._models_py3 import ResourceChangeData - from ._models_py3 import ResourceChangeDataAfterSnapshot - from ._models_py3 import ResourceChangeDataBeforeSnapshot - from ._models_py3 import ResourceChangeDetailsRequestParameters - from ._models_py3 import ResourceChangeList - from ._models_py3 import ResourceChangesRequestParameters - from ._models_py3 import ResourceChangesRequestParametersInterval - from ._models_py3 import ResourcePropertyChange - from ._models_py3 import ResourceSnapshotData - from ._models_py3 import ResourcesHistoryRequest - from ._models_py3 import ResourcesHistoryRequestOptions - from ._models_py3 import Table -except (SyntaxError, ImportError): - from ._models import Column # type: ignore - from ._models import DateTimeInterval # type: ignore - from ._models import Error # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Facet # type: ignore - from ._models import FacetError # type: ignore - from ._models import FacetRequest # type: ignore - from ._models import FacetRequestOptions # type: ignore - from ._models import FacetResult # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import QueryRequest # type: ignore - from ._models import QueryRequestOptions # type: ignore - from ._models import QueryResponse # type: ignore - from ._models import ResourceChangeData # type: ignore - from ._models import ResourceChangeDataAfterSnapshot # type: ignore - from ._models import ResourceChangeDataBeforeSnapshot # type: ignore - from ._models import ResourceChangeDetailsRequestParameters # type: ignore - from ._models import ResourceChangeList # type: ignore - from ._models import ResourceChangesRequestParameters # type: ignore - from ._models import ResourceChangesRequestParametersInterval # type: ignore - from ._models import ResourcePropertyChange # type: ignore - from ._models import ResourceSnapshotData # type: ignore - from ._models import ResourcesHistoryRequest # type: ignore - from ._models import ResourcesHistoryRequestOptions # type: ignore - from ._models import Table # type: ignore +from ._models_py3 import Column +from ._models_py3 import DateTimeInterval +from ._models_py3 import Error +from ._models_py3 import ErrorDetails +from ._models_py3 import ErrorResponse +from ._models_py3 import Facet +from ._models_py3 import FacetError +from ._models_py3 import FacetRequest +from ._models_py3 import FacetRequestOptions +from ._models_py3 import FacetResult +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import QueryRequest +from ._models_py3 import QueryRequestOptions +from ._models_py3 import QueryResponse +from ._models_py3 import ResourcesHistoryRequest +from ._models_py3 import ResourcesHistoryRequestOptions +from ._models_py3 import Table + from ._resource_graph_client_enums import ( - ChangeCategory, - ChangeType, + AuthorizationScopeFilter, ColumnDataType, FacetSortOrder, - PropertyChangeType, - ResourcesHistoryRequestOptionsResultFormat, ResultFormat, ResultTruncated, ) @@ -93,24 +52,12 @@ 'QueryRequest', 'QueryRequestOptions', 'QueryResponse', - 'ResourceChangeData', - 'ResourceChangeDataAfterSnapshot', - 'ResourceChangeDataBeforeSnapshot', - 'ResourceChangeDetailsRequestParameters', - 'ResourceChangeList', - 'ResourceChangesRequestParameters', - 'ResourceChangesRequestParametersInterval', - 'ResourcePropertyChange', - 'ResourceSnapshotData', 'ResourcesHistoryRequest', 'ResourcesHistoryRequestOptions', 'Table', - 'ChangeCategory', - 'ChangeType', + 'AuthorizationScopeFilter', 'ColumnDataType', 'FacetSortOrder', - 'PropertyChangeType', - 'ResourcesHistoryRequestOptionsResultFormat', 'ResultFormat', 'ResultTruncated', ] diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/_models.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/_models.py deleted file mode 100644 index cb5487b123f2..000000000000 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/_models.py +++ /dev/null @@ -1,1012 +0,0 @@ -# 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 Column(msrest.serialization.Model): - """Query result column descriptor. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. Column name. - :type name: str - :param type: Required. Column data type. Possible values include: "string", "integer", - "number", "boolean", "object". - :type type: str or ~azure.mgmt.resourcegraph.models.ColumnDataType - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Column, self).__init__(**kwargs) - self.name = kwargs['name'] - self.type = kwargs['type'] - - -class DateTimeInterval(msrest.serialization.Model): - """An interval in time specifying the date and time for the inclusive start and exclusive end, i.e. ``[start, end)``. - - All required parameters must be populated in order to send to Azure. - - :param start: Required. A datetime indicating the inclusive/closed start of the time interval, - i.e. ``[``\ **\ ``start``\ **\ ``, end)``. Specifying a ``start`` that occurs chronologically - after ``end`` will result in an error. - :type start: ~datetime.datetime - :param end: Required. A datetime indicating the exclusive/open end of the time interval, i.e. - ``[start,``\ **\ ``end``\ **\ ``)``. Specifying an ``end`` that occurs chronologically before - ``start`` will result in an error. - :type end: ~datetime.datetime - """ - - _validation = { - 'start': {'required': True}, - 'end': {'required': True}, - } - - _attribute_map = { - 'start': {'key': 'start', 'type': 'iso-8601'}, - 'end': {'key': 'end', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(DateTimeInterval, self).__init__(**kwargs) - self.start = kwargs['start'] - self.end = kwargs['end'] - - -class Error(msrest.serialization.Model): - """Error details. - - All required parameters must be populated in order to send to Azure. - - :param code: Required. Error code identifying the specific error. - :type code: str - :param message: Required. A human readable error message. - :type message: str - :param details: Error details. - :type details: list[~azure.mgmt.resourcegraph.models.ErrorDetails] - """ - - _validation = { - 'code': {'required': True}, - 'message': {'required': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetails]'}, - } - - def __init__( - self, - **kwargs - ): - super(Error, self).__init__(**kwargs) - self.code = kwargs['code'] - self.message = kwargs['message'] - self.details = kwargs.get('details', None) - - -class ErrorDetails(msrest.serialization.Model): - """Error details. - - All required parameters must be populated in order to send to Azure. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, object] - :param code: Required. Error code identifying the specific error. - :type code: str - :param message: Required. A human readable error message. - :type message: str - """ - - _validation = { - 'code': {'required': True}, - 'message': {'required': True}, - } - - _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetails, self).__init__(**kwargs) - self.additional_properties = kwargs.get('additional_properties', None) - self.code = kwargs['code'] - self.message = kwargs['message'] - - -class ErrorResponse(msrest.serialization.Model): - """An error response from the API. - - All required parameters must be populated in order to send to Azure. - - :param error: Required. Error information. - :type error: ~azure.mgmt.resourcegraph.models.Error - """ - - _validation = { - 'error': {'required': True}, - } - - _attribute_map = { - 'error': {'key': 'error', 'type': 'Error'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs['error'] - - -class Facet(msrest.serialization.Model): - """A facet containing additional statistics on the response of a query. Can be either FacetResult or FacetError. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: FacetError, FacetResult. - - All required parameters must be populated in order to send to Azure. - - :param expression: Required. Facet expression, same as in the corresponding facet request. - :type expression: str - :param result_type: Required. Result type.Constant filled by server. - :type result_type: str - """ - - _validation = { - 'expression': {'required': True}, - 'result_type': {'required': True}, - } - - _attribute_map = { - 'expression': {'key': 'expression', 'type': 'str'}, - 'result_type': {'key': 'resultType', 'type': 'str'}, - } - - _subtype_map = { - 'result_type': {'FacetError': 'FacetError', 'FacetResult': 'FacetResult'} - } - - def __init__( - self, - **kwargs - ): - super(Facet, self).__init__(**kwargs) - self.expression = kwargs['expression'] - self.result_type = None # type: Optional[str] - - -class FacetError(Facet): - """A facet whose execution resulted in an error. - - All required parameters must be populated in order to send to Azure. - - :param expression: Required. Facet expression, same as in the corresponding facet request. - :type expression: str - :param result_type: Required. Result type.Constant filled by server. - :type result_type: str - :param errors: Required. An array containing detected facet errors with details. - :type errors: list[~azure.mgmt.resourcegraph.models.ErrorDetails] - """ - - _validation = { - 'expression': {'required': True}, - 'result_type': {'required': True}, - 'errors': {'required': True}, - } - - _attribute_map = { - 'expression': {'key': 'expression', 'type': 'str'}, - 'result_type': {'key': 'resultType', 'type': 'str'}, - 'errors': {'key': 'errors', 'type': '[ErrorDetails]'}, - } - - def __init__( - self, - **kwargs - ): - super(FacetError, self).__init__(**kwargs) - self.result_type = 'FacetError' # type: str - self.errors = kwargs['errors'] - - -class FacetRequest(msrest.serialization.Model): - """A request to compute additional statistics (facets) over the query results. - - All required parameters must be populated in order to send to Azure. - - :param expression: Required. The column or list of columns to summarize by. - :type expression: str - :param options: The options for facet evaluation. - :type options: ~azure.mgmt.resourcegraph.models.FacetRequestOptions - """ - - _validation = { - 'expression': {'required': True}, - } - - _attribute_map = { - 'expression': {'key': 'expression', 'type': 'str'}, - 'options': {'key': 'options', 'type': 'FacetRequestOptions'}, - } - - def __init__( - self, - **kwargs - ): - super(FacetRequest, self).__init__(**kwargs) - self.expression = kwargs['expression'] - self.options = kwargs.get('options', None) - - -class FacetRequestOptions(msrest.serialization.Model): - """The options for facet evaluation. - - :param sort_by: The column name or query expression to sort on. Defaults to count if not - present. - :type sort_by: str - :param sort_order: The sorting order by the selected column (count by default). Possible values - include: "asc", "desc". Default value: "desc". - :type sort_order: str or ~azure.mgmt.resourcegraph.models.FacetSortOrder - :param filter: Specifies the filter condition for the 'where' clause which will be run on main - query's result, just before the actual faceting. - :type filter: str - :param top: The maximum number of facet rows that should be returned. - :type top: int - """ - - _validation = { - 'top': {'maximum': 1000, 'minimum': 1}, - } - - _attribute_map = { - 'sort_by': {'key': 'sortBy', 'type': 'str'}, - 'sort_order': {'key': 'sortOrder', 'type': 'str'}, - 'filter': {'key': 'filter', 'type': 'str'}, - 'top': {'key': '$top', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(FacetRequestOptions, self).__init__(**kwargs) - self.sort_by = kwargs.get('sort_by', None) - self.sort_order = kwargs.get('sort_order', "desc") - self.filter = kwargs.get('filter', None) - self.top = kwargs.get('top', None) - - -class FacetResult(Facet): - """Successfully executed facet containing additional statistics on the response of a query. - - All required parameters must be populated in order to send to Azure. - - :param expression: Required. Facet expression, same as in the corresponding facet request. - :type expression: str - :param result_type: Required. Result type.Constant filled by server. - :type result_type: str - :param total_records: Required. Number of total records in the facet results. - :type total_records: long - :param count: Required. Number of records returned in the facet response. - :type count: int - :param data: Required. A JObject array or Table containing the desired facets. Only present if - the facet is valid. - :type data: object - """ - - _validation = { - 'expression': {'required': True}, - 'result_type': {'required': True}, - 'total_records': {'required': True}, - 'count': {'required': True}, - 'data': {'required': True}, - } - - _attribute_map = { - 'expression': {'key': 'expression', 'type': 'str'}, - 'result_type': {'key': 'resultType', 'type': 'str'}, - 'total_records': {'key': 'totalRecords', 'type': 'long'}, - 'count': {'key': 'count', 'type': 'int'}, - 'data': {'key': 'data', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(FacetResult, self).__init__(**kwargs) - self.result_type = 'FacetResult' # type: str - self.total_records = kwargs['total_records'] - self.count = kwargs['count'] - self.data = kwargs['data'] - - -class Operation(msrest.serialization.Model): - """Resource Graph REST API operation definition. - - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: Display metadata associated with the operation. - :type display: ~azure.mgmt.resourcegraph.models.OperationDisplay - :param origin: The origin of operations. - :type origin: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - - -class OperationDisplay(msrest.serialization.Model): - """Display metadata associated with the operation. - - :param provider: Service provider: Microsoft Resource Graph. - :type provider: str - :param resource: Resource on which the operation is performed etc. - :type resource: str - :param operation: Type of operation: get, read, delete, etc. - :type operation: str - :param description: Description for the operation. - :type description: str - """ - - _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 = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list Resource Graph operations. It contains a list of operations and a URL link to get the next set of results. - - :param value: List of Resource Graph operations supported by the Resource Graph resource - provider. - :type value: list[~azure.mgmt.resourcegraph.models.Operation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class QueryRequest(msrest.serialization.Model): - """Describes a query to be executed. - - All required parameters must be populated in order to send to Azure. - - :param subscriptions: Azure subscriptions against which to execute the query. - :type subscriptions: list[str] - :param management_groups: Azure management groups against which to execute the query. Example: - [ 'mg1', 'mg2' ]. - :type management_groups: list[str] - :param query: Required. The resources query. - :type query: str - :param options: The query evaluation options. - :type options: ~azure.mgmt.resourcegraph.models.QueryRequestOptions - :param facets: An array of facet requests to be computed against the query result. - :type facets: list[~azure.mgmt.resourcegraph.models.FacetRequest] - """ - - _validation = { - 'query': {'required': True}, - } - - _attribute_map = { - 'subscriptions': {'key': 'subscriptions', 'type': '[str]'}, - 'management_groups': {'key': 'managementGroups', 'type': '[str]'}, - 'query': {'key': 'query', 'type': 'str'}, - 'options': {'key': 'options', 'type': 'QueryRequestOptions'}, - 'facets': {'key': 'facets', 'type': '[FacetRequest]'}, - } - - def __init__( - self, - **kwargs - ): - super(QueryRequest, self).__init__(**kwargs) - self.subscriptions = kwargs.get('subscriptions', None) - self.management_groups = kwargs.get('management_groups', None) - self.query = kwargs['query'] - self.options = kwargs.get('options', None) - self.facets = kwargs.get('facets', None) - - -class QueryRequestOptions(msrest.serialization.Model): - """The options for query evaluation. - - :param skip_token: Continuation token for pagination, capturing the next page size and offset, - as well as the context of the query. - :type skip_token: str - :param top: The maximum number of rows that the query should return. Overrides the page size - when ``$skipToken`` property is present. - :type top: int - :param skip: The number of rows to skip from the beginning of the results. Overrides the next - page offset when ``$skipToken`` property is present. - :type skip: int - :param result_format: Defines in which format query result returned. Possible values include: - "table", "objectArray". Default value: "objectArray". - :type result_format: str or ~azure.mgmt.resourcegraph.models.ResultFormat - :param allow_partial_scopes: Only applicable for tenant and management group level queries to - decide whether to allow partial scopes for result in case the number of subscriptions exceed - allowed limits. - :type allow_partial_scopes: bool - """ - - _validation = { - 'top': {'maximum': 1000, 'minimum': 1}, - 'skip': {'minimum': 0}, - } - - _attribute_map = { - 'skip_token': {'key': '$skipToken', 'type': 'str'}, - 'top': {'key': '$top', 'type': 'int'}, - 'skip': {'key': '$skip', 'type': 'int'}, - 'result_format': {'key': 'resultFormat', 'type': 'str'}, - 'allow_partial_scopes': {'key': 'allowPartialScopes', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(QueryRequestOptions, self).__init__(**kwargs) - self.skip_token = kwargs.get('skip_token', None) - self.top = kwargs.get('top', None) - self.skip = kwargs.get('skip', None) - self.result_format = kwargs.get('result_format', "objectArray") - self.allow_partial_scopes = kwargs.get('allow_partial_scopes', False) - - -class QueryResponse(msrest.serialization.Model): - """Query result. - - All required parameters must be populated in order to send to Azure. - - :param total_records: Required. Number of total records matching the query. - :type total_records: long - :param count: Required. Number of records returned in the current response. In the case of - paging, this is the number of records in the current page. - :type count: long - :param result_truncated: Required. Indicates whether the query results are truncated. Possible - values include: "true", "false". - :type result_truncated: str or ~azure.mgmt.resourcegraph.models.ResultTruncated - :param skip_token: When present, the value can be passed to a subsequent query call (together - with the same query and scopes used in the current request) to retrieve the next page of data. - :type skip_token: str - :param data: Required. Query output in JObject array or Table format. - :type data: object - :param facets: Query facets. - :type facets: list[~azure.mgmt.resourcegraph.models.Facet] - """ - - _validation = { - 'total_records': {'required': True}, - 'count': {'required': True}, - 'result_truncated': {'required': True}, - 'data': {'required': True}, - } - - _attribute_map = { - 'total_records': {'key': 'totalRecords', 'type': 'long'}, - 'count': {'key': 'count', 'type': 'long'}, - 'result_truncated': {'key': 'resultTruncated', 'type': 'str'}, - 'skip_token': {'key': '$skipToken', 'type': 'str'}, - 'data': {'key': 'data', 'type': 'object'}, - 'facets': {'key': 'facets', 'type': '[Facet]'}, - } - - def __init__( - self, - **kwargs - ): - super(QueryResponse, self).__init__(**kwargs) - self.total_records = kwargs['total_records'] - self.count = kwargs['count'] - self.result_truncated = kwargs['result_truncated'] - self.skip_token = kwargs.get('skip_token', None) - self.data = kwargs['data'] - self.facets = kwargs.get('facets', None) - - -class ResourceChangeData(msrest.serialization.Model): - """Data on a specific change, represented by a pair of before and after resource snapshots. - - All required parameters must be populated in order to send to Azure. - - :param resource_id: The resource for a change. - :type resource_id: str - :param change_id: Required. The change ID. Valid and unique within the specified resource only. - :type change_id: str - :param before_snapshot: Required. The snapshot before the change. - :type before_snapshot: ~azure.mgmt.resourcegraph.models.ResourceChangeDataBeforeSnapshot - :param after_snapshot: Required. The snapshot after the change. - :type after_snapshot: ~azure.mgmt.resourcegraph.models.ResourceChangeDataAfterSnapshot - :param change_type: The change type for snapshot. PropertyChanges will be provided in case of - Update change type. Possible values include: "Create", "Update", "Delete". - :type change_type: str or ~azure.mgmt.resourcegraph.models.ChangeType - :param property_changes: An array of resource property change. - :type property_changes: list[~azure.mgmt.resourcegraph.models.ResourcePropertyChange] - """ - - _validation = { - 'change_id': {'required': True}, - 'before_snapshot': {'required': True}, - 'after_snapshot': {'required': True}, - } - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_id': {'key': 'changeId', 'type': 'str'}, - 'before_snapshot': {'key': 'beforeSnapshot', 'type': 'ResourceChangeDataBeforeSnapshot'}, - 'after_snapshot': {'key': 'afterSnapshot', 'type': 'ResourceChangeDataAfterSnapshot'}, - 'change_type': {'key': 'changeType', 'type': 'str'}, - 'property_changes': {'key': 'propertyChanges', 'type': '[ResourcePropertyChange]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceChangeData, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.change_id = kwargs['change_id'] - self.before_snapshot = kwargs['before_snapshot'] - self.after_snapshot = kwargs['after_snapshot'] - self.change_type = kwargs.get('change_type', None) - self.property_changes = kwargs.get('property_changes', None) - - -class ResourceSnapshotData(msrest.serialization.Model): - """Data on a specific resource snapshot. - - All required parameters must be populated in order to send to Azure. - - :param snapshot_id: The ID of the snapshot. - :type snapshot_id: str - :param timestamp: Required. The time when the snapshot was created. - The snapshot timestamp provides an approximation as to when a modification to a resource was - detected. There can be a difference between the actual modification time and the detection - time. This is due to differences in how operations that modify a resource are processed, - versus how operation that record resource snapshots are processed. - :type timestamp: ~datetime.datetime - :param content: The resource snapshot content (in resourceChangeDetails response only). - :type content: object - """ - - _validation = { - 'timestamp': {'required': True}, - } - - _attribute_map = { - 'snapshot_id': {'key': 'snapshotId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'content': {'key': 'content', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceSnapshotData, self).__init__(**kwargs) - self.snapshot_id = kwargs.get('snapshot_id', None) - self.timestamp = kwargs['timestamp'] - self.content = kwargs.get('content', None) - - -class ResourceChangeDataAfterSnapshot(ResourceSnapshotData): - """The snapshot after the change. - - All required parameters must be populated in order to send to Azure. - - :param snapshot_id: The ID of the snapshot. - :type snapshot_id: str - :param timestamp: Required. The time when the snapshot was created. - The snapshot timestamp provides an approximation as to when a modification to a resource was - detected. There can be a difference between the actual modification time and the detection - time. This is due to differences in how operations that modify a resource are processed, - versus how operation that record resource snapshots are processed. - :type timestamp: ~datetime.datetime - :param content: The resource snapshot content (in resourceChangeDetails response only). - :type content: object - """ - - _validation = { - 'timestamp': {'required': True}, - } - - _attribute_map = { - 'snapshot_id': {'key': 'snapshotId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'content': {'key': 'content', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceChangeDataAfterSnapshot, self).__init__(**kwargs) - - -class ResourceChangeDataBeforeSnapshot(ResourceSnapshotData): - """The snapshot before the change. - - All required parameters must be populated in order to send to Azure. - - :param snapshot_id: The ID of the snapshot. - :type snapshot_id: str - :param timestamp: Required. The time when the snapshot was created. - The snapshot timestamp provides an approximation as to when a modification to a resource was - detected. There can be a difference between the actual modification time and the detection - time. This is due to differences in how operations that modify a resource are processed, - versus how operation that record resource snapshots are processed. - :type timestamp: ~datetime.datetime - :param content: The resource snapshot content (in resourceChangeDetails response only). - :type content: object - """ - - _validation = { - 'timestamp': {'required': True}, - } - - _attribute_map = { - 'snapshot_id': {'key': 'snapshotId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'content': {'key': 'content', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceChangeDataBeforeSnapshot, self).__init__(**kwargs) - - -class ResourceChangeDetailsRequestParameters(msrest.serialization.Model): - """The parameters for a specific change details request. - - All required parameters must be populated in order to send to Azure. - - :param resource_ids: Required. Specifies the list of resources for a change details request. - :type resource_ids: list[str] - :param change_ids: Required. Specifies the list of change IDs for a change details request. - :type change_ids: list[str] - """ - - _validation = { - 'resource_ids': {'required': True}, - 'change_ids': {'required': True}, - } - - _attribute_map = { - 'resource_ids': {'key': 'resourceIds', 'type': '[str]'}, - 'change_ids': {'key': 'changeIds', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceChangeDetailsRequestParameters, self).__init__(**kwargs) - self.resource_ids = kwargs['resource_ids'] - self.change_ids = kwargs['change_ids'] - - -class ResourceChangeList(msrest.serialization.Model): - """A list of changes associated with a resource over a specific time interval. - - :param changes: The pageable value returned by the operation, i.e. a list of changes to the - resource. - - - * The list is ordered from the most recent changes to the least recent changes. - * This list will be empty if there were no changes during the requested interval. - * The ``Before`` snapshot timestamp value of the oldest change can be outside of the specified - time interval. - :type changes: list[~azure.mgmt.resourcegraph.models.ResourceChangeData] - :param skip_token: Skip token that encodes the skip information while executing the current - request. - :type skip_token: object - """ - - _attribute_map = { - 'changes': {'key': 'changes', 'type': '[ResourceChangeData]'}, - 'skip_token': {'key': '$skipToken', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceChangeList, self).__init__(**kwargs) - self.changes = kwargs.get('changes', None) - self.skip_token = kwargs.get('skip_token', None) - - -class ResourceChangesRequestParameters(msrest.serialization.Model): - """The parameters for a specific changes request. - - All required parameters must be populated in order to send to Azure. - - :param resource_ids: Specifies the list of resources for a changes request. - :type resource_ids: list[str] - :param subscription_id: The subscription id of resources to query the changes from. - :type subscription_id: str - :param interval: Required. Specifies the date and time interval for a changes request. - :type interval: ~azure.mgmt.resourcegraph.models.ResourceChangesRequestParametersInterval - :param skip_token: Acts as the continuation token for paged responses. - :type skip_token: str - :param top: The maximum number of changes the client can accept in a paged response. - :type top: int - :param table: The table name to query resources from. - :type table: str - :param fetch_property_changes: The flag if set to true will fetch property changes. - :type fetch_property_changes: bool - :param fetch_snapshots: The flag if set to true will fetch change snapshots. - :type fetch_snapshots: bool - """ - - _validation = { - 'interval': {'required': True}, - 'top': {'maximum': 1000, 'minimum': 1}, - } - - _attribute_map = { - 'resource_ids': {'key': 'resourceIds', 'type': '[str]'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'interval': {'key': 'interval', 'type': 'ResourceChangesRequestParametersInterval'}, - 'skip_token': {'key': '$skipToken', 'type': 'str'}, - 'top': {'key': '$top', 'type': 'int'}, - 'table': {'key': 'table', 'type': 'str'}, - 'fetch_property_changes': {'key': 'fetchPropertyChanges', 'type': 'bool'}, - 'fetch_snapshots': {'key': 'fetchSnapshots', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceChangesRequestParameters, self).__init__(**kwargs) - self.resource_ids = kwargs.get('resource_ids', None) - self.subscription_id = kwargs.get('subscription_id', None) - self.interval = kwargs['interval'] - self.skip_token = kwargs.get('skip_token', None) - self.top = kwargs.get('top', None) - self.table = kwargs.get('table', None) - self.fetch_property_changes = kwargs.get('fetch_property_changes', None) - self.fetch_snapshots = kwargs.get('fetch_snapshots', None) - - -class ResourceChangesRequestParametersInterval(DateTimeInterval): - """Specifies the date and time interval for a changes request. - - All required parameters must be populated in order to send to Azure. - - :param start: Required. A datetime indicating the inclusive/closed start of the time interval, - i.e. ``[``\ **\ ``start``\ **\ ``, end)``. Specifying a ``start`` that occurs chronologically - after ``end`` will result in an error. - :type start: ~datetime.datetime - :param end: Required. A datetime indicating the exclusive/open end of the time interval, i.e. - ``[start,``\ **\ ``end``\ **\ ``)``. Specifying an ``end`` that occurs chronologically before - ``start`` will result in an error. - :type end: ~datetime.datetime - """ - - _validation = { - 'start': {'required': True}, - 'end': {'required': True}, - } - - _attribute_map = { - 'start': {'key': 'start', 'type': 'iso-8601'}, - 'end': {'key': 'end', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceChangesRequestParametersInterval, self).__init__(**kwargs) - - -class ResourcePropertyChange(msrest.serialization.Model): - """The resource property change. - - All required parameters must be populated in order to send to Azure. - - :param property_name: Required. The property name. - :type property_name: str - :param before_value: The property value in before snapshot. - :type before_value: str - :param after_value: The property value in after snapshot. - :type after_value: str - :param change_category: Required. The change category. Possible values include: "User", - "System". - :type change_category: str or ~azure.mgmt.resourcegraph.models.ChangeCategory - :param property_change_type: Required. The property change Type. Possible values include: - "Insert", "Update", "Remove". - :type property_change_type: str or ~azure.mgmt.resourcegraph.models.PropertyChangeType - """ - - _validation = { - 'property_name': {'required': True}, - 'change_category': {'required': True}, - 'property_change_type': {'required': True}, - } - - _attribute_map = { - 'property_name': {'key': 'propertyName', 'type': 'str'}, - 'before_value': {'key': 'beforeValue', 'type': 'str'}, - 'after_value': {'key': 'afterValue', 'type': 'str'}, - 'change_category': {'key': 'changeCategory', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourcePropertyChange, self).__init__(**kwargs) - self.property_name = kwargs['property_name'] - self.before_value = kwargs.get('before_value', None) - self.after_value = kwargs.get('after_value', None) - self.change_category = kwargs['change_category'] - self.property_change_type = kwargs['property_change_type'] - - -class ResourcesHistoryRequest(msrest.serialization.Model): - """ResourcesHistoryRequest. - - :param subscriptions: - :type subscriptions: list[str] - :param query: - :type query: str - :param options: - :type options: ~azure.mgmt.resourcegraph.models.ResourcesHistoryRequestOptions - :param management_group_id: - :type management_group_id: str - """ - - _attribute_map = { - 'subscriptions': {'key': 'subscriptions', 'type': '[str]'}, - 'query': {'key': 'query', 'type': 'str'}, - 'options': {'key': 'options', 'type': 'ResourcesHistoryRequestOptions'}, - 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourcesHistoryRequest, self).__init__(**kwargs) - self.subscriptions = kwargs.get('subscriptions', None) - self.query = kwargs.get('query', None) - self.options = kwargs.get('options', None) - self.management_group_id = kwargs.get('management_group_id', None) - - -class ResourcesHistoryRequestOptions(msrest.serialization.Model): - """ResourcesHistoryRequestOptions. - - :param interval: An interval in time specifying the date and time for the inclusive start and - exclusive end, i.e. ``[start, end)``. - :type interval: ~azure.mgmt.resourcegraph.models.DateTimeInterval - :param top: - :type top: int - :param skip: - :type skip: int - :param skip_token: - :type skip_token: str - :param result_format: Possible values include: "table", "objectArray". - :type result_format: str or - ~azure.mgmt.resourcegraph.models.ResourcesHistoryRequestOptionsResultFormat - """ - - _attribute_map = { - 'interval': {'key': 'interval', 'type': 'DateTimeInterval'}, - 'top': {'key': '$top', 'type': 'int'}, - 'skip': {'key': '$skip', 'type': 'int'}, - 'skip_token': {'key': '$skipToken', 'type': 'str'}, - 'result_format': {'key': 'resultFormat', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourcesHistoryRequestOptions, self).__init__(**kwargs) - self.interval = kwargs.get('interval', None) - self.top = kwargs.get('top', None) - self.skip = kwargs.get('skip', None) - self.skip_token = kwargs.get('skip_token', None) - self.result_format = kwargs.get('result_format', None) - - -class Table(msrest.serialization.Model): - """Query output in tabular format. - - All required parameters must be populated in order to send to Azure. - - :param columns: Required. Query result column descriptors. - :type columns: list[~azure.mgmt.resourcegraph.models.Column] - :param rows: Required. Query result rows. - :type rows: list[list[object]] - """ - - _validation = { - 'columns': {'required': True}, - 'rows': {'required': True}, - } - - _attribute_map = { - 'columns': {'key': 'columns', 'type': '[Column]'}, - 'rows': {'key': 'rows', 'type': '[[object]]'}, - } - - def __init__( - self, - **kwargs - ): - super(Table, self).__init__(**kwargs) - self.columns = kwargs['columns'] - self.rows = kwargs['rows'] diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/_models_py3.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/_models_py3.py index 7d12bd774827..0766abb8538a 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/_models_py3.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/_models_py3.py @@ -7,7 +7,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -20,11 +20,11 @@ class Column(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Column name. - :type name: str - :param type: Required. Column data type. Possible values include: "string", "integer", - "number", "boolean", "object". - :type type: str or ~azure.mgmt.resourcegraph.models.ColumnDataType + :ivar name: Required. Column name. + :vartype name: str + :ivar type: Required. Column data type. Possible values include: "string", "integer", "number", + "boolean", "object", "datetime". + :vartype type: str or ~azure.mgmt.resourcegraph.models.ColumnDataType """ _validation = { @@ -44,6 +44,13 @@ def __init__( type: Union[str, "ColumnDataType"], **kwargs ): + """ + :keyword name: Required. Column name. + :paramtype name: str + :keyword type: Required. Column data type. Possible values include: "string", "integer", + "number", "boolean", "object", "datetime". + :paramtype type: str or ~azure.mgmt.resourcegraph.models.ColumnDataType + """ super(Column, self).__init__(**kwargs) self.name = name self.type = type @@ -54,14 +61,14 @@ class DateTimeInterval(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param start: Required. A datetime indicating the inclusive/closed start of the time interval, + :ivar start: Required. A datetime indicating the inclusive/closed start of the time interval, i.e. ``[``\ **\ ``start``\ **\ ``, end)``. Specifying a ``start`` that occurs chronologically after ``end`` will result in an error. - :type start: ~datetime.datetime - :param end: Required. A datetime indicating the exclusive/open end of the time interval, i.e. + :vartype start: ~datetime.datetime + :ivar end: Required. A datetime indicating the exclusive/open end of the time interval, i.e. ``[start,``\ **\ ``end``\ **\ ``)``. Specifying an ``end`` that occurs chronologically before ``start`` will result in an error. - :type end: ~datetime.datetime + :vartype end: ~datetime.datetime """ _validation = { @@ -81,6 +88,16 @@ def __init__( end: datetime.datetime, **kwargs ): + """ + :keyword start: Required. A datetime indicating the inclusive/closed start of the time + interval, i.e. ``[``\ **\ ``start``\ **\ ``, end)``. Specifying a ``start`` that occurs + chronologically after ``end`` will result in an error. + :paramtype start: ~datetime.datetime + :keyword end: Required. A datetime indicating the exclusive/open end of the time interval, i.e. + ``[start,``\ **\ ``end``\ **\ ``)``. Specifying an ``end`` that occurs chronologically before + ``start`` will result in an error. + :paramtype end: ~datetime.datetime + """ super(DateTimeInterval, self).__init__(**kwargs) self.start = start self.end = end @@ -91,12 +108,12 @@ class Error(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param code: Required. Error code identifying the specific error. - :type code: str - :param message: Required. A human readable error message. - :type message: str - :param details: Error details. - :type details: list[~azure.mgmt.resourcegraph.models.ErrorDetails] + :ivar code: Required. Error code identifying the specific error. + :vartype code: str + :ivar message: Required. A human readable error message. + :vartype message: str + :ivar details: Error details. + :vartype details: list[~azure.mgmt.resourcegraph.models.ErrorDetails] """ _validation = { @@ -118,6 +135,14 @@ def __init__( details: Optional[List["ErrorDetails"]] = None, **kwargs ): + """ + :keyword code: Required. Error code identifying the specific error. + :paramtype code: str + :keyword message: Required. A human readable error message. + :paramtype message: str + :keyword details: Error details. + :paramtype details: list[~azure.mgmt.resourcegraph.models.ErrorDetails] + """ super(Error, self).__init__(**kwargs) self.code = code self.message = message @@ -129,13 +154,13 @@ class ErrorDetails(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] - :param code: Required. Error code identifying the specific error. - :type code: str - :param message: Required. A human readable error message. - :type message: str + :vartype additional_properties: dict[str, any] + :ivar code: Required. Error code identifying the specific error. + :vartype code: str + :ivar message: Required. A human readable error message. + :vartype message: str """ _validation = { @@ -154,9 +179,18 @@ def __init__( *, code: str, message: str, - additional_properties: Optional[Dict[str, object]] = None, + additional_properties: Optional[Dict[str, Any]] = None, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword code: Required. Error code identifying the specific error. + :paramtype code: str + :keyword message: Required. A human readable error message. + :paramtype message: str + """ super(ErrorDetails, self).__init__(**kwargs) self.additional_properties = additional_properties self.code = code @@ -168,8 +202,8 @@ class ErrorResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param error: Required. Error information. - :type error: ~azure.mgmt.resourcegraph.models.Error + :ivar error: Required. Error information. + :vartype error: ~azure.mgmt.resourcegraph.models.Error """ _validation = { @@ -186,6 +220,10 @@ def __init__( error: "Error", **kwargs ): + """ + :keyword error: Required. Error information. + :paramtype error: ~azure.mgmt.resourcegraph.models.Error + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -198,10 +236,10 @@ class Facet(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param expression: Required. Facet expression, same as in the corresponding facet request. - :type expression: str - :param result_type: Required. Result type.Constant filled by server. - :type result_type: str + :ivar expression: Required. Facet expression, same as in the corresponding facet request. + :vartype expression: str + :ivar result_type: Required. Result type.Constant filled by server. + :vartype result_type: str """ _validation = { @@ -224,6 +262,10 @@ def __init__( expression: str, **kwargs ): + """ + :keyword expression: Required. Facet expression, same as in the corresponding facet request. + :paramtype expression: str + """ super(Facet, self).__init__(**kwargs) self.expression = expression self.result_type = None # type: Optional[str] @@ -234,12 +276,12 @@ class FacetError(Facet): All required parameters must be populated in order to send to Azure. - :param expression: Required. Facet expression, same as in the corresponding facet request. - :type expression: str - :param result_type: Required. Result type.Constant filled by server. - :type result_type: str - :param errors: Required. An array containing detected facet errors with details. - :type errors: list[~azure.mgmt.resourcegraph.models.ErrorDetails] + :ivar expression: Required. Facet expression, same as in the corresponding facet request. + :vartype expression: str + :ivar result_type: Required. Result type.Constant filled by server. + :vartype result_type: str + :ivar errors: Required. An array containing detected facet errors with details. + :vartype errors: list[~azure.mgmt.resourcegraph.models.ErrorDetails] """ _validation = { @@ -261,6 +303,12 @@ def __init__( errors: List["ErrorDetails"], **kwargs ): + """ + :keyword expression: Required. Facet expression, same as in the corresponding facet request. + :paramtype expression: str + :keyword errors: Required. An array containing detected facet errors with details. + :paramtype errors: list[~azure.mgmt.resourcegraph.models.ErrorDetails] + """ super(FacetError, self).__init__(expression=expression, **kwargs) self.result_type = 'FacetError' # type: str self.errors = errors @@ -271,10 +319,10 @@ class FacetRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param expression: Required. The column or list of columns to summarize by. - :type expression: str - :param options: The options for facet evaluation. - :type options: ~azure.mgmt.resourcegraph.models.FacetRequestOptions + :ivar expression: Required. The column or list of columns to summarize by. + :vartype expression: str + :ivar options: The options for facet evaluation. + :vartype options: ~azure.mgmt.resourcegraph.models.FacetRequestOptions """ _validation = { @@ -293,6 +341,12 @@ def __init__( options: Optional["FacetRequestOptions"] = None, **kwargs ): + """ + :keyword expression: Required. The column or list of columns to summarize by. + :paramtype expression: str + :keyword options: The options for facet evaluation. + :paramtype options: ~azure.mgmt.resourcegraph.models.FacetRequestOptions + """ super(FacetRequest, self).__init__(**kwargs) self.expression = expression self.options = options @@ -301,17 +355,17 @@ def __init__( class FacetRequestOptions(msrest.serialization.Model): """The options for facet evaluation. - :param sort_by: The column name or query expression to sort on. Defaults to count if not + :ivar sort_by: The column name or query expression to sort on. Defaults to count if not present. - :type sort_by: str - :param sort_order: The sorting order by the selected column (count by default). Possible values + :vartype sort_by: str + :ivar sort_order: The sorting order by the selected column (count by default). Possible values include: "asc", "desc". Default value: "desc". - :type sort_order: str or ~azure.mgmt.resourcegraph.models.FacetSortOrder - :param filter: Specifies the filter condition for the 'where' clause which will be run on main + :vartype sort_order: str or ~azure.mgmt.resourcegraph.models.FacetSortOrder + :ivar filter: Specifies the filter condition for the 'where' clause which will be run on main query's result, just before the actual faceting. - :type filter: str - :param top: The maximum number of facet rows that should be returned. - :type top: int + :vartype filter: str + :ivar top: The maximum number of facet rows that should be returned. + :vartype top: int """ _validation = { @@ -334,6 +388,19 @@ def __init__( top: Optional[int] = None, **kwargs ): + """ + :keyword sort_by: The column name or query expression to sort on. Defaults to count if not + present. + :paramtype sort_by: str + :keyword sort_order: The sorting order by the selected column (count by default). Possible + values include: "asc", "desc". Default value: "desc". + :paramtype sort_order: str or ~azure.mgmt.resourcegraph.models.FacetSortOrder + :keyword filter: Specifies the filter condition for the 'where' clause which will be run on + main query's result, just before the actual faceting. + :paramtype filter: str + :keyword top: The maximum number of facet rows that should be returned. + :paramtype top: int + """ super(FacetRequestOptions, self).__init__(**kwargs) self.sort_by = sort_by self.sort_order = sort_order @@ -346,17 +413,17 @@ class FacetResult(Facet): All required parameters must be populated in order to send to Azure. - :param expression: Required. Facet expression, same as in the corresponding facet request. - :type expression: str - :param result_type: Required. Result type.Constant filled by server. - :type result_type: str - :param total_records: Required. Number of total records in the facet results. - :type total_records: long - :param count: Required. Number of records returned in the facet response. - :type count: int - :param data: Required. A JObject array or Table containing the desired facets. Only present if + :ivar expression: Required. Facet expression, same as in the corresponding facet request. + :vartype expression: str + :ivar result_type: Required. Result type.Constant filled by server. + :vartype result_type: str + :ivar total_records: Required. Number of total records in the facet results. + :vartype total_records: long + :ivar count: Required. Number of records returned in the facet response. + :vartype count: int + :ivar data: Required. A JObject array or Table containing the desired facets. Only present if the facet is valid. - :type data: object + :vartype data: any """ _validation = { @@ -381,9 +448,20 @@ def __init__( expression: str, total_records: int, count: int, - data: object, + data: Any, **kwargs ): + """ + :keyword expression: Required. Facet expression, same as in the corresponding facet request. + :paramtype expression: str + :keyword total_records: Required. Number of total records in the facet results. + :paramtype total_records: long + :keyword count: Required. Number of records returned in the facet response. + :paramtype count: int + :keyword data: Required. A JObject array or Table containing the desired facets. Only present + if the facet is valid. + :paramtype data: any + """ super(FacetResult, self).__init__(expression=expression, **kwargs) self.result_type = 'FacetResult' # type: str self.total_records = total_records @@ -394,12 +472,12 @@ def __init__( class Operation(msrest.serialization.Model): """Resource Graph REST API operation definition. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: Display metadata associated with the operation. - :type display: ~azure.mgmt.resourcegraph.models.OperationDisplay - :param origin: The origin of operations. - :type origin: str + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: ~azure.mgmt.resourcegraph.models.OperationDisplay + :ivar origin: The origin of operations. + :vartype origin: str """ _attribute_map = { @@ -416,6 +494,14 @@ def __init__( origin: Optional[str] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: ~azure.mgmt.resourcegraph.models.OperationDisplay + :keyword origin: The origin of operations. + :paramtype origin: str + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -425,14 +511,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Display metadata associated with the operation. - :param provider: Service provider: Microsoft Resource Graph. - :type provider: str - :param resource: Resource on which the operation is performed etc. - :type resource: str - :param operation: Type of operation: get, read, delete, etc. - :type operation: str - :param description: Description for the operation. - :type description: str + :ivar provider: Service provider: Microsoft Resource Graph. + :vartype provider: str + :ivar resource: Resource on which the operation is performed etc. + :vartype resource: str + :ivar operation: Type of operation: get, read, delete, etc. + :vartype operation: str + :ivar description: Description for the operation. + :vartype description: str """ _attribute_map = { @@ -451,6 +537,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft Resource Graph. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed etc. + :paramtype resource: str + :keyword operation: Type of operation: get, read, delete, etc. + :paramtype operation: str + :keyword description: Description for the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -461,9 +557,9 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Resource Graph operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of Resource Graph operations supported by the Resource Graph resource + :ivar value: List of Resource Graph operations supported by the Resource Graph resource provider. - :type value: list[~azure.mgmt.resourcegraph.models.Operation] + :vartype value: list[~azure.mgmt.resourcegraph.models.Operation] """ _attribute_map = { @@ -476,6 +572,11 @@ def __init__( value: Optional[List["Operation"]] = None, **kwargs ): + """ + :keyword value: List of Resource Graph operations supported by the Resource Graph resource + provider. + :paramtype value: list[~azure.mgmt.resourcegraph.models.Operation] + """ super(OperationListResult, self).__init__(**kwargs) self.value = value @@ -485,17 +586,17 @@ class QueryRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param subscriptions: Azure subscriptions against which to execute the query. - :type subscriptions: list[str] - :param management_groups: Azure management groups against which to execute the query. Example: - [ 'mg1', 'mg2' ]. - :type management_groups: list[str] - :param query: Required. The resources query. - :type query: str - :param options: The query evaluation options. - :type options: ~azure.mgmt.resourcegraph.models.QueryRequestOptions - :param facets: An array of facet requests to be computed against the query result. - :type facets: list[~azure.mgmt.resourcegraph.models.FacetRequest] + :ivar subscriptions: Azure subscriptions against which to execute the query. + :vartype subscriptions: list[str] + :ivar management_groups: Azure management groups against which to execute the query. Example: [ + 'mg1', 'mg2' ]. + :vartype management_groups: list[str] + :ivar query: Required. The resources query. + :vartype query: str + :ivar options: The query evaluation options. + :vartype options: ~azure.mgmt.resourcegraph.models.QueryRequestOptions + :ivar facets: An array of facet requests to be computed against the query result. + :vartype facets: list[~azure.mgmt.resourcegraph.models.FacetRequest] """ _validation = { @@ -520,6 +621,19 @@ def __init__( facets: Optional[List["FacetRequest"]] = None, **kwargs ): + """ + :keyword subscriptions: Azure subscriptions against which to execute the query. + :paramtype subscriptions: list[str] + :keyword management_groups: Azure management groups against which to execute the query. + Example: [ 'mg1', 'mg2' ]. + :paramtype management_groups: list[str] + :keyword query: Required. The resources query. + :paramtype query: str + :keyword options: The query evaluation options. + :paramtype options: ~azure.mgmt.resourcegraph.models.QueryRequestOptions + :keyword facets: An array of facet requests to be computed against the query result. + :paramtype facets: list[~azure.mgmt.resourcegraph.models.FacetRequest] + """ super(QueryRequest, self).__init__(**kwargs) self.subscriptions = subscriptions self.management_groups = management_groups @@ -531,22 +645,28 @@ def __init__( class QueryRequestOptions(msrest.serialization.Model): """The options for query evaluation. - :param skip_token: Continuation token for pagination, capturing the next page size and offset, + :ivar skip_token: Continuation token for pagination, capturing the next page size and offset, as well as the context of the query. - :type skip_token: str - :param top: The maximum number of rows that the query should return. Overrides the page size + :vartype skip_token: str + :ivar top: The maximum number of rows that the query should return. Overrides the page size when ``$skipToken`` property is present. - :type top: int - :param skip: The number of rows to skip from the beginning of the results. Overrides the next + :vartype top: int + :ivar skip: The number of rows to skip from the beginning of the results. Overrides the next page offset when ``$skipToken`` property is present. - :type skip: int - :param result_format: Defines in which format query result returned. Possible values include: - "table", "objectArray". Default value: "objectArray". - :type result_format: str or ~azure.mgmt.resourcegraph.models.ResultFormat - :param allow_partial_scopes: Only applicable for tenant and management group level queries to + :vartype skip: int + :ivar result_format: Defines in which format query result returned. Possible values include: + "table", "objectArray". + :vartype result_format: str or ~azure.mgmt.resourcegraph.models.ResultFormat + :ivar allow_partial_scopes: Only applicable for tenant and management group level queries to decide whether to allow partial scopes for result in case the number of subscriptions exceed allowed limits. - :type allow_partial_scopes: bool + :vartype allow_partial_scopes: bool + :ivar authorization_scope_filter: Defines what level of authorization resources should be + returned based on the which subscriptions and management groups are passed as scopes. Possible + values include: "AtScopeAndBelow", "AtScopeAndAbove", "AtScopeExact", "AtScopeAboveAndBelow". + Default value: "AtScopeAndBelow". + :vartype authorization_scope_filter: str or + ~azure.mgmt.resourcegraph.models.AuthorizationScopeFilter """ _validation = { @@ -560,6 +680,7 @@ class QueryRequestOptions(msrest.serialization.Model): 'skip': {'key': '$skip', 'type': 'int'}, 'result_format': {'key': 'resultFormat', 'type': 'str'}, 'allow_partial_scopes': {'key': 'allowPartialScopes', 'type': 'bool'}, + 'authorization_scope_filter': {'key': 'authorizationScopeFilter', 'type': 'str'}, } def __init__( @@ -568,16 +689,42 @@ def __init__( skip_token: Optional[str] = None, top: Optional[int] = None, skip: Optional[int] = None, - result_format: Optional[Union[str, "ResultFormat"]] = "objectArray", + result_format: Optional[Union[str, "ResultFormat"]] = None, allow_partial_scopes: Optional[bool] = False, + authorization_scope_filter: Optional[Union[str, "AuthorizationScopeFilter"]] = "AtScopeAndBelow", **kwargs ): + """ + :keyword skip_token: Continuation token for pagination, capturing the next page size and + offset, as well as the context of the query. + :paramtype skip_token: str + :keyword top: The maximum number of rows that the query should return. Overrides the page size + when ``$skipToken`` property is present. + :paramtype top: int + :keyword skip: The number of rows to skip from the beginning of the results. Overrides the next + page offset when ``$skipToken`` property is present. + :paramtype skip: int + :keyword result_format: Defines in which format query result returned. Possible values include: + "table", "objectArray". + :paramtype result_format: str or ~azure.mgmt.resourcegraph.models.ResultFormat + :keyword allow_partial_scopes: Only applicable for tenant and management group level queries to + decide whether to allow partial scopes for result in case the number of subscriptions exceed + allowed limits. + :paramtype allow_partial_scopes: bool + :keyword authorization_scope_filter: Defines what level of authorization resources should be + returned based on the which subscriptions and management groups are passed as scopes. Possible + values include: "AtScopeAndBelow", "AtScopeAndAbove", "AtScopeExact", "AtScopeAboveAndBelow". + Default value: "AtScopeAndBelow". + :paramtype authorization_scope_filter: str or + ~azure.mgmt.resourcegraph.models.AuthorizationScopeFilter + """ super(QueryRequestOptions, self).__init__(**kwargs) self.skip_token = skip_token self.top = top self.skip = skip self.result_format = result_format self.allow_partial_scopes = allow_partial_scopes + self.authorization_scope_filter = authorization_scope_filter class QueryResponse(msrest.serialization.Model): @@ -585,21 +732,21 @@ class QueryResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param total_records: Required. Number of total records matching the query. - :type total_records: long - :param count: Required. Number of records returned in the current response. In the case of + :ivar total_records: Required. Number of total records matching the query. + :vartype total_records: long + :ivar count: Required. Number of records returned in the current response. In the case of paging, this is the number of records in the current page. - :type count: long - :param result_truncated: Required. Indicates whether the query results are truncated. Possible + :vartype count: long + :ivar result_truncated: Required. Indicates whether the query results are truncated. Possible values include: "true", "false". - :type result_truncated: str or ~azure.mgmt.resourcegraph.models.ResultTruncated - :param skip_token: When present, the value can be passed to a subsequent query call (together + :vartype result_truncated: str or ~azure.mgmt.resourcegraph.models.ResultTruncated + :ivar skip_token: When present, the value can be passed to a subsequent query call (together with the same query and scopes used in the current request) to retrieve the next page of data. - :type skip_token: str - :param data: Required. Query output in JObject array or Table format. - :type data: object - :param facets: Query facets. - :type facets: list[~azure.mgmt.resourcegraph.models.Facet] + :vartype skip_token: str + :ivar data: Required. Query output in JObject array or Table format. + :vartype data: any + :ivar facets: Query facets. + :vartype facets: list[~azure.mgmt.resourcegraph.models.Facet] """ _validation = { @@ -624,11 +771,28 @@ def __init__( total_records: int, count: int, result_truncated: Union[str, "ResultTruncated"], - data: object, + data: Any, skip_token: Optional[str] = None, facets: Optional[List["Facet"]] = None, **kwargs ): + """ + :keyword total_records: Required. Number of total records matching the query. + :paramtype total_records: long + :keyword count: Required. Number of records returned in the current response. In the case of + paging, this is the number of records in the current page. + :paramtype count: long + :keyword result_truncated: Required. Indicates whether the query results are truncated. + Possible values include: "true", "false". + :paramtype result_truncated: str or ~azure.mgmt.resourcegraph.models.ResultTruncated + :keyword skip_token: When present, the value can be passed to a subsequent query call (together + with the same query and scopes used in the current request) to retrieve the next page of data. + :paramtype skip_token: str + :keyword data: Required. Query output in JObject array or Table format. + :paramtype data: any + :keyword facets: Query facets. + :paramtype facets: list[~azure.mgmt.resourcegraph.models.Facet] + """ super(QueryResponse, self).__init__(**kwargs) self.total_records = total_records self.count = count @@ -638,412 +802,25 @@ def __init__( self.facets = facets -class ResourceChangeData(msrest.serialization.Model): - """Data on a specific change, represented by a pair of before and after resource snapshots. - - All required parameters must be populated in order to send to Azure. - - :param resource_id: The resource for a change. - :type resource_id: str - :param change_id: Required. The change ID. Valid and unique within the specified resource only. - :type change_id: str - :param before_snapshot: Required. The snapshot before the change. - :type before_snapshot: ~azure.mgmt.resourcegraph.models.ResourceChangeDataBeforeSnapshot - :param after_snapshot: Required. The snapshot after the change. - :type after_snapshot: ~azure.mgmt.resourcegraph.models.ResourceChangeDataAfterSnapshot - :param change_type: The change type for snapshot. PropertyChanges will be provided in case of - Update change type. Possible values include: "Create", "Update", "Delete". - :type change_type: str or ~azure.mgmt.resourcegraph.models.ChangeType - :param property_changes: An array of resource property change. - :type property_changes: list[~azure.mgmt.resourcegraph.models.ResourcePropertyChange] - """ - - _validation = { - 'change_id': {'required': True}, - 'before_snapshot': {'required': True}, - 'after_snapshot': {'required': True}, - } - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'change_id': {'key': 'changeId', 'type': 'str'}, - 'before_snapshot': {'key': 'beforeSnapshot', 'type': 'ResourceChangeDataBeforeSnapshot'}, - 'after_snapshot': {'key': 'afterSnapshot', 'type': 'ResourceChangeDataAfterSnapshot'}, - 'change_type': {'key': 'changeType', 'type': 'str'}, - 'property_changes': {'key': 'propertyChanges', 'type': '[ResourcePropertyChange]'}, - } - - def __init__( - self, - *, - change_id: str, - before_snapshot: "ResourceChangeDataBeforeSnapshot", - after_snapshot: "ResourceChangeDataAfterSnapshot", - resource_id: Optional[str] = None, - change_type: Optional[Union[str, "ChangeType"]] = None, - property_changes: Optional[List["ResourcePropertyChange"]] = None, - **kwargs - ): - super(ResourceChangeData, self).__init__(**kwargs) - self.resource_id = resource_id - self.change_id = change_id - self.before_snapshot = before_snapshot - self.after_snapshot = after_snapshot - self.change_type = change_type - self.property_changes = property_changes - - -class ResourceSnapshotData(msrest.serialization.Model): - """Data on a specific resource snapshot. - - All required parameters must be populated in order to send to Azure. - - :param snapshot_id: The ID of the snapshot. - :type snapshot_id: str - :param timestamp: Required. The time when the snapshot was created. - The snapshot timestamp provides an approximation as to when a modification to a resource was - detected. There can be a difference between the actual modification time and the detection - time. This is due to differences in how operations that modify a resource are processed, - versus how operation that record resource snapshots are processed. - :type timestamp: ~datetime.datetime - :param content: The resource snapshot content (in resourceChangeDetails response only). - :type content: object - """ - - _validation = { - 'timestamp': {'required': True}, - } - - _attribute_map = { - 'snapshot_id': {'key': 'snapshotId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'content': {'key': 'content', 'type': 'object'}, - } - - def __init__( - self, - *, - timestamp: datetime.datetime, - snapshot_id: Optional[str] = None, - content: Optional[object] = None, - **kwargs - ): - super(ResourceSnapshotData, self).__init__(**kwargs) - self.snapshot_id = snapshot_id - self.timestamp = timestamp - self.content = content - - -class ResourceChangeDataAfterSnapshot(ResourceSnapshotData): - """The snapshot after the change. - - All required parameters must be populated in order to send to Azure. - - :param snapshot_id: The ID of the snapshot. - :type snapshot_id: str - :param timestamp: Required. The time when the snapshot was created. - The snapshot timestamp provides an approximation as to when a modification to a resource was - detected. There can be a difference between the actual modification time and the detection - time. This is due to differences in how operations that modify a resource are processed, - versus how operation that record resource snapshots are processed. - :type timestamp: ~datetime.datetime - :param content: The resource snapshot content (in resourceChangeDetails response only). - :type content: object - """ - - _validation = { - 'timestamp': {'required': True}, - } - - _attribute_map = { - 'snapshot_id': {'key': 'snapshotId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'content': {'key': 'content', 'type': 'object'}, - } - - def __init__( - self, - *, - timestamp: datetime.datetime, - snapshot_id: Optional[str] = None, - content: Optional[object] = None, - **kwargs - ): - super(ResourceChangeDataAfterSnapshot, self).__init__(snapshot_id=snapshot_id, timestamp=timestamp, content=content, **kwargs) - - -class ResourceChangeDataBeforeSnapshot(ResourceSnapshotData): - """The snapshot before the change. - - All required parameters must be populated in order to send to Azure. - - :param snapshot_id: The ID of the snapshot. - :type snapshot_id: str - :param timestamp: Required. The time when the snapshot was created. - The snapshot timestamp provides an approximation as to when a modification to a resource was - detected. There can be a difference between the actual modification time and the detection - time. This is due to differences in how operations that modify a resource are processed, - versus how operation that record resource snapshots are processed. - :type timestamp: ~datetime.datetime - :param content: The resource snapshot content (in resourceChangeDetails response only). - :type content: object - """ - - _validation = { - 'timestamp': {'required': True}, - } - - _attribute_map = { - 'snapshot_id': {'key': 'snapshotId', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'content': {'key': 'content', 'type': 'object'}, - } - - def __init__( - self, - *, - timestamp: datetime.datetime, - snapshot_id: Optional[str] = None, - content: Optional[object] = None, - **kwargs - ): - super(ResourceChangeDataBeforeSnapshot, self).__init__(snapshot_id=snapshot_id, timestamp=timestamp, content=content, **kwargs) - - -class ResourceChangeDetailsRequestParameters(msrest.serialization.Model): - """The parameters for a specific change details request. - - All required parameters must be populated in order to send to Azure. - - :param resource_ids: Required. Specifies the list of resources for a change details request. - :type resource_ids: list[str] - :param change_ids: Required. Specifies the list of change IDs for a change details request. - :type change_ids: list[str] - """ - - _validation = { - 'resource_ids': {'required': True}, - 'change_ids': {'required': True}, - } - - _attribute_map = { - 'resource_ids': {'key': 'resourceIds', 'type': '[str]'}, - 'change_ids': {'key': 'changeIds', 'type': '[str]'}, - } - - def __init__( - self, - *, - resource_ids: List[str], - change_ids: List[str], - **kwargs - ): - super(ResourceChangeDetailsRequestParameters, self).__init__(**kwargs) - self.resource_ids = resource_ids - self.change_ids = change_ids - - -class ResourceChangeList(msrest.serialization.Model): - """A list of changes associated with a resource over a specific time interval. - - :param changes: The pageable value returned by the operation, i.e. a list of changes to the - resource. - - - * The list is ordered from the most recent changes to the least recent changes. - * This list will be empty if there were no changes during the requested interval. - * The ``Before`` snapshot timestamp value of the oldest change can be outside of the specified - time interval. - :type changes: list[~azure.mgmt.resourcegraph.models.ResourceChangeData] - :param skip_token: Skip token that encodes the skip information while executing the current - request. - :type skip_token: object - """ - - _attribute_map = { - 'changes': {'key': 'changes', 'type': '[ResourceChangeData]'}, - 'skip_token': {'key': '$skipToken', 'type': 'object'}, - } - - def __init__( - self, - *, - changes: Optional[List["ResourceChangeData"]] = None, - skip_token: Optional[object] = None, - **kwargs - ): - super(ResourceChangeList, self).__init__(**kwargs) - self.changes = changes - self.skip_token = skip_token - - -class ResourceChangesRequestParameters(msrest.serialization.Model): - """The parameters for a specific changes request. - - All required parameters must be populated in order to send to Azure. - - :param resource_ids: Specifies the list of resources for a changes request. - :type resource_ids: list[str] - :param subscription_id: The subscription id of resources to query the changes from. - :type subscription_id: str - :param interval: Required. Specifies the date and time interval for a changes request. - :type interval: ~azure.mgmt.resourcegraph.models.ResourceChangesRequestParametersInterval - :param skip_token: Acts as the continuation token for paged responses. - :type skip_token: str - :param top: The maximum number of changes the client can accept in a paged response. - :type top: int - :param table: The table name to query resources from. - :type table: str - :param fetch_property_changes: The flag if set to true will fetch property changes. - :type fetch_property_changes: bool - :param fetch_snapshots: The flag if set to true will fetch change snapshots. - :type fetch_snapshots: bool - """ - - _validation = { - 'interval': {'required': True}, - 'top': {'maximum': 1000, 'minimum': 1}, - } - - _attribute_map = { - 'resource_ids': {'key': 'resourceIds', 'type': '[str]'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'interval': {'key': 'interval', 'type': 'ResourceChangesRequestParametersInterval'}, - 'skip_token': {'key': '$skipToken', 'type': 'str'}, - 'top': {'key': '$top', 'type': 'int'}, - 'table': {'key': 'table', 'type': 'str'}, - 'fetch_property_changes': {'key': 'fetchPropertyChanges', 'type': 'bool'}, - 'fetch_snapshots': {'key': 'fetchSnapshots', 'type': 'bool'}, - } - - def __init__( - self, - *, - interval: "ResourceChangesRequestParametersInterval", - resource_ids: Optional[List[str]] = None, - subscription_id: Optional[str] = None, - skip_token: Optional[str] = None, - top: Optional[int] = None, - table: Optional[str] = None, - fetch_property_changes: Optional[bool] = None, - fetch_snapshots: Optional[bool] = None, - **kwargs - ): - super(ResourceChangesRequestParameters, self).__init__(**kwargs) - self.resource_ids = resource_ids - self.subscription_id = subscription_id - self.interval = interval - self.skip_token = skip_token - self.top = top - self.table = table - self.fetch_property_changes = fetch_property_changes - self.fetch_snapshots = fetch_snapshots - - -class ResourceChangesRequestParametersInterval(DateTimeInterval): - """Specifies the date and time interval for a changes request. - - All required parameters must be populated in order to send to Azure. - - :param start: Required. A datetime indicating the inclusive/closed start of the time interval, - i.e. ``[``\ **\ ``start``\ **\ ``, end)``. Specifying a ``start`` that occurs chronologically - after ``end`` will result in an error. - :type start: ~datetime.datetime - :param end: Required. A datetime indicating the exclusive/open end of the time interval, i.e. - ``[start,``\ **\ ``end``\ **\ ``)``. Specifying an ``end`` that occurs chronologically before - ``start`` will result in an error. - :type end: ~datetime.datetime - """ - - _validation = { - 'start': {'required': True}, - 'end': {'required': True}, - } - - _attribute_map = { - 'start': {'key': 'start', 'type': 'iso-8601'}, - 'end': {'key': 'end', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - start: datetime.datetime, - end: datetime.datetime, - **kwargs - ): - super(ResourceChangesRequestParametersInterval, self).__init__(start=start, end=end, **kwargs) - - -class ResourcePropertyChange(msrest.serialization.Model): - """The resource property change. - - All required parameters must be populated in order to send to Azure. - - :param property_name: Required. The property name. - :type property_name: str - :param before_value: The property value in before snapshot. - :type before_value: str - :param after_value: The property value in after snapshot. - :type after_value: str - :param change_category: Required. The change category. Possible values include: "User", - "System". - :type change_category: str or ~azure.mgmt.resourcegraph.models.ChangeCategory - :param property_change_type: Required. The property change Type. Possible values include: - "Insert", "Update", "Remove". - :type property_change_type: str or ~azure.mgmt.resourcegraph.models.PropertyChangeType - """ - - _validation = { - 'property_name': {'required': True}, - 'change_category': {'required': True}, - 'property_change_type': {'required': True}, - } - - _attribute_map = { - 'property_name': {'key': 'propertyName', 'type': 'str'}, - 'before_value': {'key': 'beforeValue', 'type': 'str'}, - 'after_value': {'key': 'afterValue', 'type': 'str'}, - 'change_category': {'key': 'changeCategory', 'type': 'str'}, - 'property_change_type': {'key': 'propertyChangeType', 'type': 'str'}, - } - - def __init__( - self, - *, - property_name: str, - change_category: Union[str, "ChangeCategory"], - property_change_type: Union[str, "PropertyChangeType"], - before_value: Optional[str] = None, - after_value: Optional[str] = None, - **kwargs - ): - super(ResourcePropertyChange, self).__init__(**kwargs) - self.property_name = property_name - self.before_value = before_value - self.after_value = after_value - self.change_category = change_category - self.property_change_type = property_change_type - - class ResourcesHistoryRequest(msrest.serialization.Model): - """ResourcesHistoryRequest. - - :param subscriptions: - :type subscriptions: list[str] - :param query: - :type query: str - :param options: - :type options: ~azure.mgmt.resourcegraph.models.ResourcesHistoryRequestOptions - :param management_group_id: - :type management_group_id: str + """Describes a history request to be executed. + + :ivar subscriptions: Azure subscriptions against which to execute the query. + :vartype subscriptions: list[str] + :ivar query: The resources query. + :vartype query: str + :ivar options: The history request evaluation options. + :vartype options: ~azure.mgmt.resourcegraph.models.ResourcesHistoryRequestOptions + :ivar management_groups: Azure management groups against which to execute the query. Example: [ + 'mg1', 'mg2' ]. + :vartype management_groups: list[str] """ _attribute_map = { 'subscriptions': {'key': 'subscriptions', 'type': '[str]'}, 'query': {'key': 'query', 'type': 'str'}, 'options': {'key': 'options', 'type': 'ResourcesHistoryRequestOptions'}, - 'management_group_id': {'key': 'managementGroupId', 'type': 'str'}, + 'management_groups': {'key': 'managementGroups', 'type': '[str]'}, } def __init__( @@ -1052,33 +829,51 @@ def __init__( subscriptions: Optional[List[str]] = None, query: Optional[str] = None, options: Optional["ResourcesHistoryRequestOptions"] = None, - management_group_id: Optional[str] = None, + management_groups: Optional[List[str]] = None, **kwargs ): + """ + :keyword subscriptions: Azure subscriptions against which to execute the query. + :paramtype subscriptions: list[str] + :keyword query: The resources query. + :paramtype query: str + :keyword options: The history request evaluation options. + :paramtype options: ~azure.mgmt.resourcegraph.models.ResourcesHistoryRequestOptions + :keyword management_groups: Azure management groups against which to execute the query. + Example: [ 'mg1', 'mg2' ]. + :paramtype management_groups: list[str] + """ super(ResourcesHistoryRequest, self).__init__(**kwargs) self.subscriptions = subscriptions self.query = query self.options = options - self.management_group_id = management_group_id + self.management_groups = management_groups class ResourcesHistoryRequestOptions(msrest.serialization.Model): - """ResourcesHistoryRequestOptions. - - :param interval: An interval in time specifying the date and time for the inclusive start and - exclusive end, i.e. ``[start, end)``. - :type interval: ~azure.mgmt.resourcegraph.models.DateTimeInterval - :param top: - :type top: int - :param skip: - :type skip: int - :param skip_token: - :type skip_token: str - :param result_format: Possible values include: "table", "objectArray". - :type result_format: str or - ~azure.mgmt.resourcegraph.models.ResourcesHistoryRequestOptionsResultFormat + """The options for history request evaluation. + + :ivar interval: The time interval used to fetch history. + :vartype interval: ~azure.mgmt.resourcegraph.models.DateTimeInterval + :ivar top: The maximum number of rows that the query should return. Overrides the page size + when ``$skipToken`` property is present. + :vartype top: int + :ivar skip: The number of rows to skip from the beginning of the results. Overrides the next + page offset when ``$skipToken`` property is present. + :vartype skip: int + :ivar skip_token: Continuation token for pagination, capturing the next page size and offset, + as well as the context of the query. + :vartype skip_token: str + :ivar result_format: Defines in which format query result returned. Possible values include: + "table", "objectArray". + :vartype result_format: str or ~azure.mgmt.resourcegraph.models.ResultFormat """ + _validation = { + 'top': {'maximum': 1000, 'minimum': 1}, + 'skip': {'minimum': 0}, + } + _attribute_map = { 'interval': {'key': 'interval', 'type': 'DateTimeInterval'}, 'top': {'key': '$top', 'type': 'int'}, @@ -1094,9 +889,25 @@ def __init__( top: Optional[int] = None, skip: Optional[int] = None, skip_token: Optional[str] = None, - result_format: Optional[Union[str, "ResourcesHistoryRequestOptionsResultFormat"]] = None, + result_format: Optional[Union[str, "ResultFormat"]] = None, **kwargs ): + """ + :keyword interval: The time interval used to fetch history. + :paramtype interval: ~azure.mgmt.resourcegraph.models.DateTimeInterval + :keyword top: The maximum number of rows that the query should return. Overrides the page size + when ``$skipToken`` property is present. + :paramtype top: int + :keyword skip: The number of rows to skip from the beginning of the results. Overrides the next + page offset when ``$skipToken`` property is present. + :paramtype skip: int + :keyword skip_token: Continuation token for pagination, capturing the next page size and + offset, as well as the context of the query. + :paramtype skip_token: str + :keyword result_format: Defines in which format query result returned. Possible values include: + "table", "objectArray". + :paramtype result_format: str or ~azure.mgmt.resourcegraph.models.ResultFormat + """ super(ResourcesHistoryRequestOptions, self).__init__(**kwargs) self.interval = interval self.top = top @@ -1110,10 +921,10 @@ class Table(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param columns: Required. Query result column descriptors. - :type columns: list[~azure.mgmt.resourcegraph.models.Column] - :param rows: Required. Query result rows. - :type rows: list[list[object]] + :ivar columns: Required. Query result column descriptors. + :vartype columns: list[~azure.mgmt.resourcegraph.models.Column] + :ivar rows: Required. Query result rows. + :vartype rows: list[list[any]] """ _validation = { @@ -1130,9 +941,15 @@ def __init__( self, *, columns: List["Column"], - rows: List[List[object]], + rows: List[List[Any]], **kwargs ): + """ + :keyword columns: Required. Query result column descriptors. + :paramtype columns: list[~azure.mgmt.resourcegraph.models.Column] + :keyword rows: Required. Query result rows. + :paramtype rows: list[list[any]] + """ super(Table, self).__init__(**kwargs) self.columns = columns self.rows = rows diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/_resource_graph_client_enums.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/_resource_graph_client_enums.py index e221084b3baa..9f3e3c1f418d 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/_resource_graph_client_enums.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/_resource_graph_client_enums.py @@ -6,42 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -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 ChangeCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The change category. - """ - - USER = "User" - SYSTEM = "System" - -class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The change type for snapshot. PropertyChanges will be provided in case of Update change type +class AuthorizationScopeFilter(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Defines what level of authorization resources should be returned based on the which + subscriptions and management groups are passed as scopes. """ - CREATE = "Create" - UPDATE = "Update" - DELETE = "Delete" + AT_SCOPE_AND_BELOW = "AtScopeAndBelow" + AT_SCOPE_AND_ABOVE = "AtScopeAndAbove" + AT_SCOPE_EXACT = "AtScopeExact" + AT_SCOPE_ABOVE_AND_BELOW = "AtScopeAboveAndBelow" -class ColumnDataType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ColumnDataType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Data type of a column in a table. """ @@ -50,35 +30,23 @@ class ColumnDataType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NUMBER = "number" BOOLEAN = "boolean" OBJECT = "object" + DATETIME = "datetime" -class FacetSortOrder(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FacetSortOrder(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The sorting order by the selected column (count by default). """ ASC = "asc" DESC = "desc" -class PropertyChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The property change Type - """ - - INSERT = "Insert" - UPDATE = "Update" - REMOVE = "Remove" - -class ResourcesHistoryRequestOptionsResultFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - TABLE = "table" - OBJECT_ARRAY = "objectArray" - -class ResultFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResultFormat(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Defines in which format query result returned. """ TABLE = "table" OBJECT_ARRAY = "objectArray" -class ResultTruncated(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResultTruncated(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates whether the query results are truncated. """ diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/_operations.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/_operations.py index 96b0bd7d4d63..6fc0bc1c7037 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/_operations.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/_operations.py @@ -5,23 +5,50 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar 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.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ResourceGraph/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01" - 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 = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/_resource_graph_client_operations.py b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/_resource_graph_client_operations.py index 4cc35520fa0d..519b57649da2 100644 --- a/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/_resource_graph_client_operations.py +++ b/sdk/resources/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/_resource_graph_client_operations.py @@ -5,143 +5,102 @@ # 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 functools +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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_resources_request( + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ResourceGraph/resources') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_resources_history_request( + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ResourceGraph/resourcesHistory') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ResourceGraphClientOperationsMixin(object): - def resource_changes( - self, - parameters, # type: "_models.ResourceChangesRequestParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourceChangeList" - """List changes to a resource for a given time interval. - - :param parameters: the parameters for this request for changes. - :type parameters: ~azure.mgmt.resourcegraph.models.ResourceChangesRequestParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourceChangeList, or the result of cls(response) - :rtype: ~azure.mgmt.resourcegraph.models.ResourceChangeList - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceChangeList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.resource_changes.metadata['url'] # type: ignore - - # 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(parameters, 'ResourceChangesRequestParameters') - 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('ResourceChangeList', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - resource_changes.metadata = {'url': '/providers/Microsoft.ResourceGraph/resourceChanges'} # type: ignore - - def resource_change_details( - self, - parameters, # type: "_models.ResourceChangeDetailsRequestParameters" - **kwargs # type: Any - ): - # type: (...) -> List["_models.ResourceChangeData"] - """Get resource change details. - - :param parameters: The parameters for this request for resource change details. - :type parameters: ~azure.mgmt.resourcegraph.models.ResourceChangeDetailsRequestParameters - :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of ResourceChangeData, or the result of cls(response) - :rtype: list[~azure.mgmt.resourcegraph.models.ResourceChangeData] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ResourceChangeData"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.resource_change_details.metadata['url'] # type: ignore - - # 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(parameters, 'ResourceChangeDetailsRequestParameters') - 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('[ResourceChangeData]', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - resource_change_details.metadata = {'url': '/providers/Microsoft.ResourceGraph/resourceChangeDetails'} # type: ignore - + @distributed_trace def resources( self, - query, # type: "_models.QueryRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.QueryResponse" + query: "_models.QueryRequest", + **kwargs: Any + ) -> "_models.QueryResponse": """Queries the resources managed by Azure Resource Manager for scopes specified in the request. :param query: Request specifying query and its options. @@ -156,32 +115,25 @@ def resources( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.resources.metadata['url'] # type: ignore - - # 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(query, 'QueryRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(query, 'QueryRequest') + + request = build_resources_request( + content_type=content_type, + json=_json, + template_url=self.resources.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QueryResponse', pipeline_response) @@ -190,54 +142,49 @@ def resources( return cls(pipeline_response, deserialized, {}) return deserialized + resources.metadata = {'url': '/providers/Microsoft.ResourceGraph/resources'} # type: ignore + + @distributed_trace def resources_history( self, - request, # type: "_models.ResourcesHistoryRequest" - **kwargs # type: Any - ): - # type: (...) -> object + request: "_models.ResourcesHistoryRequest", + **kwargs: Any + ) -> Any: """List all snapshots of a resource for a given time interval. - :param request: + :param request: Request specifying the query and its options. :type request: ~azure.mgmt.resourcegraph.models.ResourcesHistoryRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: object, or the result of cls(response) - :rtype: object + :return: any, or the result of cls(response) + :rtype: any :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[object] + cls = kwargs.pop('cls', None) # type: ClsType[Any] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.resources_history.metadata['url'] # type: ignore - - # 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(request, 'ResourcesHistoryRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(request, 'ResourcesHistoryRequest') + + request = build_resources_history_request( + content_type=content_type, + json=_json, + template_url=self.resources_history.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('object', pipeline_response) @@ -246,4 +193,6 @@ def resources_history( return cls(pipeline_response, deserialized, {}) return deserialized + resources_history.metadata = {'url': '/providers/Microsoft.ResourceGraph/resourcesHistory'} # type: ignore +