diff --git a/sdk/azure-imds/azure/imds/__init__.py b/sdk/azure-imds/azure/imds/__init__.py new file mode 100644 index 000000000000..1fa037b34cea --- /dev/null +++ b/sdk/azure-imds/azure/imds/__init__.py @@ -0,0 +1,18 @@ +# 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 .instance_metadata_client import InstanceMetadataClient +from .version import VERSION + +__all__ = ['InstanceMetadataClient'] + +__version__ = VERSION + diff --git a/sdk/azure-imds/azure/imds/instance_metadata_client.py b/sdk/azure-imds/azure/imds/instance_metadata_client.py new file mode 100644 index 000000000000..3085af7beb7a --- /dev/null +++ b/sdk/azure-imds/azure/imds/instance_metadata_client.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer +from msrestazure import AzureConfiguration +from .version import VERSION +from .operations.instances_operations import InstancesOperations +from .operations.attested_operations import AttestedOperations +from .operations.identity_operations import IdentityOperations +from . import models + + +class InstanceMetadataClientConfiguration(AzureConfiguration): + """Configuration for InstanceMetadataClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if not base_url: + base_url = 'https://169.254.169.254/metadata' + + super(InstanceMetadataClientConfiguration, self).__init__(base_url) + + self.add_user_agent('azure-imds/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + + +class InstanceMetadataClient(SDKClient): + """The Azure Instance Metadata Client + + :ivar config: Configuration for client. + :vartype config: InstanceMetadataClientConfiguration + + :ivar instances: Instances operations + :vartype instances: azure.imds.operations.InstancesOperations + :ivar attested: Attested operations + :vartype attested: azure.imds.operations.AttestedOperations + :ivar identity: Identity operations + :vartype identity: azure.imds.operations.IdentityOperations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + self.config = InstanceMetadataClientConfiguration(credentials, base_url) + super(InstanceMetadataClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2019-02-01' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.instances = InstancesOperations( + self._client, self.config, self._serialize, self._deserialize) + self.attested = AttestedOperations( + self._client, self.config, self._serialize, self._deserialize) + self.identity = IdentityOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/sdk/azure-imds/azure/imds/models/__init__.py b/sdk/azure-imds/azure/imds/models/__init__.py new file mode 100644 index 000000000000..aa11901b8855 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/__init__.py @@ -0,0 +1,70 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +try: + from .plan_properties_py3 import PlanProperties + from .public_keys_properties_py3 import PublicKeysProperties + from .compute_py3 import Compute + from .ipv4_properties_py3 import Ipv4Properties + from .subnet_properties_py3 import SubnetProperties + from .network_interface_ipv4_py3 import NetworkInterfaceIpv4 + from .ipv6_properties_py3 import Ipv6Properties + from .network_interface_ipv6_py3 import NetworkInterfaceIpv6 + from .network_interface_py3 import NetworkInterface + from .network_py3 import Network + from .instance_py3 import Instance + from .attested_data_py3 import AttestedData + from .error_response_py3 import ErrorResponse, ErrorResponseException + from .identity_error_response_py3 import IdentityErrorResponse, IdentityErrorResponseException + from .identity_token_response_py3 import IdentityTokenResponse + from .identity_info_response_py3 import IdentityInfoResponse +except (SyntaxError, ImportError): + from .plan_properties import PlanProperties + from .public_keys_properties import PublicKeysProperties + from .compute import Compute + from .ipv4_properties import Ipv4Properties + from .subnet_properties import SubnetProperties + from .network_interface_ipv4 import NetworkInterfaceIpv4 + from .ipv6_properties import Ipv6Properties + from .network_interface_ipv6 import NetworkInterfaceIpv6 + from .network_interface import NetworkInterface + from .network import Network + from .instance import Instance + from .attested_data import AttestedData + from .error_response import ErrorResponse, ErrorResponseException + from .identity_error_response import IdentityErrorResponse, IdentityErrorResponseException + from .identity_token_response import IdentityTokenResponse + from .identity_info_response import IdentityInfoResponse +from .instance_metadata_client_enums import ( + Error, + BypassCache, +) + +__all__ = [ + 'PlanProperties', + 'PublicKeysProperties', + 'Compute', + 'Ipv4Properties', + 'SubnetProperties', + 'NetworkInterfaceIpv4', + 'Ipv6Properties', + 'NetworkInterfaceIpv6', + 'NetworkInterface', + 'Network', + 'Instance', + 'AttestedData', + 'ErrorResponse', 'ErrorResponseException', + 'IdentityErrorResponse', 'IdentityErrorResponseException', + 'IdentityTokenResponse', + 'IdentityInfoResponse', + 'Error', + 'BypassCache', +] diff --git a/sdk/azure-imds/azure/imds/models/attested_data.py b/sdk/azure-imds/azure/imds/models/attested_data.py new file mode 100644 index 000000000000..1da42f2bb93d --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/attested_data.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class AttestedData(Model): + """This is the response from the Attested_GetDocument operation. + + :param signature: This is the encoded string containing the VM ID, plan + information, public key, timestamp, and nonce value. + :type signature: str + :param encoding: This is the encoding scheme of the signature. + :type encoding: str + """ + + _attribute_map = { + 'signature': {'key': 'signature', 'type': 'str'}, + 'encoding': {'key': 'encoding', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(AttestedData, self).__init__(**kwargs) + self.signature = kwargs.get('signature', None) + self.encoding = kwargs.get('encoding', None) diff --git a/sdk/azure-imds/azure/imds/models/attested_data_py3.py b/sdk/azure-imds/azure/imds/models/attested_data_py3.py new file mode 100644 index 000000000000..dedc15d9a6b8 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/attested_data_py3.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class AttestedData(Model): + """This is the response from the Attested_GetDocument operation. + + :param signature: This is the encoded string containing the VM ID, plan + information, public key, timestamp, and nonce value. + :type signature: str + :param encoding: This is the encoding scheme of the signature. + :type encoding: str + """ + + _attribute_map = { + 'signature': {'key': 'signature', 'type': 'str'}, + 'encoding': {'key': 'encoding', 'type': 'str'}, + } + + def __init__(self, *, signature: str=None, encoding: str=None, **kwargs) -> None: + super(AttestedData, self).__init__(**kwargs) + self.signature = signature + self.encoding = encoding diff --git a/sdk/azure-imds/azure/imds/models/compute.py b/sdk/azure-imds/azure/imds/models/compute.py new file mode 100644 index 000000000000..8fa596901a3f --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/compute.py @@ -0,0 +1,117 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Compute(Model): + """Compute Metadata. + + :param az_environment: This is the name of the environment in which the VM + is running. + :type az_environment: str + :param custom_data: This is the base64 encoded custom data for the running + VM. + :type custom_data: str + :param location: This is the Azure Region in which the VM is running. + :type location: str + :param name: This is the name of the VM. + :type name: str + :param offer: This is the offer information for the VM image. This value + is only present for images deployed from the Azure Image Gallery. + :type offer: str + :param os_type: This value indicates the type of OS the VM is running, + either Linux or Windows. + :type os_type: str + :param placement_group_id: This is the placement group of your Virtual + Machine Scale Set. + :type placement_group_id: str + :param plan: This contains the data about the plan. + :type plan: ~azure.imds.models.PlanProperties + :param public_keys: This is information about the SSH certificate + :type public_keys: list[~azure.imds.models.PublicKeysProperties] + :param platform_fault_domain: This is the fault domain in which the VM. + :type platform_fault_domain: str + :param platform_update_domain: This is the update domain in which the VM. + :type platform_update_domain: str + :param provider: This is the provider of the VM. + :type provider: str + :param publisher: This is the publisher of the VM image. + :type publisher: str + :param resource_group_name: This is the resource group for the VM. + :type resource_group_name: str + :param sku: This is the specific SKU for the VM image. + :type sku: str + :param subscription_id: This is the Azure subscription for the VM. + :type subscription_id: str + :param tags: This is the list of tags for your VM. + :type tags: str + :param version: This is the version of the VM image. + :type version: str + :param vm_id: This is the unique identifier for the VM. + :type vm_id: str + :param vm_scale_set_name: This is the resource name of the VMSS. + :type vm_scale_set_name: str + :param vm_size: This is the size of the VM. + :type vm_size: str + :param zone: This is the availability zone of the VM. + :type zone: str + """ + + _attribute_map = { + 'az_environment': {'key': 'azEnvironment', 'type': 'str'}, + 'custom_data': {'key': 'customData', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'offer': {'key': 'offer', 'type': 'str'}, + 'os_type': {'key': 'osType', 'type': 'str'}, + 'placement_group_id': {'key': 'placementGroupId', 'type': 'str'}, + 'plan': {'key': 'plan', 'type': 'PlanProperties'}, + 'public_keys': {'key': 'publicKeys', 'type': '[PublicKeysProperties]'}, + 'platform_fault_domain': {'key': 'platformFaultDomain', 'type': 'str'}, + 'platform_update_domain': {'key': 'platformUpdateDomain', 'type': 'str'}, + 'provider': {'key': 'provider', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'resource_group_name': {'key': 'resourceGroupName', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + 'vm_id': {'key': 'vmId', 'type': 'str'}, + 'vm_scale_set_name': {'key': 'vmScaleSetName', 'type': 'str'}, + 'vm_size': {'key': 'vmSize', 'type': 'str'}, + 'zone': {'key': 'zone', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Compute, self).__init__(**kwargs) + self.az_environment = kwargs.get('az_environment', None) + self.custom_data = kwargs.get('custom_data', None) + self.location = kwargs.get('location', None) + self.name = kwargs.get('name', None) + self.offer = kwargs.get('offer', None) + self.os_type = kwargs.get('os_type', None) + self.placement_group_id = kwargs.get('placement_group_id', None) + self.plan = kwargs.get('plan', None) + self.public_keys = kwargs.get('public_keys', None) + self.platform_fault_domain = kwargs.get('platform_fault_domain', None) + self.platform_update_domain = kwargs.get('platform_update_domain', None) + self.provider = kwargs.get('provider', None) + self.publisher = kwargs.get('publisher', None) + self.resource_group_name = kwargs.get('resource_group_name', None) + self.sku = kwargs.get('sku', None) + self.subscription_id = kwargs.get('subscription_id', None) + self.tags = kwargs.get('tags', None) + self.version = kwargs.get('version', None) + self.vm_id = kwargs.get('vm_id', None) + self.vm_scale_set_name = kwargs.get('vm_scale_set_name', None) + self.vm_size = kwargs.get('vm_size', None) + self.zone = kwargs.get('zone', None) diff --git a/sdk/azure-imds/azure/imds/models/compute_py3.py b/sdk/azure-imds/azure/imds/models/compute_py3.py new file mode 100644 index 000000000000..c3602e25652f --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/compute_py3.py @@ -0,0 +1,117 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Compute(Model): + """Compute Metadata. + + :param az_environment: This is the name of the environment in which the VM + is running. + :type az_environment: str + :param custom_data: This is the base64 encoded custom data for the running + VM. + :type custom_data: str + :param location: This is the Azure Region in which the VM is running. + :type location: str + :param name: This is the name of the VM. + :type name: str + :param offer: This is the offer information for the VM image. This value + is only present for images deployed from the Azure Image Gallery. + :type offer: str + :param os_type: This value indicates the type of OS the VM is running, + either Linux or Windows. + :type os_type: str + :param placement_group_id: This is the placement group of your Virtual + Machine Scale Set. + :type placement_group_id: str + :param plan: This contains the data about the plan. + :type plan: ~azure.imds.models.PlanProperties + :param public_keys: This is information about the SSH certificate + :type public_keys: list[~azure.imds.models.PublicKeysProperties] + :param platform_fault_domain: This is the fault domain in which the VM. + :type platform_fault_domain: str + :param platform_update_domain: This is the update domain in which the VM. + :type platform_update_domain: str + :param provider: This is the provider of the VM. + :type provider: str + :param publisher: This is the publisher of the VM image. + :type publisher: str + :param resource_group_name: This is the resource group for the VM. + :type resource_group_name: str + :param sku: This is the specific SKU for the VM image. + :type sku: str + :param subscription_id: This is the Azure subscription for the VM. + :type subscription_id: str + :param tags: This is the list of tags for your VM. + :type tags: str + :param version: This is the version of the VM image. + :type version: str + :param vm_id: This is the unique identifier for the VM. + :type vm_id: str + :param vm_scale_set_name: This is the resource name of the VMSS. + :type vm_scale_set_name: str + :param vm_size: This is the size of the VM. + :type vm_size: str + :param zone: This is the availability zone of the VM. + :type zone: str + """ + + _attribute_map = { + 'az_environment': {'key': 'azEnvironment', 'type': 'str'}, + 'custom_data': {'key': 'customData', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'offer': {'key': 'offer', 'type': 'str'}, + 'os_type': {'key': 'osType', 'type': 'str'}, + 'placement_group_id': {'key': 'placementGroupId', 'type': 'str'}, + 'plan': {'key': 'plan', 'type': 'PlanProperties'}, + 'public_keys': {'key': 'publicKeys', 'type': '[PublicKeysProperties]'}, + 'platform_fault_domain': {'key': 'platformFaultDomain', 'type': 'str'}, + 'platform_update_domain': {'key': 'platformUpdateDomain', 'type': 'str'}, + 'provider': {'key': 'provider', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'resource_group_name': {'key': 'resourceGroupName', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + 'vm_id': {'key': 'vmId', 'type': 'str'}, + 'vm_scale_set_name': {'key': 'vmScaleSetName', 'type': 'str'}, + 'vm_size': {'key': 'vmSize', 'type': 'str'}, + 'zone': {'key': 'zone', 'type': 'str'}, + } + + def __init__(self, *, az_environment: str=None, custom_data: str=None, location: str=None, name: str=None, offer: str=None, os_type: str=None, placement_group_id: str=None, plan=None, public_keys=None, platform_fault_domain: str=None, platform_update_domain: str=None, provider: str=None, publisher: str=None, resource_group_name: str=None, sku: str=None, subscription_id: str=None, tags: str=None, version: str=None, vm_id: str=None, vm_scale_set_name: str=None, vm_size: str=None, zone: str=None, **kwargs) -> None: + super(Compute, self).__init__(**kwargs) + self.az_environment = az_environment + self.custom_data = custom_data + self.location = location + self.name = name + self.offer = offer + self.os_type = os_type + self.placement_group_id = placement_group_id + self.plan = plan + self.public_keys = public_keys + self.platform_fault_domain = platform_fault_domain + self.platform_update_domain = platform_update_domain + self.provider = provider + self.publisher = publisher + self.resource_group_name = resource_group_name + self.sku = sku + self.subscription_id = subscription_id + self.tags = tags + self.version = version + self.vm_id = vm_id + self.vm_scale_set_name = vm_scale_set_name + self.vm_size = vm_size + self.zone = zone diff --git a/sdk/azure-imds/azure/imds/models/error_response.py b/sdk/azure-imds/azure/imds/models/error_response.py new file mode 100644 index 000000000000..60321d55e746 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/error_response.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class ErrorResponse(Model): + """This is the response from an operation in the case an error occurs. + + :param error: Error message indicating why the operation failed. + :type error: str + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) diff --git a/sdk/azure-imds/azure/imds/models/error_response_py3.py b/sdk/azure-imds/azure/imds/models/error_response_py3.py new file mode 100644 index 000000000000..200a4ea62c2b --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/error_response_py3.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class ErrorResponse(Model): + """This is the response from an operation in the case an error occurs. + + :param error: Error message indicating why the operation failed. + :type error: str + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'str'}, + } + + def __init__(self, *, error: str=None, **kwargs) -> None: + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) diff --git a/sdk/azure-imds/azure/imds/models/identity_error_response.py b/sdk/azure-imds/azure/imds/models/identity_error_response.py new file mode 100644 index 000000000000..a72b99031920 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/identity_error_response.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class IdentityErrorResponse(Model): + """This is the response from an Identity operation in the case an error + occurs. + + :param error: Error code. Possible values include: 'invalid_request', + 'unauthorized_client', 'access_denied', 'unsupported_response_type', + 'invalid_scope', 'server_error', 'service_unavailable', 'bad_request', + 'forbidden', 'not_found', 'method_not_allowed', 'too_many_requests' + :type error: str or ~azure.imds.models.Error + :param error_description: Error message indicating why the operation + failed. + :type error_description: str + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'str'}, + 'error_description': {'key': 'error_description', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(IdentityErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + self.error_description = kwargs.get('error_description', None) + + +class IdentityErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'IdentityErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(IdentityErrorResponseException, self).__init__(deserialize, response, 'IdentityErrorResponse', *args) diff --git a/sdk/azure-imds/azure/imds/models/identity_error_response_py3.py b/sdk/azure-imds/azure/imds/models/identity_error_response_py3.py new file mode 100644 index 000000000000..ed78a7cbac24 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/identity_error_response_py3.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class IdentityErrorResponse(Model): + """This is the response from an Identity operation in the case an error + occurs. + + :param error: Error code. Possible values include: 'invalid_request', + 'unauthorized_client', 'access_denied', 'unsupported_response_type', + 'invalid_scope', 'server_error', 'service_unavailable', 'bad_request', + 'forbidden', 'not_found', 'method_not_allowed', 'too_many_requests' + :type error: str or ~azure.imds.models.Error + :param error_description: Error message indicating why the operation + failed. + :type error_description: str + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'str'}, + 'error_description': {'key': 'error_description', 'type': 'str'}, + } + + def __init__(self, *, error=None, error_description: str=None, **kwargs) -> None: + super(IdentityErrorResponse, self).__init__(**kwargs) + self.error = error + self.error_description = error_description + + +class IdentityErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'IdentityErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(IdentityErrorResponseException, self).__init__(deserialize, response, 'IdentityErrorResponse', *args) diff --git a/sdk/azure-imds/azure/imds/models/identity_info_response.py b/sdk/azure-imds/azure/imds/models/identity_info_response.py new file mode 100644 index 000000000000..19ec5a4183c9 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/identity_info_response.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class IdentityInfoResponse(Model): + """This is the response from the Identity_GetInfo operation. + + :param tenant_id: This is the AAD tenantId of the identity of the caller. + :type tenant_id: str + """ + + _attribute_map = { + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(IdentityInfoResponse, self).__init__(**kwargs) + self.tenant_id = kwargs.get('tenant_id', None) diff --git a/sdk/azure-imds/azure/imds/models/identity_info_response_py3.py b/sdk/azure-imds/azure/imds/models/identity_info_response_py3.py new file mode 100644 index 000000000000..dfd4630b9f91 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/identity_info_response_py3.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class IdentityInfoResponse(Model): + """This is the response from the Identity_GetInfo operation. + + :param tenant_id: This is the AAD tenantId of the identity of the caller. + :type tenant_id: str + """ + + _attribute_map = { + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__(self, *, tenant_id: str=None, **kwargs) -> None: + super(IdentityInfoResponse, self).__init__(**kwargs) + self.tenant_id = tenant_id diff --git a/sdk/azure-imds/azure/imds/models/identity_token_response.py b/sdk/azure-imds/azure/imds/models/identity_token_response.py new file mode 100644 index 000000000000..8b888379226c --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/identity_token_response.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class IdentityTokenResponse(Model): + """This is the response from the Identity_GetToken operation. + + :param access_token: This is the requested access token. The app can use + this token to authenticate to the sink resource. + :type access_token: str + :param expires_in: This is how long the access token is valid (in + seconds). + :type expires_in: str + :param expires_on: This is the time when the access token expires. The + date is represented as the number of seconds from 1970-01-01T0:0:0Z UTC + until the expiration time. This value is used to determine the lifetime of + cached tokens. + :type expires_on: str + :param ext_expires_in: This indicates the extended lifetime of the token + (in seconds). + :type ext_expires_in: str + :param not_before: This is the time when the access token becomes + effective. The date is represented as the number of seconds from + 1970-01-01T0:0:0Z UTC until the expiration time. + :type not_before: str + :param resource: This is the app ID URI of the sink resource. + :type resource: str + :param token_type: This indicates the token type value. + :type token_type: str + :param client_id: This is the client_id specified in the request, if any. + :type client_id: str + :param object_id: This is the object_id specified in the request, if any. + :type object_id: str + :param msi_res_id: This is the msi_res_id specified in the request, if + any. + :type msi_res_id: str + """ + + _attribute_map = { + 'access_token': {'key': 'access_token', 'type': 'str'}, + 'expires_in': {'key': 'expires_in', 'type': 'str'}, + 'expires_on': {'key': 'expires_on', 'type': 'str'}, + 'ext_expires_in': {'key': 'ext_expires_in', 'type': 'str'}, + 'not_before': {'key': 'not_before', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'token_type': {'key': 'token_type', 'type': 'str'}, + 'client_id': {'key': 'client_id', 'type': 'str'}, + 'object_id': {'key': 'object_id', 'type': 'str'}, + 'msi_res_id': {'key': 'msi_res_id', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(IdentityTokenResponse, self).__init__(**kwargs) + self.access_token = kwargs.get('access_token', None) + self.expires_in = kwargs.get('expires_in', None) + self.expires_on = kwargs.get('expires_on', None) + self.ext_expires_in = kwargs.get('ext_expires_in', None) + self.not_before = kwargs.get('not_before', None) + self.resource = kwargs.get('resource', None) + self.token_type = kwargs.get('token_type', None) + self.client_id = kwargs.get('client_id', None) + self.object_id = kwargs.get('object_id', None) + self.msi_res_id = kwargs.get('msi_res_id', None) diff --git a/sdk/azure-imds/azure/imds/models/identity_token_response_py3.py b/sdk/azure-imds/azure/imds/models/identity_token_response_py3.py new file mode 100644 index 000000000000..84d1f28bb946 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/identity_token_response_py3.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class IdentityTokenResponse(Model): + """This is the response from the Identity_GetToken operation. + + :param access_token: This is the requested access token. The app can use + this token to authenticate to the sink resource. + :type access_token: str + :param expires_in: This is how long the access token is valid (in + seconds). + :type expires_in: str + :param expires_on: This is the time when the access token expires. The + date is represented as the number of seconds from 1970-01-01T0:0:0Z UTC + until the expiration time. This value is used to determine the lifetime of + cached tokens. + :type expires_on: str + :param ext_expires_in: This indicates the extended lifetime of the token + (in seconds). + :type ext_expires_in: str + :param not_before: This is the time when the access token becomes + effective. The date is represented as the number of seconds from + 1970-01-01T0:0:0Z UTC until the expiration time. + :type not_before: str + :param resource: This is the app ID URI of the sink resource. + :type resource: str + :param token_type: This indicates the token type value. + :type token_type: str + :param client_id: This is the client_id specified in the request, if any. + :type client_id: str + :param object_id: This is the object_id specified in the request, if any. + :type object_id: str + :param msi_res_id: This is the msi_res_id specified in the request, if + any. + :type msi_res_id: str + """ + + _attribute_map = { + 'access_token': {'key': 'access_token', 'type': 'str'}, + 'expires_in': {'key': 'expires_in', 'type': 'str'}, + 'expires_on': {'key': 'expires_on', 'type': 'str'}, + 'ext_expires_in': {'key': 'ext_expires_in', 'type': 'str'}, + 'not_before': {'key': 'not_before', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'token_type': {'key': 'token_type', 'type': 'str'}, + 'client_id': {'key': 'client_id', 'type': 'str'}, + 'object_id': {'key': 'object_id', 'type': 'str'}, + 'msi_res_id': {'key': 'msi_res_id', 'type': 'str'}, + } + + def __init__(self, *, access_token: str=None, expires_in: str=None, expires_on: str=None, ext_expires_in: str=None, not_before: str=None, resource: str=None, token_type: str=None, client_id: str=None, object_id: str=None, msi_res_id: str=None, **kwargs) -> None: + super(IdentityTokenResponse, self).__init__(**kwargs) + self.access_token = access_token + self.expires_in = expires_in + self.expires_on = expires_on + self.ext_expires_in = ext_expires_in + self.not_before = not_before + self.resource = resource + self.token_type = token_type + self.client_id = client_id + self.object_id = object_id + self.msi_res_id = msi_res_id diff --git a/sdk/azure-imds/azure/imds/models/instance.py b/sdk/azure-imds/azure/imds/models/instance.py new file mode 100644 index 000000000000..cfcc8be3caf2 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/instance.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Instance(Model): + """This is the response from the Instance_GetMetadata operation. + + :param compute: Compute Metadata + :type compute: ~azure.imds.models.Compute + :param network: Network Metadata + :type network: ~azure.imds.models.Network + """ + + _attribute_map = { + 'compute': {'key': 'compute', 'type': 'Compute'}, + 'network': {'key': 'network', 'type': 'Network'}, + } + + def __init__(self, **kwargs): + super(Instance, self).__init__(**kwargs) + self.compute = kwargs.get('compute', None) + self.network = kwargs.get('network', None) diff --git a/sdk/azure-imds/azure/imds/models/instance_metadata_client_enums.py b/sdk/azure-imds/azure/imds/models/instance_metadata_client_enums.py new file mode 100644 index 000000000000..5d29f6f5ca7b --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/instance_metadata_client_enums.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum + + +class Error(str, Enum): + + invalid_request = "invalid_request" + unauthorized_client = "unauthorized_client" + access_denied = "access_denied" + unsupported_response_type = "unsupported_response_type" + invalid_scope = "invalid_scope" + server_error = "server_error" + service_unavailable = "service_unavailable" + bad_request = "bad_request" + forbidden = "forbidden" + not_found = "not_found" + method_not_allowed = "method_not_allowed" + too_many_requests = "too_many_requests" + + +class BypassCache(str, Enum): + + true = "true" diff --git a/sdk/azure-imds/azure/imds/models/instance_py3.py b/sdk/azure-imds/azure/imds/models/instance_py3.py new file mode 100644 index 000000000000..90776f6b6ad7 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/instance_py3.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Instance(Model): + """This is the response from the Instance_GetMetadata operation. + + :param compute: Compute Metadata + :type compute: ~azure.imds.models.Compute + :param network: Network Metadata + :type network: ~azure.imds.models.Network + """ + + _attribute_map = { + 'compute': {'key': 'compute', 'type': 'Compute'}, + 'network': {'key': 'network', 'type': 'Network'}, + } + + def __init__(self, *, compute=None, network=None, **kwargs) -> None: + super(Instance, self).__init__(**kwargs) + self.compute = compute + self.network = network diff --git a/sdk/azure-imds/azure/imds/models/ipv4_properties.py b/sdk/azure-imds/azure/imds/models/ipv4_properties.py new file mode 100644 index 000000000000..5a0837863cc3 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/ipv4_properties.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Ipv4Properties(Model): + """This contains the IPv4 properties. + + :param private_ip_address: This is the private IP address assigned to the + interface. + :type private_ip_address: str + :param public_ip_address: This is the public IP address assigned to the + interface. + :type public_ip_address: str + """ + + _attribute_map = { + 'private_ip_address': {'key': 'privateIpAddress', 'type': 'str'}, + 'public_ip_address': {'key': 'publicIpAddress', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Ipv4Properties, self).__init__(**kwargs) + self.private_ip_address = kwargs.get('private_ip_address', None) + self.public_ip_address = kwargs.get('public_ip_address', None) diff --git a/sdk/azure-imds/azure/imds/models/ipv4_properties_py3.py b/sdk/azure-imds/azure/imds/models/ipv4_properties_py3.py new file mode 100644 index 000000000000..a5710decf4eb --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/ipv4_properties_py3.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Ipv4Properties(Model): + """This contains the IPv4 properties. + + :param private_ip_address: This is the private IP address assigned to the + interface. + :type private_ip_address: str + :param public_ip_address: This is the public IP address assigned to the + interface. + :type public_ip_address: str + """ + + _attribute_map = { + 'private_ip_address': {'key': 'privateIpAddress', 'type': 'str'}, + 'public_ip_address': {'key': 'publicIpAddress', 'type': 'str'}, + } + + def __init__(self, *, private_ip_address: str=None, public_ip_address: str=None, **kwargs) -> None: + super(Ipv4Properties, self).__init__(**kwargs) + self.private_ip_address = private_ip_address + self.public_ip_address = public_ip_address diff --git a/sdk/azure-imds/azure/imds/models/ipv6_properties.py b/sdk/azure-imds/azure/imds/models/ipv6_properties.py new file mode 100644 index 000000000000..42e6e62f0a85 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/ipv6_properties.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Ipv6Properties(Model): + """This contains the IPv6 properties. + + :param private_ip_address: This is the private IPv6 address assigned to + the interface. + :type private_ip_address: str + """ + + _attribute_map = { + 'private_ip_address': {'key': 'privateIpAddress', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Ipv6Properties, self).__init__(**kwargs) + self.private_ip_address = kwargs.get('private_ip_address', None) diff --git a/sdk/azure-imds/azure/imds/models/ipv6_properties_py3.py b/sdk/azure-imds/azure/imds/models/ipv6_properties_py3.py new file mode 100644 index 000000000000..9bf332fec7a7 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/ipv6_properties_py3.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Ipv6Properties(Model): + """This contains the IPv6 properties. + + :param private_ip_address: This is the private IPv6 address assigned to + the interface. + :type private_ip_address: str + """ + + _attribute_map = { + 'private_ip_address': {'key': 'privateIpAddress', 'type': 'str'}, + } + + def __init__(self, *, private_ip_address: str=None, **kwargs) -> None: + super(Ipv6Properties, self).__init__(**kwargs) + self.private_ip_address = private_ip_address diff --git a/sdk/azure-imds/azure/imds/models/network.py b/sdk/azure-imds/azure/imds/models/network.py new file mode 100644 index 000000000000..4241f7a73e30 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/network.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Network(Model): + """Network Metadata. + + :param interface: This contains data about the network interface. + :type interface: list[~azure.imds.models.NetworkInterface] + """ + + _attribute_map = { + 'interface': {'key': 'interface', 'type': '[NetworkInterface]'}, + } + + def __init__(self, **kwargs): + super(Network, self).__init__(**kwargs) + self.interface = kwargs.get('interface', None) diff --git a/sdk/azure-imds/azure/imds/models/network_interface.py b/sdk/azure-imds/azure/imds/models/network_interface.py new file mode 100644 index 000000000000..52ce4ea3173e --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/network_interface.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class NetworkInterface(Model): + """This contains data about the network interface. + + :param ipv4: This contains the IPv4 address. + :type ipv4: ~azure.imds.models.NetworkInterfaceIpv4 + :param ipv6: This contains the IPv6 address. + :type ipv6: ~azure.imds.models.NetworkInterfaceIpv6 + :param mac_address: This is the MAC address of the interface. + :type mac_address: str + """ + + _attribute_map = { + 'ipv4': {'key': 'ipv4', 'type': 'NetworkInterfaceIpv4'}, + 'ipv6': {'key': 'ipv6', 'type': 'NetworkInterfaceIpv6'}, + 'mac_address': {'key': 'macAddress', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(NetworkInterface, self).__init__(**kwargs) + self.ipv4 = kwargs.get('ipv4', None) + self.ipv6 = kwargs.get('ipv6', None) + self.mac_address = kwargs.get('mac_address', None) diff --git a/sdk/azure-imds/azure/imds/models/network_interface_ipv4.py b/sdk/azure-imds/azure/imds/models/network_interface_ipv4.py new file mode 100644 index 000000000000..e206b86659f6 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/network_interface_ipv4.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class NetworkInterfaceIpv4(Model): + """This contains the IPv4 address. + + :param ip_address: This is the IP address + :type ip_address: list[~azure.imds.models.Ipv4Properties] + :param subnet: This is the subnet + :type subnet: list[~azure.imds.models.SubnetProperties] + """ + + _attribute_map = { + 'ip_address': {'key': 'ipAddress', 'type': '[Ipv4Properties]'}, + 'subnet': {'key': 'subnet', 'type': '[SubnetProperties]'}, + } + + def __init__(self, **kwargs): + super(NetworkInterfaceIpv4, self).__init__(**kwargs) + self.ip_address = kwargs.get('ip_address', None) + self.subnet = kwargs.get('subnet', None) diff --git a/sdk/azure-imds/azure/imds/models/network_interface_ipv4_py3.py b/sdk/azure-imds/azure/imds/models/network_interface_ipv4_py3.py new file mode 100644 index 000000000000..e5f96ef5a46f --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/network_interface_ipv4_py3.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class NetworkInterfaceIpv4(Model): + """This contains the IPv4 address. + + :param ip_address: This is the IP address + :type ip_address: list[~azure.imds.models.Ipv4Properties] + :param subnet: This is the subnet + :type subnet: list[~azure.imds.models.SubnetProperties] + """ + + _attribute_map = { + 'ip_address': {'key': 'ipAddress', 'type': '[Ipv4Properties]'}, + 'subnet': {'key': 'subnet', 'type': '[SubnetProperties]'}, + } + + def __init__(self, *, ip_address=None, subnet=None, **kwargs) -> None: + super(NetworkInterfaceIpv4, self).__init__(**kwargs) + self.ip_address = ip_address + self.subnet = subnet diff --git a/sdk/azure-imds/azure/imds/models/network_interface_ipv6.py b/sdk/azure-imds/azure/imds/models/network_interface_ipv6.py new file mode 100644 index 000000000000..3671cf2c4ac2 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/network_interface_ipv6.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class NetworkInterfaceIpv6(Model): + """This contains the IPv6 address. + + :param ip_address: This is the IP address + :type ip_address: list[~azure.imds.models.Ipv6Properties] + """ + + _attribute_map = { + 'ip_address': {'key': 'ipAddress', 'type': '[Ipv6Properties]'}, + } + + def __init__(self, **kwargs): + super(NetworkInterfaceIpv6, self).__init__(**kwargs) + self.ip_address = kwargs.get('ip_address', None) diff --git a/sdk/azure-imds/azure/imds/models/network_interface_ipv6_py3.py b/sdk/azure-imds/azure/imds/models/network_interface_ipv6_py3.py new file mode 100644 index 000000000000..0f24bc86d571 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/network_interface_ipv6_py3.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class NetworkInterfaceIpv6(Model): + """This contains the IPv6 address. + + :param ip_address: This is the IP address + :type ip_address: list[~azure.imds.models.Ipv6Properties] + """ + + _attribute_map = { + 'ip_address': {'key': 'ipAddress', 'type': '[Ipv6Properties]'}, + } + + def __init__(self, *, ip_address=None, **kwargs) -> None: + super(NetworkInterfaceIpv6, self).__init__(**kwargs) + self.ip_address = ip_address diff --git a/sdk/azure-imds/azure/imds/models/network_interface_py3.py b/sdk/azure-imds/azure/imds/models/network_interface_py3.py new file mode 100644 index 000000000000..ebe4a3c62342 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/network_interface_py3.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class NetworkInterface(Model): + """This contains data about the network interface. + + :param ipv4: This contains the IPv4 address. + :type ipv4: ~azure.imds.models.NetworkInterfaceIpv4 + :param ipv6: This contains the IPv6 address. + :type ipv6: ~azure.imds.models.NetworkInterfaceIpv6 + :param mac_address: This is the MAC address of the interface. + :type mac_address: str + """ + + _attribute_map = { + 'ipv4': {'key': 'ipv4', 'type': 'NetworkInterfaceIpv4'}, + 'ipv6': {'key': 'ipv6', 'type': 'NetworkInterfaceIpv6'}, + 'mac_address': {'key': 'macAddress', 'type': 'str'}, + } + + def __init__(self, *, ipv4=None, ipv6=None, mac_address: str=None, **kwargs) -> None: + super(NetworkInterface, self).__init__(**kwargs) + self.ipv4 = ipv4 + self.ipv6 = ipv6 + self.mac_address = mac_address diff --git a/sdk/azure-imds/azure/imds/models/network_py3.py b/sdk/azure-imds/azure/imds/models/network_py3.py new file mode 100644 index 000000000000..f64cb57a83ff --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/network_py3.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Network(Model): + """Network Metadata. + + :param interface: This contains data about the network interface. + :type interface: list[~azure.imds.models.NetworkInterface] + """ + + _attribute_map = { + 'interface': {'key': 'interface', 'type': '[NetworkInterface]'}, + } + + def __init__(self, *, interface=None, **kwargs) -> None: + super(Network, self).__init__(**kwargs) + self.interface = interface diff --git a/sdk/azure-imds/azure/imds/models/plan_properties.py b/sdk/azure-imds/azure/imds/models/plan_properties.py new file mode 100644 index 000000000000..a97228fd29cf --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/plan_properties.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class PlanProperties(Model): + """This contains the data about the plan. + + :param name: This is the Plan ID. + :type name: str + :param publisher: This is the publisher ID. + :type publisher: str + :param product: This is the product of the image from the Marketplace. + :type product: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PlanProperties, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.publisher = kwargs.get('publisher', None) + self.product = kwargs.get('product', None) diff --git a/sdk/azure-imds/azure/imds/models/plan_properties_py3.py b/sdk/azure-imds/azure/imds/models/plan_properties_py3.py new file mode 100644 index 000000000000..4b59ee1a7bf1 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/plan_properties_py3.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class PlanProperties(Model): + """This contains the data about the plan. + + :param name: This is the Plan ID. + :type name: str + :param publisher: This is the publisher ID. + :type publisher: str + :param product: This is the product of the image from the Marketplace. + :type product: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'product': {'key': 'product', 'type': 'str'}, + } + + def __init__(self, *, name: str=None, publisher: str=None, product: str=None, **kwargs) -> None: + super(PlanProperties, self).__init__(**kwargs) + self.name = name + self.publisher = publisher + self.product = product diff --git a/sdk/azure-imds/azure/imds/models/public_keys_properties.py b/sdk/azure-imds/azure/imds/models/public_keys_properties.py new file mode 100644 index 000000000000..47f6293cb02a --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/public_keys_properties.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class PublicKeysProperties(Model): + """This contains the data about the public key. + + :param path: This specifies the full path on the VM where the SSH public + key is stored. + :type path: str + :param key_data: This is the SSH public key certificate used to + authenticate with the VM. + :type key_data: str + """ + + _attribute_map = { + 'path': {'key': 'path', 'type': 'str'}, + 'key_data': {'key': 'keyData', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(PublicKeysProperties, self).__init__(**kwargs) + self.path = kwargs.get('path', None) + self.key_data = kwargs.get('key_data', None) diff --git a/sdk/azure-imds/azure/imds/models/public_keys_properties_py3.py b/sdk/azure-imds/azure/imds/models/public_keys_properties_py3.py new file mode 100644 index 000000000000..608cc4d22441 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/public_keys_properties_py3.py @@ -0,0 +1,34 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class PublicKeysProperties(Model): + """This contains the data about the public key. + + :param path: This specifies the full path on the VM where the SSH public + key is stored. + :type path: str + :param key_data: This is the SSH public key certificate used to + authenticate with the VM. + :type key_data: str + """ + + _attribute_map = { + 'path': {'key': 'path', 'type': 'str'}, + 'key_data': {'key': 'keyData', 'type': 'str'}, + } + + def __init__(self, *, path: str=None, key_data: str=None, **kwargs) -> None: + super(PublicKeysProperties, self).__init__(**kwargs) + self.path = path + self.key_data = key_data diff --git a/sdk/azure-imds/azure/imds/models/subnet_properties.py b/sdk/azure-imds/azure/imds/models/subnet_properties.py new file mode 100644 index 000000000000..f1a5d4746f07 --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/subnet_properties.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class SubnetProperties(Model): + """This contains the properties of the subnet. + + :param address: This is the address range of the subnet. + :type address: str + :param prefix: This is the prefix of the subnet. + :type prefix: str + """ + + _attribute_map = { + 'address': {'key': 'address', 'type': 'str'}, + 'prefix': {'key': 'prefix', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(SubnetProperties, self).__init__(**kwargs) + self.address = kwargs.get('address', None) + self.prefix = kwargs.get('prefix', None) diff --git a/sdk/azure-imds/azure/imds/models/subnet_properties_py3.py b/sdk/azure-imds/azure/imds/models/subnet_properties_py3.py new file mode 100644 index 000000000000..516e0160a37d --- /dev/null +++ b/sdk/azure-imds/azure/imds/models/subnet_properties_py3.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class SubnetProperties(Model): + """This contains the properties of the subnet. + + :param address: This is the address range of the subnet. + :type address: str + :param prefix: This is the prefix of the subnet. + :type prefix: str + """ + + _attribute_map = { + 'address': {'key': 'address', 'type': 'str'}, + 'prefix': {'key': 'prefix', 'type': 'str'}, + } + + def __init__(self, *, address: str=None, prefix: str=None, **kwargs) -> None: + super(SubnetProperties, self).__init__(**kwargs) + self.address = address + self.prefix = prefix diff --git a/sdk/azure-imds/azure/imds/operations/__init__.py b/sdk/azure-imds/azure/imds/operations/__init__.py new file mode 100644 index 000000000000..0523f162ec70 --- /dev/null +++ b/sdk/azure-imds/azure/imds/operations/__init__.py @@ -0,0 +1,20 @@ +# 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 .instances_operations import InstancesOperations +from .attested_operations import AttestedOperations +from .identity_operations import IdentityOperations + +__all__ = [ + 'InstancesOperations', + 'AttestedOperations', + 'IdentityOperations', +] diff --git a/sdk/azure-imds/azure/imds/operations/attested_operations.py b/sdk/azure-imds/azure/imds/operations/attested_operations.py new file mode 100644 index 000000000000..b1210e16be95 --- /dev/null +++ b/sdk/azure-imds/azure/imds/operations/attested_operations.py @@ -0,0 +1,96 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class AttestedOperations(object): + """AttestedOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: This is the API version to use. Constant value: "2019-02-01". + :ivar metadata: This must be set to 'true'. Constant value: "true". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-02-01" + self.metadata = "true" + + self.config = config + + def get_document( + self, nonce=None, custom_headers=None, raw=False, **operation_config): + """Get Attested Data for the Virtual Machine. + + :param nonce: This is a string of up to 32 random alphanumeric + characters. + :type nonce: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: AttestedData or ClientRawResponse if raw=true + :rtype: ~azure.imds.models.AttestedData or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_document.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if nonce is not None: + query_parameters['nonce'] = self._serialize.query("nonce", nonce, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + header_parameters['Metadata'] = self._serialize.header("self.metadata", self.metadata, 'str') + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('AttestedData', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_document.metadata = {'url': '/attested/document'} diff --git a/sdk/azure-imds/azure/imds/operations/identity_operations.py b/sdk/azure-imds/azure/imds/operations/identity_operations.py new file mode 100644 index 000000000000..f6b0e74e81ed --- /dev/null +++ b/sdk/azure-imds/azure/imds/operations/identity_operations.py @@ -0,0 +1,178 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class IdentityOperations(object): + """IdentityOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar metadata: This must be set to 'true'. Constant value: "true". + :ivar api_version: This is the API version to use. Constant value: "2019-02-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.metadata = "true" + self.api_version = "2019-02-01" + + self.config = config + + def get_token( + self, resource, client_id=None, object_id=None, msi_res_id=None, authority=None, bypass_cache=None, custom_headers=None, raw=False, **operation_config): + """Get a Token from Azure AD. + + :param resource: This is the urlencoded identifier URI of the sink + resource for the requested Azure AD token. The resulting token + contains the corresponding aud for this resource. + :type resource: str + :param client_id: This identifies, by Azure AD client id, a specific + explicit identity to use when authenticating to Azure AD. Mutually + exclusive with object_id and msi_res_id. + :type client_id: str + :param object_id: This identifies, by Azure AD object id, a specific + explicit identity to use when authenticating to Azure AD. Mutually + exclusive with client_id and msi_res_id. + :type object_id: str + :param msi_res_id: This identifies, by urlencoded ARM resource id, a + specific explicit identity to use when authenticating to Azure AD. + Mutually exclusive with client_id and object_id. + :type msi_res_id: str + :param authority: This indicates the authority to request AAD tokens + from. Defaults to the known authority of the identity to be used. + :type authority: str + :param bypass_cache: If provided, the value must be 'true'. This + indicates to the server that the token must be retrieved from Azure AD + and cannot be retrieved from an internal cache. Possible values + include: 'true' + :type bypass_cache: str or ~azure.imds.models.BypassCache + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: IdentityTokenResponse or ClientRawResponse if raw=true + :rtype: ~azure.imds.models.IdentityTokenResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`IdentityErrorResponseException` + """ + # Construct URL + url = self.get_token.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['resource'] = self._serialize.query("resource", resource, 'str') + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if client_id is not None: + query_parameters['client_id'] = self._serialize.query("client_id", client_id, 'str') + if object_id is not None: + query_parameters['object_id'] = self._serialize.query("object_id", object_id, 'str') + if msi_res_id is not None: + query_parameters['msi_res_id'] = self._serialize.query("msi_res_id", msi_res_id, 'str') + if authority is not None: + query_parameters['authority'] = self._serialize.query("authority", authority, 'str') + if bypass_cache is not None: + query_parameters['bypass_cache'] = self._serialize.query("bypass_cache", bypass_cache, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + header_parameters['Metadata'] = self._serialize.header("self.metadata", self.metadata, 'str') + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.IdentityErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('IdentityTokenResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_token.metadata = {'url': '/identity/oauth2/token'} + + def get_info( + self, custom_headers=None, raw=False, **operation_config): + """Get information about AAD Metadata. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: IdentityInfoResponse or ClientRawResponse if raw=true + :rtype: ~azure.imds.models.IdentityInfoResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`IdentityErrorResponseException` + """ + # Construct URL + url = self.get_info.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + header_parameters['Metadata'] = self._serialize.header("self.metadata", self.metadata, 'str') + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.IdentityErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('IdentityInfoResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_info.metadata = {'url': '/identity/info'} diff --git a/sdk/azure-imds/azure/imds/operations/instances_operations.py b/sdk/azure-imds/azure/imds/operations/instances_operations.py new file mode 100644 index 000000000000..c4f9781a23fc --- /dev/null +++ b/sdk/azure-imds/azure/imds/operations/instances_operations.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class InstancesOperations(object): + """InstancesOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: This is the API version to use. Constant value: "2019-02-01". + :ivar metadata: This must be set to 'true'. Constant value: "true". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-02-01" + self.metadata = "true" + + self.config = config + + def get_metadata( + self, custom_headers=None, raw=False, **operation_config): + """Get Instance Metadata for the Virtual Machine. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Instance or ClientRawResponse if raw=true + :rtype: ~azure.imds.models.Instance or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_metadata.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + header_parameters['Metadata'] = self._serialize.header("self.metadata", self.metadata, 'str') + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('Instance', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_metadata.metadata = {'url': '/instance'} diff --git a/sdk/azure-imds/azure/imds/version.py b/sdk/azure-imds/azure/imds/version.py new file mode 100644 index 000000000000..e0ec669828cb --- /dev/null +++ b/sdk/azure-imds/azure/imds/version.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" +