code
stringlengths 501
4.91M
| package
stringlengths 2
88
| path
stringlengths 11
291
| filename
stringlengths 4
197
| parsed_code
stringlengths 0
4.91M
| quality_prob
float64 0
0.99
| learning_prob
float64 0.02
1
|
---|---|---|---|---|---|---|
import msrest.serialization
class AsyncOperationStatus(msrest.serialization.Model):
"""The async operation status.
:param subscription_id: Subscription ID that the resource belongs to.
:type subscription_id: str
:param id: The GET resource path for the operation.
:type id: str
:param name: The operation ID.
:type name: str
:param status: The status of the operation. Possible values include: "Succeeded", "Pending",
"Failed".
:type status: str or ~$(python-base-namespace).v2019_01_01_preview.models.StatusType
:param start_time: Start time of the async operation.
:type start_time: str
:param end_time: End time of the async operation.
:type end_time: str
:param error: Error response if async operation failed.
:type error: ~$(python-base-namespace).v2019_01_01_preview.models.AsyncOperationStatusError
:param billing_config: The billing configuration for the tenant.
:type billing_config: ~$(python-base-
namespace).v2019_01_01_preview.models.B2CTenantResourcePropertiesBillingConfig
:param tenant_id: An identifier of the B2C tenant.
:type tenant_id: str
"""
_attribute_map = {
'subscription_id': {'key': 'subscriptionId', 'type': 'str'},
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'status': {'key': 'status', 'type': 'str'},
'start_time': {'key': 'startTime', 'type': 'str'},
'end_time': {'key': 'endTime', 'type': 'str'},
'error': {'key': 'error', 'type': 'AsyncOperationStatusError'},
'billing_config': {'key': 'properties.billingConfig', 'type': 'B2CTenantResourcePropertiesBillingConfig'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(AsyncOperationStatus, self).__init__(**kwargs)
self.subscription_id = kwargs.get('subscription_id', None)
self.id = kwargs.get('id', None)
self.name = kwargs.get('name', None)
self.status = kwargs.get('status', None)
self.start_time = kwargs.get('start_time', None)
self.end_time = kwargs.get('end_time', None)
self.error = kwargs.get('error', None)
self.billing_config = kwargs.get('billing_config', None)
self.tenant_id = kwargs.get('tenant_id', None)
class AsyncOperationStatusError(msrest.serialization.Model):
"""Error response if async operation failed.
:param code: Error code.
:type code: str
:param message: Error message.
:type message: str
"""
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(AsyncOperationStatusError, self).__init__(**kwargs)
self.code = kwargs.get('code', None)
self.message = kwargs.get('message', None)
class B2CResourceSKU(msrest.serialization.Model):
"""SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C billing at `aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
Variables are only populated by the server, and will be ignored when sending a request.
:param name: The name of the SKU for the tenant. Possible values include: "Standard",
"PremiumP1", "PremiumP2".
:type name: str or ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKUName
:ivar tier: The tier of the tenant. Default value: "A0".
:vartype tier: str
"""
_validation = {
'tier': {'constant': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'tier': {'key': 'tier', 'type': 'str'},
}
tier = "A0"
def __init__(
self,
**kwargs
):
super(B2CResourceSKU, self).__init__(**kwargs)
self.name = kwargs.get('name', None)
class B2CTenantResource(msrest.serialization.Model):
"""B2CTenantResource.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar type: The type of the B2C tenant resource. Default value:
"Microsoft.AzureActiveDirectory/b2cDirectories".
:vartype type: str
:param sku: Required. SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C
billing at `aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
:type sku: ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKU
:ivar id: An identifier that represents the B2C tenant resource.
:vartype id: str
:ivar name: The name of the B2C tenant resource.
:vartype name: str
:param location: Required. The location in which the resource is hosted and data resides. Refer
to `this documentation <https://aka.ms/B2CDataResidency>`_ to see valid data residency
locations. Please choose one of 'United States', 'Europe', and 'Asia Pacific'.
:type location: str
:param tags: A set of tags. Resource Tags.
:type tags: dict[str, str]
:param billing_config: The billing configuration for the tenant.
:type billing_config: ~$(python-base-
namespace).v2019_01_01_preview.models.B2CTenantResourcePropertiesBillingConfig
:param tenant_id: An identifier of the B2C tenant.
:type tenant_id: str
"""
_validation = {
'type': {'readonly': True, 'constant': True},
'sku': {'required': True},
'id': {'readonly': True},
'name': {'readonly': True},
'location': {'required': True},
}
_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'sku': {'key': 'sku', 'type': 'B2CResourceSKU'},
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'location': {'key': 'location', 'type': 'str'},
'tags': {'key': 'tags', 'type': '{str}'},
'billing_config': {'key': 'properties.billingConfig', 'type': 'B2CTenantResourcePropertiesBillingConfig'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
type = "Microsoft.AzureActiveDirectory/b2cDirectories"
def __init__(
self,
**kwargs
):
super(B2CTenantResource, self).__init__(**kwargs)
self.type = None
self.sku = kwargs['sku']
self.id = None
self.name = None
self.location = kwargs['location']
self.tags = kwargs.get('tags', None)
self.billing_config = kwargs.get('billing_config', None)
self.tenant_id = kwargs.get('tenant_id', None)
class B2CTenantResourceList(msrest.serialization.Model):
"""The collection of Azure AD B2C tenant resources.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of guest usages resources.
:vartype value: list[~$(python-base-namespace).v2019_01_01_preview.models.B2CTenantResource]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[B2CTenantResource]'},
}
def __init__(
self,
**kwargs
):
super(B2CTenantResourceList, self).__init__(**kwargs)
self.value = None
class B2CTenantResourcePropertiesBillingConfig(msrest.serialization.Model):
"""The billing configuration for the tenant.
Variables are only populated by the server, and will be ignored when sending a request.
:param billing_type: The type of billing. Will be MAU for all new customers. If 'Auths', it can
be updated to 'MAU'. Cannot be changed if value is 'MAU'. Learn more about Azure AD B2C billing
at `aka.ms/b2cBilling <https://aka.ms/b2cbilling>`_. Possible values include: "MAU", "Auths".
:type billing_type: str or ~$(python-base-namespace).v2019_01_01_preview.models.BillingType
:ivar effective_start_date_utc: The data from which the billing type took effect.
:vartype effective_start_date_utc: str
"""
_validation = {
'effective_start_date_utc': {'readonly': True},
}
_attribute_map = {
'billing_type': {'key': 'billingType', 'type': 'str'},
'effective_start_date_utc': {'key': 'effectiveStartDateUtc', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(B2CTenantResourcePropertiesBillingConfig, self).__init__(**kwargs)
self.billing_type = kwargs.get('billing_type', None)
self.effective_start_date_utc = None
class B2CTenantUpdateRequest(msrest.serialization.Model):
"""The request body to update the Azure AD B2C tenant resource.
:param sku: SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C billing at
`aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
:type sku: ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKU
:param tags: A set of tags. Resource Tags.
:type tags: dict[str, str]
:param billing_config: The billing configuration for the tenant.
:type billing_config: ~$(python-base-
namespace).v2019_01_01_preview.models.B2CTenantResourcePropertiesBillingConfig
:param tenant_id: An identifier of the B2C tenant.
:type tenant_id: str
"""
_attribute_map = {
'sku': {'key': 'sku', 'type': 'B2CResourceSKU'},
'tags': {'key': 'tags', 'type': '{str}'},
'billing_config': {'key': 'properties.billingConfig', 'type': 'B2CTenantResourcePropertiesBillingConfig'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(B2CTenantUpdateRequest, self).__init__(**kwargs)
self.sku = kwargs.get('sku', None)
self.tags = kwargs.get('tags', None)
self.billing_config = kwargs.get('billing_config', None)
self.tenant_id = kwargs.get('tenant_id', None)
class CheckNameAvailabilityRequestBody(msrest.serialization.Model):
"""The information required to check the availability of the name for the tenant.
All required parameters must be populated in order to send to Azure.
:param name: Required. The domain name to check for availability.
:type name: str
:param country_code: Required. Country code of Azure tenant (e.g. 'US'). Refer to
`aka.ms/B2CDataResidency <https://aka.ms/B2CDataResidency>`_ to see valid country codes and
corresponding data residency locations. If you do not see a country code in an valid data
residency location, choose one from the list.
:type country_code: str
"""
_validation = {
'name': {'required': True},
'country_code': {'required': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'country_code': {'key': 'countryCode', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(CheckNameAvailabilityRequestBody, self).__init__(**kwargs)
self.name = kwargs['name']
self.country_code = kwargs['country_code']
class CreateTenantRequestBody(msrest.serialization.Model):
"""The information needed to create the Azure AD B2C tenant and corresponding Azure resource, which is used for billing purposes.
All required parameters must be populated in order to send to Azure.
:param location: Required. The location in which the resource is hosted and data resides. Refer
to `this documentation <https://aka.ms/B2CDataResidency>`_ to see valid data residency
locations. Please choose one of 'United States', 'Europe', and 'Asia Pacific'.
:type location: str
:param properties: Required.
:type properties: ~$(python-base-
namespace).v2019_01_01_preview.models.CreateTenantRequestBodyProperties
:param sku: Required. SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C
billing at `aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
:type sku: ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKU
:param tags: A set of tags. Resource Tags.
:type tags: dict[str, str]
"""
_validation = {
'location': {'required': True},
'properties': {'required': True},
'sku': {'required': True},
}
_attribute_map = {
'location': {'key': 'location', 'type': 'str'},
'properties': {'key': 'properties', 'type': 'CreateTenantRequestBodyProperties'},
'sku': {'key': 'sku', 'type': 'B2CResourceSKU'},
'tags': {'key': 'tags', 'type': '{str}'},
}
def __init__(
self,
**kwargs
):
super(CreateTenantRequestBody, self).__init__(**kwargs)
self.location = kwargs['location']
self.properties = kwargs['properties']
self.sku = kwargs['sku']
self.tags = kwargs.get('tags', None)
class CreateTenantRequestBodyProperties(msrest.serialization.Model):
"""CreateTenantRequestBodyProperties.
:param display_name: The display name of the B2C tenant.
:type display_name: str
:param country_code: Country code of Azure tenant (e.g. 'US'). Refer to
`aka.ms/B2CDataResidency <https://aka.ms/B2CDataResidency>`_ to see valid country codes and
corresponding data residency locations. If you do not see a country code in an valid data
residency location, choose one from the list.
:type country_code: str
"""
_attribute_map = {
'display_name': {'key': 'createTenantProperties.displayName', 'type': 'str'},
'country_code': {'key': 'createTenantProperties.countryCode', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(CreateTenantRequestBodyProperties, self).__init__(**kwargs)
self.display_name = kwargs.get('display_name', None)
self.country_code = kwargs.get('country_code', None)
class ErrorAdditionalInfo(msrest.serialization.Model):
"""The resource management error additional info.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar type: The additional info type.
:vartype type: str
:ivar info: The additional info.
:vartype info: object
"""
_validation = {
'type': {'readonly': True},
'info': {'readonly': True},
}
_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'info': {'key': 'info', 'type': 'object'},
}
def __init__(
self,
**kwargs
):
super(ErrorAdditionalInfo, self).__init__(**kwargs)
self.type = None
self.info = None
class ErrorResponse(msrest.serialization.Model):
"""Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: The error code.
:vartype code: str
:ivar message: The error message.
:vartype message: str
:ivar target: The error target.
:vartype target: str
:ivar details: The error details.
:vartype details: list[~$(python-base-namespace).v2019_01_01_preview.models.ErrorResponse]
:ivar additional_info: The error additional info.
:vartype additional_info: list[~$(python-base-
namespace).v2019_01_01_preview.models.ErrorAdditionalInfo]
"""
_validation = {
'code': {'readonly': True},
'message': {'readonly': True},
'target': {'readonly': True},
'details': {'readonly': True},
'additional_info': {'readonly': True},
}
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
'target': {'key': 'target', 'type': 'str'},
'details': {'key': 'details', 'type': '[ErrorResponse]'},
'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'},
}
def __init__(
self,
**kwargs
):
super(ErrorResponse, self).__init__(**kwargs)
self.code = None
self.message = None
self.target = None
self.details = None
self.additional_info = None
class NameAvailabilityResponse(msrest.serialization.Model):
"""Response of the CheckNameAvailability operation.
:param message: Description of the reason if name is not available.
:type message: str
:param name_available: True if the name is available and can be used to create a new tenant.
Otherwise false.
:type name_available: bool
:param reason: Describes the reason for the 'nameAvailable' value. Possible values include:
"AlreadyExists", "Invalid".
:type reason: str or ~$(python-base-
namespace).v2019_01_01_preview.models.NameAvailabilityReasonType
"""
_attribute_map = {
'message': {'key': 'message', 'type': 'str'},
'name_available': {'key': 'nameAvailable', 'type': 'bool'},
'reason': {'key': 'reason', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(NameAvailabilityResponse, self).__init__(**kwargs)
self.message = kwargs.get('message', None)
self.name_available = kwargs.get('name_available', None)
self.reason = kwargs.get('reason', None)
class Operation(msrest.serialization.Model):
"""Microsoft.AzureActiveDirectory REST API operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Operation name: {provider}/{resource}/{operation}.
:vartype name: str
:param display: The object that represents the operation.
:type display: ~$(python-base-namespace).v2019_01_01_preview.models.OperationDisplay
"""
_validation = {
'name': {'readonly': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'display': {'key': 'display', 'type': 'OperationDisplay'},
}
def __init__(
self,
**kwargs
):
super(Operation, self).__init__(**kwargs)
self.name = None
self.display = kwargs.get('display', None)
class OperationDisplay(msrest.serialization.Model):
"""The object that represents the operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar provider: Service provider: Microsoft.AzureActiveDirectory.
:vartype provider: str
:ivar resource: Resource on which the operation is performed: GuestUsages, etc.
:vartype resource: str
:ivar operation: Operation type: Read, write, delete, etc.
:vartype operation: str
:param description: Friendly name of the operation.
:type description: str
"""
_validation = {
'provider': {'readonly': True},
'resource': {'readonly': True},
'operation': {'readonly': True},
}
_attribute_map = {
'provider': {'key': 'provider', 'type': 'str'},
'resource': {'key': 'resource', 'type': 'str'},
'operation': {'key': 'operation', 'type': 'str'},
'description': {'key': 'description', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(OperationDisplay, self).__init__(**kwargs)
self.provider = None
self.resource = None
self.operation = None
self.description = kwargs.get('description', None)
class OperationListResult(msrest.serialization.Model):
"""Result of listing operations for the resourceProvider.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of cpim service operations supported by the Microsoft.AzureActiveDirectory
resource provider.
:vartype value: list[~$(python-base-namespace).v2019_01_01_preview.models.Operation]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[Operation]'},
}
def __init__(
self,
**kwargs
):
super(OperationListResult, self).__init__(**kwargs)
self.value = None
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2019_01_01_preview/models/_models.py
|
_models.py
|
import msrest.serialization
class AsyncOperationStatus(msrest.serialization.Model):
"""The async operation status.
:param subscription_id: Subscription ID that the resource belongs to.
:type subscription_id: str
:param id: The GET resource path for the operation.
:type id: str
:param name: The operation ID.
:type name: str
:param status: The status of the operation. Possible values include: "Succeeded", "Pending",
"Failed".
:type status: str or ~$(python-base-namespace).v2019_01_01_preview.models.StatusType
:param start_time: Start time of the async operation.
:type start_time: str
:param end_time: End time of the async operation.
:type end_time: str
:param error: Error response if async operation failed.
:type error: ~$(python-base-namespace).v2019_01_01_preview.models.AsyncOperationStatusError
:param billing_config: The billing configuration for the tenant.
:type billing_config: ~$(python-base-
namespace).v2019_01_01_preview.models.B2CTenantResourcePropertiesBillingConfig
:param tenant_id: An identifier of the B2C tenant.
:type tenant_id: str
"""
_attribute_map = {
'subscription_id': {'key': 'subscriptionId', 'type': 'str'},
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'status': {'key': 'status', 'type': 'str'},
'start_time': {'key': 'startTime', 'type': 'str'},
'end_time': {'key': 'endTime', 'type': 'str'},
'error': {'key': 'error', 'type': 'AsyncOperationStatusError'},
'billing_config': {'key': 'properties.billingConfig', 'type': 'B2CTenantResourcePropertiesBillingConfig'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(AsyncOperationStatus, self).__init__(**kwargs)
self.subscription_id = kwargs.get('subscription_id', None)
self.id = kwargs.get('id', None)
self.name = kwargs.get('name', None)
self.status = kwargs.get('status', None)
self.start_time = kwargs.get('start_time', None)
self.end_time = kwargs.get('end_time', None)
self.error = kwargs.get('error', None)
self.billing_config = kwargs.get('billing_config', None)
self.tenant_id = kwargs.get('tenant_id', None)
class AsyncOperationStatusError(msrest.serialization.Model):
"""Error response if async operation failed.
:param code: Error code.
:type code: str
:param message: Error message.
:type message: str
"""
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(AsyncOperationStatusError, self).__init__(**kwargs)
self.code = kwargs.get('code', None)
self.message = kwargs.get('message', None)
class B2CResourceSKU(msrest.serialization.Model):
"""SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C billing at `aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
Variables are only populated by the server, and will be ignored when sending a request.
:param name: The name of the SKU for the tenant. Possible values include: "Standard",
"PremiumP1", "PremiumP2".
:type name: str or ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKUName
:ivar tier: The tier of the tenant. Default value: "A0".
:vartype tier: str
"""
_validation = {
'tier': {'constant': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'tier': {'key': 'tier', 'type': 'str'},
}
tier = "A0"
def __init__(
self,
**kwargs
):
super(B2CResourceSKU, self).__init__(**kwargs)
self.name = kwargs.get('name', None)
class B2CTenantResource(msrest.serialization.Model):
"""B2CTenantResource.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar type: The type of the B2C tenant resource. Default value:
"Microsoft.AzureActiveDirectory/b2cDirectories".
:vartype type: str
:param sku: Required. SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C
billing at `aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
:type sku: ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKU
:ivar id: An identifier that represents the B2C tenant resource.
:vartype id: str
:ivar name: The name of the B2C tenant resource.
:vartype name: str
:param location: Required. The location in which the resource is hosted and data resides. Refer
to `this documentation <https://aka.ms/B2CDataResidency>`_ to see valid data residency
locations. Please choose one of 'United States', 'Europe', and 'Asia Pacific'.
:type location: str
:param tags: A set of tags. Resource Tags.
:type tags: dict[str, str]
:param billing_config: The billing configuration for the tenant.
:type billing_config: ~$(python-base-
namespace).v2019_01_01_preview.models.B2CTenantResourcePropertiesBillingConfig
:param tenant_id: An identifier of the B2C tenant.
:type tenant_id: str
"""
_validation = {
'type': {'readonly': True, 'constant': True},
'sku': {'required': True},
'id': {'readonly': True},
'name': {'readonly': True},
'location': {'required': True},
}
_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'sku': {'key': 'sku', 'type': 'B2CResourceSKU'},
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'location': {'key': 'location', 'type': 'str'},
'tags': {'key': 'tags', 'type': '{str}'},
'billing_config': {'key': 'properties.billingConfig', 'type': 'B2CTenantResourcePropertiesBillingConfig'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
type = "Microsoft.AzureActiveDirectory/b2cDirectories"
def __init__(
self,
**kwargs
):
super(B2CTenantResource, self).__init__(**kwargs)
self.type = None
self.sku = kwargs['sku']
self.id = None
self.name = None
self.location = kwargs['location']
self.tags = kwargs.get('tags', None)
self.billing_config = kwargs.get('billing_config', None)
self.tenant_id = kwargs.get('tenant_id', None)
class B2CTenantResourceList(msrest.serialization.Model):
"""The collection of Azure AD B2C tenant resources.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of guest usages resources.
:vartype value: list[~$(python-base-namespace).v2019_01_01_preview.models.B2CTenantResource]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[B2CTenantResource]'},
}
def __init__(
self,
**kwargs
):
super(B2CTenantResourceList, self).__init__(**kwargs)
self.value = None
class B2CTenantResourcePropertiesBillingConfig(msrest.serialization.Model):
"""The billing configuration for the tenant.
Variables are only populated by the server, and will be ignored when sending a request.
:param billing_type: The type of billing. Will be MAU for all new customers. If 'Auths', it can
be updated to 'MAU'. Cannot be changed if value is 'MAU'. Learn more about Azure AD B2C billing
at `aka.ms/b2cBilling <https://aka.ms/b2cbilling>`_. Possible values include: "MAU", "Auths".
:type billing_type: str or ~$(python-base-namespace).v2019_01_01_preview.models.BillingType
:ivar effective_start_date_utc: The data from which the billing type took effect.
:vartype effective_start_date_utc: str
"""
_validation = {
'effective_start_date_utc': {'readonly': True},
}
_attribute_map = {
'billing_type': {'key': 'billingType', 'type': 'str'},
'effective_start_date_utc': {'key': 'effectiveStartDateUtc', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(B2CTenantResourcePropertiesBillingConfig, self).__init__(**kwargs)
self.billing_type = kwargs.get('billing_type', None)
self.effective_start_date_utc = None
class B2CTenantUpdateRequest(msrest.serialization.Model):
"""The request body to update the Azure AD B2C tenant resource.
:param sku: SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C billing at
`aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
:type sku: ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKU
:param tags: A set of tags. Resource Tags.
:type tags: dict[str, str]
:param billing_config: The billing configuration for the tenant.
:type billing_config: ~$(python-base-
namespace).v2019_01_01_preview.models.B2CTenantResourcePropertiesBillingConfig
:param tenant_id: An identifier of the B2C tenant.
:type tenant_id: str
"""
_attribute_map = {
'sku': {'key': 'sku', 'type': 'B2CResourceSKU'},
'tags': {'key': 'tags', 'type': '{str}'},
'billing_config': {'key': 'properties.billingConfig', 'type': 'B2CTenantResourcePropertiesBillingConfig'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(B2CTenantUpdateRequest, self).__init__(**kwargs)
self.sku = kwargs.get('sku', None)
self.tags = kwargs.get('tags', None)
self.billing_config = kwargs.get('billing_config', None)
self.tenant_id = kwargs.get('tenant_id', None)
class CheckNameAvailabilityRequestBody(msrest.serialization.Model):
"""The information required to check the availability of the name for the tenant.
All required parameters must be populated in order to send to Azure.
:param name: Required. The domain name to check for availability.
:type name: str
:param country_code: Required. Country code of Azure tenant (e.g. 'US'). Refer to
`aka.ms/B2CDataResidency <https://aka.ms/B2CDataResidency>`_ to see valid country codes and
corresponding data residency locations. If you do not see a country code in an valid data
residency location, choose one from the list.
:type country_code: str
"""
_validation = {
'name': {'required': True},
'country_code': {'required': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'country_code': {'key': 'countryCode', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(CheckNameAvailabilityRequestBody, self).__init__(**kwargs)
self.name = kwargs['name']
self.country_code = kwargs['country_code']
class CreateTenantRequestBody(msrest.serialization.Model):
"""The information needed to create the Azure AD B2C tenant and corresponding Azure resource, which is used for billing purposes.
All required parameters must be populated in order to send to Azure.
:param location: Required. The location in which the resource is hosted and data resides. Refer
to `this documentation <https://aka.ms/B2CDataResidency>`_ to see valid data residency
locations. Please choose one of 'United States', 'Europe', and 'Asia Pacific'.
:type location: str
:param properties: Required.
:type properties: ~$(python-base-
namespace).v2019_01_01_preview.models.CreateTenantRequestBodyProperties
:param sku: Required. SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C
billing at `aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
:type sku: ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKU
:param tags: A set of tags. Resource Tags.
:type tags: dict[str, str]
"""
_validation = {
'location': {'required': True},
'properties': {'required': True},
'sku': {'required': True},
}
_attribute_map = {
'location': {'key': 'location', 'type': 'str'},
'properties': {'key': 'properties', 'type': 'CreateTenantRequestBodyProperties'},
'sku': {'key': 'sku', 'type': 'B2CResourceSKU'},
'tags': {'key': 'tags', 'type': '{str}'},
}
def __init__(
self,
**kwargs
):
super(CreateTenantRequestBody, self).__init__(**kwargs)
self.location = kwargs['location']
self.properties = kwargs['properties']
self.sku = kwargs['sku']
self.tags = kwargs.get('tags', None)
class CreateTenantRequestBodyProperties(msrest.serialization.Model):
"""CreateTenantRequestBodyProperties.
:param display_name: The display name of the B2C tenant.
:type display_name: str
:param country_code: Country code of Azure tenant (e.g. 'US'). Refer to
`aka.ms/B2CDataResidency <https://aka.ms/B2CDataResidency>`_ to see valid country codes and
corresponding data residency locations. If you do not see a country code in an valid data
residency location, choose one from the list.
:type country_code: str
"""
_attribute_map = {
'display_name': {'key': 'createTenantProperties.displayName', 'type': 'str'},
'country_code': {'key': 'createTenantProperties.countryCode', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(CreateTenantRequestBodyProperties, self).__init__(**kwargs)
self.display_name = kwargs.get('display_name', None)
self.country_code = kwargs.get('country_code', None)
class ErrorAdditionalInfo(msrest.serialization.Model):
"""The resource management error additional info.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar type: The additional info type.
:vartype type: str
:ivar info: The additional info.
:vartype info: object
"""
_validation = {
'type': {'readonly': True},
'info': {'readonly': True},
}
_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'info': {'key': 'info', 'type': 'object'},
}
def __init__(
self,
**kwargs
):
super(ErrorAdditionalInfo, self).__init__(**kwargs)
self.type = None
self.info = None
class ErrorResponse(msrest.serialization.Model):
"""Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: The error code.
:vartype code: str
:ivar message: The error message.
:vartype message: str
:ivar target: The error target.
:vartype target: str
:ivar details: The error details.
:vartype details: list[~$(python-base-namespace).v2019_01_01_preview.models.ErrorResponse]
:ivar additional_info: The error additional info.
:vartype additional_info: list[~$(python-base-
namespace).v2019_01_01_preview.models.ErrorAdditionalInfo]
"""
_validation = {
'code': {'readonly': True},
'message': {'readonly': True},
'target': {'readonly': True},
'details': {'readonly': True},
'additional_info': {'readonly': True},
}
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
'target': {'key': 'target', 'type': 'str'},
'details': {'key': 'details', 'type': '[ErrorResponse]'},
'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'},
}
def __init__(
self,
**kwargs
):
super(ErrorResponse, self).__init__(**kwargs)
self.code = None
self.message = None
self.target = None
self.details = None
self.additional_info = None
class NameAvailabilityResponse(msrest.serialization.Model):
"""Response of the CheckNameAvailability operation.
:param message: Description of the reason if name is not available.
:type message: str
:param name_available: True if the name is available and can be used to create a new tenant.
Otherwise false.
:type name_available: bool
:param reason: Describes the reason for the 'nameAvailable' value. Possible values include:
"AlreadyExists", "Invalid".
:type reason: str or ~$(python-base-
namespace).v2019_01_01_preview.models.NameAvailabilityReasonType
"""
_attribute_map = {
'message': {'key': 'message', 'type': 'str'},
'name_available': {'key': 'nameAvailable', 'type': 'bool'},
'reason': {'key': 'reason', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(NameAvailabilityResponse, self).__init__(**kwargs)
self.message = kwargs.get('message', None)
self.name_available = kwargs.get('name_available', None)
self.reason = kwargs.get('reason', None)
class Operation(msrest.serialization.Model):
"""Microsoft.AzureActiveDirectory REST API operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Operation name: {provider}/{resource}/{operation}.
:vartype name: str
:param display: The object that represents the operation.
:type display: ~$(python-base-namespace).v2019_01_01_preview.models.OperationDisplay
"""
_validation = {
'name': {'readonly': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'display': {'key': 'display', 'type': 'OperationDisplay'},
}
def __init__(
self,
**kwargs
):
super(Operation, self).__init__(**kwargs)
self.name = None
self.display = kwargs.get('display', None)
class OperationDisplay(msrest.serialization.Model):
"""The object that represents the operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar provider: Service provider: Microsoft.AzureActiveDirectory.
:vartype provider: str
:ivar resource: Resource on which the operation is performed: GuestUsages, etc.
:vartype resource: str
:ivar operation: Operation type: Read, write, delete, etc.
:vartype operation: str
:param description: Friendly name of the operation.
:type description: str
"""
_validation = {
'provider': {'readonly': True},
'resource': {'readonly': True},
'operation': {'readonly': True},
}
_attribute_map = {
'provider': {'key': 'provider', 'type': 'str'},
'resource': {'key': 'resource', 'type': 'str'},
'operation': {'key': 'operation', 'type': 'str'},
'description': {'key': 'description', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(OperationDisplay, self).__init__(**kwargs)
self.provider = None
self.resource = None
self.operation = None
self.description = kwargs.get('description', None)
class OperationListResult(msrest.serialization.Model):
"""Result of listing operations for the resourceProvider.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of cpim service operations supported by the Microsoft.AzureActiveDirectory
resource provider.
:vartype value: list[~$(python-base-namespace).v2019_01_01_preview.models.Operation]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[Operation]'},
}
def __init__(
self,
**kwargs
):
super(OperationListResult, self).__init__(**kwargs)
self.value = None
| 0.847952 | 0.254023 |
from typing import Dict, Optional, Union
import msrest.serialization
from ._cpim_configuration_client_enums import *
class AsyncOperationStatus(msrest.serialization.Model):
"""The async operation status.
:param subscription_id: Subscription ID that the resource belongs to.
:type subscription_id: str
:param id: The GET resource path for the operation.
:type id: str
:param name: The operation ID.
:type name: str
:param status: The status of the operation. Possible values include: "Succeeded", "Pending",
"Failed".
:type status: str or ~$(python-base-namespace).v2019_01_01_preview.models.StatusType
:param start_time: Start time of the async operation.
:type start_time: str
:param end_time: End time of the async operation.
:type end_time: str
:param error: Error response if async operation failed.
:type error: ~$(python-base-namespace).v2019_01_01_preview.models.AsyncOperationStatusError
:param billing_config: The billing configuration for the tenant.
:type billing_config: ~$(python-base-
namespace).v2019_01_01_preview.models.B2CTenantResourcePropertiesBillingConfig
:param tenant_id: An identifier of the B2C tenant.
:type tenant_id: str
"""
_attribute_map = {
'subscription_id': {'key': 'subscriptionId', 'type': 'str'},
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'status': {'key': 'status', 'type': 'str'},
'start_time': {'key': 'startTime', 'type': 'str'},
'end_time': {'key': 'endTime', 'type': 'str'},
'error': {'key': 'error', 'type': 'AsyncOperationStatusError'},
'billing_config': {'key': 'properties.billingConfig', 'type': 'B2CTenantResourcePropertiesBillingConfig'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
def __init__(
self,
*,
subscription_id: Optional[str] = None,
id: Optional[str] = None,
name: Optional[str] = None,
status: Optional[Union[str, "StatusType"]] = None,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
error: Optional["AsyncOperationStatusError"] = None,
billing_config: Optional["B2CTenantResourcePropertiesBillingConfig"] = None,
tenant_id: Optional[str] = None,
**kwargs
):
super(AsyncOperationStatus, self).__init__(**kwargs)
self.subscription_id = subscription_id
self.id = id
self.name = name
self.status = status
self.start_time = start_time
self.end_time = end_time
self.error = error
self.billing_config = billing_config
self.tenant_id = tenant_id
class AsyncOperationStatusError(msrest.serialization.Model):
"""Error response if async operation failed.
:param code: Error code.
:type code: str
:param message: Error message.
:type message: str
"""
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
}
def __init__(
self,
*,
code: Optional[str] = None,
message: Optional[str] = None,
**kwargs
):
super(AsyncOperationStatusError, self).__init__(**kwargs)
self.code = code
self.message = message
class B2CResourceSKU(msrest.serialization.Model):
"""SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C billing at `aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
Variables are only populated by the server, and will be ignored when sending a request.
:param name: The name of the SKU for the tenant. Possible values include: "Standard",
"PremiumP1", "PremiumP2".
:type name: str or ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKUName
:ivar tier: The tier of the tenant. Default value: "A0".
:vartype tier: str
"""
_validation = {
'tier': {'constant': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'tier': {'key': 'tier', 'type': 'str'},
}
tier = "A0"
def __init__(
self,
*,
name: Optional[Union[str, "B2CResourceSKUName"]] = None,
**kwargs
):
super(B2CResourceSKU, self).__init__(**kwargs)
self.name = name
class B2CTenantResource(msrest.serialization.Model):
"""B2CTenantResource.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar type: The type of the B2C tenant resource. Default value:
"Microsoft.AzureActiveDirectory/b2cDirectories".
:vartype type: str
:param sku: Required. SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C
billing at `aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
:type sku: ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKU
:ivar id: An identifier that represents the B2C tenant resource.
:vartype id: str
:ivar name: The name of the B2C tenant resource.
:vartype name: str
:param location: Required. The location in which the resource is hosted and data resides. Refer
to `this documentation <https://aka.ms/B2CDataResidency>`_ to see valid data residency
locations. Please choose one of 'United States', 'Europe', and 'Asia Pacific'.
:type location: str
:param tags: A set of tags. Resource Tags.
:type tags: dict[str, str]
:param billing_config: The billing configuration for the tenant.
:type billing_config: ~$(python-base-
namespace).v2019_01_01_preview.models.B2CTenantResourcePropertiesBillingConfig
:param tenant_id: An identifier of the B2C tenant.
:type tenant_id: str
"""
_validation = {
'type': {'readonly': True, 'constant': True},
'sku': {'required': True},
'id': {'readonly': True},
'name': {'readonly': True},
'location': {'required': True},
}
_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'sku': {'key': 'sku', 'type': 'B2CResourceSKU'},
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'location': {'key': 'location', 'type': 'str'},
'tags': {'key': 'tags', 'type': '{str}'},
'billing_config': {'key': 'properties.billingConfig', 'type': 'B2CTenantResourcePropertiesBillingConfig'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
type = "Microsoft.AzureActiveDirectory/b2cDirectories"
def __init__(
self,
*,
sku: "B2CResourceSKU",
location: str,
tags: Optional[Dict[str, str]] = None,
billing_config: Optional["B2CTenantResourcePropertiesBillingConfig"] = None,
tenant_id: Optional[str] = None,
**kwargs
):
super(B2CTenantResource, self).__init__(**kwargs)
self.type = None
self.sku = sku
self.id = None
self.name = None
self.location = location
self.tags = tags
self.billing_config = billing_config
self.tenant_id = tenant_id
class B2CTenantResourceList(msrest.serialization.Model):
"""The collection of Azure AD B2C tenant resources.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of guest usages resources.
:vartype value: list[~$(python-base-namespace).v2019_01_01_preview.models.B2CTenantResource]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[B2CTenantResource]'},
}
def __init__(
self,
**kwargs
):
super(B2CTenantResourceList, self).__init__(**kwargs)
self.value = None
class B2CTenantResourcePropertiesBillingConfig(msrest.serialization.Model):
"""The billing configuration for the tenant.
Variables are only populated by the server, and will be ignored when sending a request.
:param billing_type: The type of billing. Will be MAU for all new customers. If 'Auths', it can
be updated to 'MAU'. Cannot be changed if value is 'MAU'. Learn more about Azure AD B2C billing
at `aka.ms/b2cBilling <https://aka.ms/b2cbilling>`_. Possible values include: "MAU", "Auths".
:type billing_type: str or ~$(python-base-namespace).v2019_01_01_preview.models.BillingType
:ivar effective_start_date_utc: The data from which the billing type took effect.
:vartype effective_start_date_utc: str
"""
_validation = {
'effective_start_date_utc': {'readonly': True},
}
_attribute_map = {
'billing_type': {'key': 'billingType', 'type': 'str'},
'effective_start_date_utc': {'key': 'effectiveStartDateUtc', 'type': 'str'},
}
def __init__(
self,
*,
billing_type: Optional[Union[str, "BillingType"]] = None,
**kwargs
):
super(B2CTenantResourcePropertiesBillingConfig, self).__init__(**kwargs)
self.billing_type = billing_type
self.effective_start_date_utc = None
class B2CTenantUpdateRequest(msrest.serialization.Model):
"""The request body to update the Azure AD B2C tenant resource.
:param sku: SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C billing at
`aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
:type sku: ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKU
:param tags: A set of tags. Resource Tags.
:type tags: dict[str, str]
:param billing_config: The billing configuration for the tenant.
:type billing_config: ~$(python-base-
namespace).v2019_01_01_preview.models.B2CTenantResourcePropertiesBillingConfig
:param tenant_id: An identifier of the B2C tenant.
:type tenant_id: str
"""
_attribute_map = {
'sku': {'key': 'sku', 'type': 'B2CResourceSKU'},
'tags': {'key': 'tags', 'type': '{str}'},
'billing_config': {'key': 'properties.billingConfig', 'type': 'B2CTenantResourcePropertiesBillingConfig'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
def __init__(
self,
*,
sku: Optional["B2CResourceSKU"] = None,
tags: Optional[Dict[str, str]] = None,
billing_config: Optional["B2CTenantResourcePropertiesBillingConfig"] = None,
tenant_id: Optional[str] = None,
**kwargs
):
super(B2CTenantUpdateRequest, self).__init__(**kwargs)
self.sku = sku
self.tags = tags
self.billing_config = billing_config
self.tenant_id = tenant_id
class CheckNameAvailabilityRequestBody(msrest.serialization.Model):
"""The information required to check the availability of the name for the tenant.
All required parameters must be populated in order to send to Azure.
:param name: Required. The domain name to check for availability.
:type name: str
:param country_code: Required. Country code of Azure tenant (e.g. 'US'). Refer to
`aka.ms/B2CDataResidency <https://aka.ms/B2CDataResidency>`_ to see valid country codes and
corresponding data residency locations. If you do not see a country code in an valid data
residency location, choose one from the list.
:type country_code: str
"""
_validation = {
'name': {'required': True},
'country_code': {'required': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'country_code': {'key': 'countryCode', 'type': 'str'},
}
def __init__(
self,
*,
name: str,
country_code: str,
**kwargs
):
super(CheckNameAvailabilityRequestBody, self).__init__(**kwargs)
self.name = name
self.country_code = country_code
class CreateTenantRequestBody(msrest.serialization.Model):
"""The information needed to create the Azure AD B2C tenant and corresponding Azure resource, which is used for billing purposes.
All required parameters must be populated in order to send to Azure.
:param location: Required. The location in which the resource is hosted and data resides. Refer
to `this documentation <https://aka.ms/B2CDataResidency>`_ to see valid data residency
locations. Please choose one of 'United States', 'Europe', and 'Asia Pacific'.
:type location: str
:param properties: Required.
:type properties: ~$(python-base-
namespace).v2019_01_01_preview.models.CreateTenantRequestBodyProperties
:param sku: Required. SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C
billing at `aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
:type sku: ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKU
:param tags: A set of tags. Resource Tags.
:type tags: dict[str, str]
"""
_validation = {
'location': {'required': True},
'properties': {'required': True},
'sku': {'required': True},
}
_attribute_map = {
'location': {'key': 'location', 'type': 'str'},
'properties': {'key': 'properties', 'type': 'CreateTenantRequestBodyProperties'},
'sku': {'key': 'sku', 'type': 'B2CResourceSKU'},
'tags': {'key': 'tags', 'type': '{str}'},
}
def __init__(
self,
*,
location: str,
properties: "CreateTenantRequestBodyProperties",
sku: "B2CResourceSKU",
tags: Optional[Dict[str, str]] = None,
**kwargs
):
super(CreateTenantRequestBody, self).__init__(**kwargs)
self.location = location
self.properties = properties
self.sku = sku
self.tags = tags
class CreateTenantRequestBodyProperties(msrest.serialization.Model):
"""CreateTenantRequestBodyProperties.
:param display_name: The display name of the B2C tenant.
:type display_name: str
:param country_code: Country code of Azure tenant (e.g. 'US'). Refer to
`aka.ms/B2CDataResidency <https://aka.ms/B2CDataResidency>`_ to see valid country codes and
corresponding data residency locations. If you do not see a country code in an valid data
residency location, choose one from the list.
:type country_code: str
"""
_attribute_map = {
'display_name': {'key': 'createTenantProperties.displayName', 'type': 'str'},
'country_code': {'key': 'createTenantProperties.countryCode', 'type': 'str'},
}
def __init__(
self,
*,
display_name: Optional[str] = None,
country_code: Optional[str] = None,
**kwargs
):
super(CreateTenantRequestBodyProperties, self).__init__(**kwargs)
self.display_name = display_name
self.country_code = country_code
class ErrorAdditionalInfo(msrest.serialization.Model):
"""The resource management error additional info.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar type: The additional info type.
:vartype type: str
:ivar info: The additional info.
:vartype info: object
"""
_validation = {
'type': {'readonly': True},
'info': {'readonly': True},
}
_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'info': {'key': 'info', 'type': 'object'},
}
def __init__(
self,
**kwargs
):
super(ErrorAdditionalInfo, self).__init__(**kwargs)
self.type = None
self.info = None
class ErrorResponse(msrest.serialization.Model):
"""Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: The error code.
:vartype code: str
:ivar message: The error message.
:vartype message: str
:ivar target: The error target.
:vartype target: str
:ivar details: The error details.
:vartype details: list[~$(python-base-namespace).v2019_01_01_preview.models.ErrorResponse]
:ivar additional_info: The error additional info.
:vartype additional_info: list[~$(python-base-
namespace).v2019_01_01_preview.models.ErrorAdditionalInfo]
"""
_validation = {
'code': {'readonly': True},
'message': {'readonly': True},
'target': {'readonly': True},
'details': {'readonly': True},
'additional_info': {'readonly': True},
}
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
'target': {'key': 'target', 'type': 'str'},
'details': {'key': 'details', 'type': '[ErrorResponse]'},
'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'},
}
def __init__(
self,
**kwargs
):
super(ErrorResponse, self).__init__(**kwargs)
self.code = None
self.message = None
self.target = None
self.details = None
self.additional_info = None
class NameAvailabilityResponse(msrest.serialization.Model):
"""Response of the CheckNameAvailability operation.
:param message: Description of the reason if name is not available.
:type message: str
:param name_available: True if the name is available and can be used to create a new tenant.
Otherwise false.
:type name_available: bool
:param reason: Describes the reason for the 'nameAvailable' value. Possible values include:
"AlreadyExists", "Invalid".
:type reason: str or ~$(python-base-
namespace).v2019_01_01_preview.models.NameAvailabilityReasonType
"""
_attribute_map = {
'message': {'key': 'message', 'type': 'str'},
'name_available': {'key': 'nameAvailable', 'type': 'bool'},
'reason': {'key': 'reason', 'type': 'str'},
}
def __init__(
self,
*,
message: Optional[str] = None,
name_available: Optional[bool] = None,
reason: Optional[Union[str, "NameAvailabilityReasonType"]] = None,
**kwargs
):
super(NameAvailabilityResponse, self).__init__(**kwargs)
self.message = message
self.name_available = name_available
self.reason = reason
class Operation(msrest.serialization.Model):
"""Microsoft.AzureActiveDirectory REST API operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Operation name: {provider}/{resource}/{operation}.
:vartype name: str
:param display: The object that represents the operation.
:type display: ~$(python-base-namespace).v2019_01_01_preview.models.OperationDisplay
"""
_validation = {
'name': {'readonly': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'display': {'key': 'display', 'type': 'OperationDisplay'},
}
def __init__(
self,
*,
display: Optional["OperationDisplay"] = None,
**kwargs
):
super(Operation, self).__init__(**kwargs)
self.name = None
self.display = display
class OperationDisplay(msrest.serialization.Model):
"""The object that represents the operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar provider: Service provider: Microsoft.AzureActiveDirectory.
:vartype provider: str
:ivar resource: Resource on which the operation is performed: GuestUsages, etc.
:vartype resource: str
:ivar operation: Operation type: Read, write, delete, etc.
:vartype operation: str
:param description: Friendly name of the operation.
:type description: str
"""
_validation = {
'provider': {'readonly': True},
'resource': {'readonly': True},
'operation': {'readonly': True},
}
_attribute_map = {
'provider': {'key': 'provider', 'type': 'str'},
'resource': {'key': 'resource', 'type': 'str'},
'operation': {'key': 'operation', 'type': 'str'},
'description': {'key': 'description', 'type': 'str'},
}
def __init__(
self,
*,
description: Optional[str] = None,
**kwargs
):
super(OperationDisplay, self).__init__(**kwargs)
self.provider = None
self.resource = None
self.operation = None
self.description = description
class OperationListResult(msrest.serialization.Model):
"""Result of listing operations for the resourceProvider.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of cpim service operations supported by the Microsoft.AzureActiveDirectory
resource provider.
:vartype value: list[~$(python-base-namespace).v2019_01_01_preview.models.Operation]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[Operation]'},
}
def __init__(
self,
**kwargs
):
super(OperationListResult, self).__init__(**kwargs)
self.value = None
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2019_01_01_preview/models/_models_py3.py
|
_models_py3.py
|
from typing import Dict, Optional, Union
import msrest.serialization
from ._cpim_configuration_client_enums import *
class AsyncOperationStatus(msrest.serialization.Model):
"""The async operation status.
:param subscription_id: Subscription ID that the resource belongs to.
:type subscription_id: str
:param id: The GET resource path for the operation.
:type id: str
:param name: The operation ID.
:type name: str
:param status: The status of the operation. Possible values include: "Succeeded", "Pending",
"Failed".
:type status: str or ~$(python-base-namespace).v2019_01_01_preview.models.StatusType
:param start_time: Start time of the async operation.
:type start_time: str
:param end_time: End time of the async operation.
:type end_time: str
:param error: Error response if async operation failed.
:type error: ~$(python-base-namespace).v2019_01_01_preview.models.AsyncOperationStatusError
:param billing_config: The billing configuration for the tenant.
:type billing_config: ~$(python-base-
namespace).v2019_01_01_preview.models.B2CTenantResourcePropertiesBillingConfig
:param tenant_id: An identifier of the B2C tenant.
:type tenant_id: str
"""
_attribute_map = {
'subscription_id': {'key': 'subscriptionId', 'type': 'str'},
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'status': {'key': 'status', 'type': 'str'},
'start_time': {'key': 'startTime', 'type': 'str'},
'end_time': {'key': 'endTime', 'type': 'str'},
'error': {'key': 'error', 'type': 'AsyncOperationStatusError'},
'billing_config': {'key': 'properties.billingConfig', 'type': 'B2CTenantResourcePropertiesBillingConfig'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
def __init__(
self,
*,
subscription_id: Optional[str] = None,
id: Optional[str] = None,
name: Optional[str] = None,
status: Optional[Union[str, "StatusType"]] = None,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
error: Optional["AsyncOperationStatusError"] = None,
billing_config: Optional["B2CTenantResourcePropertiesBillingConfig"] = None,
tenant_id: Optional[str] = None,
**kwargs
):
super(AsyncOperationStatus, self).__init__(**kwargs)
self.subscription_id = subscription_id
self.id = id
self.name = name
self.status = status
self.start_time = start_time
self.end_time = end_time
self.error = error
self.billing_config = billing_config
self.tenant_id = tenant_id
class AsyncOperationStatusError(msrest.serialization.Model):
"""Error response if async operation failed.
:param code: Error code.
:type code: str
:param message: Error message.
:type message: str
"""
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
}
def __init__(
self,
*,
code: Optional[str] = None,
message: Optional[str] = None,
**kwargs
):
super(AsyncOperationStatusError, self).__init__(**kwargs)
self.code = code
self.message = message
class B2CResourceSKU(msrest.serialization.Model):
"""SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C billing at `aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
Variables are only populated by the server, and will be ignored when sending a request.
:param name: The name of the SKU for the tenant. Possible values include: "Standard",
"PremiumP1", "PremiumP2".
:type name: str or ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKUName
:ivar tier: The tier of the tenant. Default value: "A0".
:vartype tier: str
"""
_validation = {
'tier': {'constant': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'tier': {'key': 'tier', 'type': 'str'},
}
tier = "A0"
def __init__(
self,
*,
name: Optional[Union[str, "B2CResourceSKUName"]] = None,
**kwargs
):
super(B2CResourceSKU, self).__init__(**kwargs)
self.name = name
class B2CTenantResource(msrest.serialization.Model):
"""B2CTenantResource.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar type: The type of the B2C tenant resource. Default value:
"Microsoft.AzureActiveDirectory/b2cDirectories".
:vartype type: str
:param sku: Required. SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C
billing at `aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
:type sku: ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKU
:ivar id: An identifier that represents the B2C tenant resource.
:vartype id: str
:ivar name: The name of the B2C tenant resource.
:vartype name: str
:param location: Required. The location in which the resource is hosted and data resides. Refer
to `this documentation <https://aka.ms/B2CDataResidency>`_ to see valid data residency
locations. Please choose one of 'United States', 'Europe', and 'Asia Pacific'.
:type location: str
:param tags: A set of tags. Resource Tags.
:type tags: dict[str, str]
:param billing_config: The billing configuration for the tenant.
:type billing_config: ~$(python-base-
namespace).v2019_01_01_preview.models.B2CTenantResourcePropertiesBillingConfig
:param tenant_id: An identifier of the B2C tenant.
:type tenant_id: str
"""
_validation = {
'type': {'readonly': True, 'constant': True},
'sku': {'required': True},
'id': {'readonly': True},
'name': {'readonly': True},
'location': {'required': True},
}
_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'sku': {'key': 'sku', 'type': 'B2CResourceSKU'},
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'location': {'key': 'location', 'type': 'str'},
'tags': {'key': 'tags', 'type': '{str}'},
'billing_config': {'key': 'properties.billingConfig', 'type': 'B2CTenantResourcePropertiesBillingConfig'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
type = "Microsoft.AzureActiveDirectory/b2cDirectories"
def __init__(
self,
*,
sku: "B2CResourceSKU",
location: str,
tags: Optional[Dict[str, str]] = None,
billing_config: Optional["B2CTenantResourcePropertiesBillingConfig"] = None,
tenant_id: Optional[str] = None,
**kwargs
):
super(B2CTenantResource, self).__init__(**kwargs)
self.type = None
self.sku = sku
self.id = None
self.name = None
self.location = location
self.tags = tags
self.billing_config = billing_config
self.tenant_id = tenant_id
class B2CTenantResourceList(msrest.serialization.Model):
"""The collection of Azure AD B2C tenant resources.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of guest usages resources.
:vartype value: list[~$(python-base-namespace).v2019_01_01_preview.models.B2CTenantResource]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[B2CTenantResource]'},
}
def __init__(
self,
**kwargs
):
super(B2CTenantResourceList, self).__init__(**kwargs)
self.value = None
class B2CTenantResourcePropertiesBillingConfig(msrest.serialization.Model):
"""The billing configuration for the tenant.
Variables are only populated by the server, and will be ignored when sending a request.
:param billing_type: The type of billing. Will be MAU for all new customers. If 'Auths', it can
be updated to 'MAU'. Cannot be changed if value is 'MAU'. Learn more about Azure AD B2C billing
at `aka.ms/b2cBilling <https://aka.ms/b2cbilling>`_. Possible values include: "MAU", "Auths".
:type billing_type: str or ~$(python-base-namespace).v2019_01_01_preview.models.BillingType
:ivar effective_start_date_utc: The data from which the billing type took effect.
:vartype effective_start_date_utc: str
"""
_validation = {
'effective_start_date_utc': {'readonly': True},
}
_attribute_map = {
'billing_type': {'key': 'billingType', 'type': 'str'},
'effective_start_date_utc': {'key': 'effectiveStartDateUtc', 'type': 'str'},
}
def __init__(
self,
*,
billing_type: Optional[Union[str, "BillingType"]] = None,
**kwargs
):
super(B2CTenantResourcePropertiesBillingConfig, self).__init__(**kwargs)
self.billing_type = billing_type
self.effective_start_date_utc = None
class B2CTenantUpdateRequest(msrest.serialization.Model):
"""The request body to update the Azure AD B2C tenant resource.
:param sku: SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C billing at
`aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
:type sku: ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKU
:param tags: A set of tags. Resource Tags.
:type tags: dict[str, str]
:param billing_config: The billing configuration for the tenant.
:type billing_config: ~$(python-base-
namespace).v2019_01_01_preview.models.B2CTenantResourcePropertiesBillingConfig
:param tenant_id: An identifier of the B2C tenant.
:type tenant_id: str
"""
_attribute_map = {
'sku': {'key': 'sku', 'type': 'B2CResourceSKU'},
'tags': {'key': 'tags', 'type': '{str}'},
'billing_config': {'key': 'properties.billingConfig', 'type': 'B2CTenantResourcePropertiesBillingConfig'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
def __init__(
self,
*,
sku: Optional["B2CResourceSKU"] = None,
tags: Optional[Dict[str, str]] = None,
billing_config: Optional["B2CTenantResourcePropertiesBillingConfig"] = None,
tenant_id: Optional[str] = None,
**kwargs
):
super(B2CTenantUpdateRequest, self).__init__(**kwargs)
self.sku = sku
self.tags = tags
self.billing_config = billing_config
self.tenant_id = tenant_id
class CheckNameAvailabilityRequestBody(msrest.serialization.Model):
"""The information required to check the availability of the name for the tenant.
All required parameters must be populated in order to send to Azure.
:param name: Required. The domain name to check for availability.
:type name: str
:param country_code: Required. Country code of Azure tenant (e.g. 'US'). Refer to
`aka.ms/B2CDataResidency <https://aka.ms/B2CDataResidency>`_ to see valid country codes and
corresponding data residency locations. If you do not see a country code in an valid data
residency location, choose one from the list.
:type country_code: str
"""
_validation = {
'name': {'required': True},
'country_code': {'required': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'country_code': {'key': 'countryCode', 'type': 'str'},
}
def __init__(
self,
*,
name: str,
country_code: str,
**kwargs
):
super(CheckNameAvailabilityRequestBody, self).__init__(**kwargs)
self.name = name
self.country_code = country_code
class CreateTenantRequestBody(msrest.serialization.Model):
"""The information needed to create the Azure AD B2C tenant and corresponding Azure resource, which is used for billing purposes.
All required parameters must be populated in order to send to Azure.
:param location: Required. The location in which the resource is hosted and data resides. Refer
to `this documentation <https://aka.ms/B2CDataResidency>`_ to see valid data residency
locations. Please choose one of 'United States', 'Europe', and 'Asia Pacific'.
:type location: str
:param properties: Required.
:type properties: ~$(python-base-
namespace).v2019_01_01_preview.models.CreateTenantRequestBodyProperties
:param sku: Required. SKU properties of the Azure AD B2C tenant. Learn more about Azure AD B2C
billing at `aka.ms/b2cBilling <https://aka.ms/b2cBilling>`_.
:type sku: ~$(python-base-namespace).v2019_01_01_preview.models.B2CResourceSKU
:param tags: A set of tags. Resource Tags.
:type tags: dict[str, str]
"""
_validation = {
'location': {'required': True},
'properties': {'required': True},
'sku': {'required': True},
}
_attribute_map = {
'location': {'key': 'location', 'type': 'str'},
'properties': {'key': 'properties', 'type': 'CreateTenantRequestBodyProperties'},
'sku': {'key': 'sku', 'type': 'B2CResourceSKU'},
'tags': {'key': 'tags', 'type': '{str}'},
}
def __init__(
self,
*,
location: str,
properties: "CreateTenantRequestBodyProperties",
sku: "B2CResourceSKU",
tags: Optional[Dict[str, str]] = None,
**kwargs
):
super(CreateTenantRequestBody, self).__init__(**kwargs)
self.location = location
self.properties = properties
self.sku = sku
self.tags = tags
class CreateTenantRequestBodyProperties(msrest.serialization.Model):
"""CreateTenantRequestBodyProperties.
:param display_name: The display name of the B2C tenant.
:type display_name: str
:param country_code: Country code of Azure tenant (e.g. 'US'). Refer to
`aka.ms/B2CDataResidency <https://aka.ms/B2CDataResidency>`_ to see valid country codes and
corresponding data residency locations. If you do not see a country code in an valid data
residency location, choose one from the list.
:type country_code: str
"""
_attribute_map = {
'display_name': {'key': 'createTenantProperties.displayName', 'type': 'str'},
'country_code': {'key': 'createTenantProperties.countryCode', 'type': 'str'},
}
def __init__(
self,
*,
display_name: Optional[str] = None,
country_code: Optional[str] = None,
**kwargs
):
super(CreateTenantRequestBodyProperties, self).__init__(**kwargs)
self.display_name = display_name
self.country_code = country_code
class ErrorAdditionalInfo(msrest.serialization.Model):
"""The resource management error additional info.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar type: The additional info type.
:vartype type: str
:ivar info: The additional info.
:vartype info: object
"""
_validation = {
'type': {'readonly': True},
'info': {'readonly': True},
}
_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'info': {'key': 'info', 'type': 'object'},
}
def __init__(
self,
**kwargs
):
super(ErrorAdditionalInfo, self).__init__(**kwargs)
self.type = None
self.info = None
class ErrorResponse(msrest.serialization.Model):
"""Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: The error code.
:vartype code: str
:ivar message: The error message.
:vartype message: str
:ivar target: The error target.
:vartype target: str
:ivar details: The error details.
:vartype details: list[~$(python-base-namespace).v2019_01_01_preview.models.ErrorResponse]
:ivar additional_info: The error additional info.
:vartype additional_info: list[~$(python-base-
namespace).v2019_01_01_preview.models.ErrorAdditionalInfo]
"""
_validation = {
'code': {'readonly': True},
'message': {'readonly': True},
'target': {'readonly': True},
'details': {'readonly': True},
'additional_info': {'readonly': True},
}
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
'target': {'key': 'target', 'type': 'str'},
'details': {'key': 'details', 'type': '[ErrorResponse]'},
'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'},
}
def __init__(
self,
**kwargs
):
super(ErrorResponse, self).__init__(**kwargs)
self.code = None
self.message = None
self.target = None
self.details = None
self.additional_info = None
class NameAvailabilityResponse(msrest.serialization.Model):
"""Response of the CheckNameAvailability operation.
:param message: Description of the reason if name is not available.
:type message: str
:param name_available: True if the name is available and can be used to create a new tenant.
Otherwise false.
:type name_available: bool
:param reason: Describes the reason for the 'nameAvailable' value. Possible values include:
"AlreadyExists", "Invalid".
:type reason: str or ~$(python-base-
namespace).v2019_01_01_preview.models.NameAvailabilityReasonType
"""
_attribute_map = {
'message': {'key': 'message', 'type': 'str'},
'name_available': {'key': 'nameAvailable', 'type': 'bool'},
'reason': {'key': 'reason', 'type': 'str'},
}
def __init__(
self,
*,
message: Optional[str] = None,
name_available: Optional[bool] = None,
reason: Optional[Union[str, "NameAvailabilityReasonType"]] = None,
**kwargs
):
super(NameAvailabilityResponse, self).__init__(**kwargs)
self.message = message
self.name_available = name_available
self.reason = reason
class Operation(msrest.serialization.Model):
"""Microsoft.AzureActiveDirectory REST API operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Operation name: {provider}/{resource}/{operation}.
:vartype name: str
:param display: The object that represents the operation.
:type display: ~$(python-base-namespace).v2019_01_01_preview.models.OperationDisplay
"""
_validation = {
'name': {'readonly': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'display': {'key': 'display', 'type': 'OperationDisplay'},
}
def __init__(
self,
*,
display: Optional["OperationDisplay"] = None,
**kwargs
):
super(Operation, self).__init__(**kwargs)
self.name = None
self.display = display
class OperationDisplay(msrest.serialization.Model):
"""The object that represents the operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar provider: Service provider: Microsoft.AzureActiveDirectory.
:vartype provider: str
:ivar resource: Resource on which the operation is performed: GuestUsages, etc.
:vartype resource: str
:ivar operation: Operation type: Read, write, delete, etc.
:vartype operation: str
:param description: Friendly name of the operation.
:type description: str
"""
_validation = {
'provider': {'readonly': True},
'resource': {'readonly': True},
'operation': {'readonly': True},
}
_attribute_map = {
'provider': {'key': 'provider', 'type': 'str'},
'resource': {'key': 'resource', 'type': 'str'},
'operation': {'key': 'operation', 'type': 'str'},
'description': {'key': 'description', 'type': 'str'},
}
def __init__(
self,
*,
description: Optional[str] = None,
**kwargs
):
super(OperationDisplay, self).__init__(**kwargs)
self.provider = None
self.resource = None
self.operation = None
self.description = description
class OperationListResult(msrest.serialization.Model):
"""Result of listing operations for the resourceProvider.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of cpim service operations supported by the Microsoft.AzureActiveDirectory
resource provider.
:vartype value: list[~$(python-base-namespace).v2019_01_01_preview.models.Operation]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[Operation]'},
}
def __init__(
self,
**kwargs
):
super(OperationListResult, self).__init__(**kwargs)
self.value = None
| 0.917173 | 0.258282 |
from enum import Enum, EnumMeta
from six import with_metaclass
class _CaseInsensitiveEnumMeta(EnumMeta):
def __getitem__(self, name):
return super().__getitem__(name.upper())
def __getattr__(cls, name):
"""Return the enum member matching `name`
We use __getattr__ instead of descriptors or inserting into the enum
class' __dict__ in order to support `name` and `value` being both
properties for enum members (which live in the class' __dict__) and
enum members themselves.
"""
try:
return cls._member_map_[name.upper()]
except KeyError:
raise AttributeError(name)
class B2CResourceSKUName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
"""The name of the SKU for the tenant.
"""
STANDARD = "Standard" #: Azure AD B2C usage is billed to a linked Azure subscription and uses a monthly active users (MAU) billing model.
PREMIUM_P1 = "PremiumP1" #: Azure AD B2C usage is billed to a linked Azure subscription and uses number of authentications based billing.
PREMIUM_P2 = "PremiumP2" #: Azure AD B2C usage is billed to a linked Azure subscription and uses number of authentications based billing.
class BillingType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
"""The type of billing. Will be MAU for all new customers. If 'Auths', it can be updated to 'MAU'.
Cannot be changed if value is 'MAU'. Learn more about Azure AD B2C billing at
`aka.ms/b2cBilling <https://aka.ms/b2cbilling>`_.
"""
MAU = "MAU" #: Azure AD B2C usage is billed to a linked Azure subscription and uses a monthly active users (MAU) billing model.
AUTHS = "Auths" #: Azure AD B2C usage is billed to a linked Azure subscription and uses number of authentications based billing.
class NameAvailabilityReasonType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
"""Describes the reason for the 'nameAvailable' value.
"""
ALREADY_EXISTS = "AlreadyExists" #: The name is already in use and is therefore unavailable.
INVALID = "Invalid" #: The name provided does not match the resource provider’s naming requirements (incorrect length, unsupported characters, etc.).
class StatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
"""The status of the operation.
"""
SUCCEEDED = "Succeeded" #: The operation succeeded.
PENDING = "Pending" #: The operation is pending.
FAILED = "Failed" #: The operation failed.
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2019_01_01_preview/models/_cpim_configuration_client_enums.py
|
_cpim_configuration_client_enums.py
|
from enum import Enum, EnumMeta
from six import with_metaclass
class _CaseInsensitiveEnumMeta(EnumMeta):
def __getitem__(self, name):
return super().__getitem__(name.upper())
def __getattr__(cls, name):
"""Return the enum member matching `name`
We use __getattr__ instead of descriptors or inserting into the enum
class' __dict__ in order to support `name` and `value` being both
properties for enum members (which live in the class' __dict__) and
enum members themselves.
"""
try:
return cls._member_map_[name.upper()]
except KeyError:
raise AttributeError(name)
class B2CResourceSKUName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
"""The name of the SKU for the tenant.
"""
STANDARD = "Standard" #: Azure AD B2C usage is billed to a linked Azure subscription and uses a monthly active users (MAU) billing model.
PREMIUM_P1 = "PremiumP1" #: Azure AD B2C usage is billed to a linked Azure subscription and uses number of authentications based billing.
PREMIUM_P2 = "PremiumP2" #: Azure AD B2C usage is billed to a linked Azure subscription and uses number of authentications based billing.
class BillingType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
"""The type of billing. Will be MAU for all new customers. If 'Auths', it can be updated to 'MAU'.
Cannot be changed if value is 'MAU'. Learn more about Azure AD B2C billing at
`aka.ms/b2cBilling <https://aka.ms/b2cbilling>`_.
"""
MAU = "MAU" #: Azure AD B2C usage is billed to a linked Azure subscription and uses a monthly active users (MAU) billing model.
AUTHS = "Auths" #: Azure AD B2C usage is billed to a linked Azure subscription and uses number of authentications based billing.
class NameAvailabilityReasonType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
"""Describes the reason for the 'nameAvailable' value.
"""
ALREADY_EXISTS = "AlreadyExists" #: The name is already in use and is therefore unavailable.
INVALID = "Invalid" #: The name provided does not match the resource provider’s naming requirements (incorrect length, unsupported characters, etc.).
class StatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
"""The status of the operation.
"""
SUCCEEDED = "Succeeded" #: The operation succeeded.
PENDING = "Pending" #: The operation is pending.
FAILED = "Failed" #: The operation failed.
| 0.82386 | 0.203351 |
try:
from ._models_py3 import AsyncOperationStatus
from ._models_py3 import AsyncOperationStatusError
from ._models_py3 import B2CResourceSKU
from ._models_py3 import B2CTenantResource
from ._models_py3 import B2CTenantResourceList
from ._models_py3 import B2CTenantResourcePropertiesBillingConfig
from ._models_py3 import B2CTenantUpdateRequest
from ._models_py3 import CheckNameAvailabilityRequestBody
from ._models_py3 import CreateTenantRequestBody
from ._models_py3 import CreateTenantRequestBodyProperties
from ._models_py3 import ErrorAdditionalInfo
from ._models_py3 import ErrorResponse
from ._models_py3 import NameAvailabilityResponse
from ._models_py3 import Operation
from ._models_py3 import OperationDisplay
from ._models_py3 import OperationListResult
except (SyntaxError, ImportError):
from ._models import AsyncOperationStatus # type: ignore
from ._models import AsyncOperationStatusError # type: ignore
from ._models import B2CResourceSKU # type: ignore
from ._models import B2CTenantResource # type: ignore
from ._models import B2CTenantResourceList # type: ignore
from ._models import B2CTenantResourcePropertiesBillingConfig # type: ignore
from ._models import B2CTenantUpdateRequest # type: ignore
from ._models import CheckNameAvailabilityRequestBody # type: ignore
from ._models import CreateTenantRequestBody # type: ignore
from ._models import CreateTenantRequestBodyProperties # type: ignore
from ._models import ErrorAdditionalInfo # type: ignore
from ._models import ErrorResponse # type: ignore
from ._models import NameAvailabilityResponse # type: ignore
from ._models import Operation # type: ignore
from ._models import OperationDisplay # type: ignore
from ._models import OperationListResult # type: ignore
from ._cpim_configuration_client_enums import (
B2CResourceSKUName,
BillingType,
NameAvailabilityReasonType,
StatusType,
)
__all__ = [
'AsyncOperationStatus',
'AsyncOperationStatusError',
'B2CResourceSKU',
'B2CTenantResource',
'B2CTenantResourceList',
'B2CTenantResourcePropertiesBillingConfig',
'B2CTenantUpdateRequest',
'CheckNameAvailabilityRequestBody',
'CreateTenantRequestBody',
'CreateTenantRequestBodyProperties',
'ErrorAdditionalInfo',
'ErrorResponse',
'NameAvailabilityResponse',
'Operation',
'OperationDisplay',
'OperationListResult',
'B2CResourceSKUName',
'BillingType',
'NameAvailabilityReasonType',
'StatusType',
]
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2019_01_01_preview/models/__init__.py
|
__init__.py
|
try:
from ._models_py3 import AsyncOperationStatus
from ._models_py3 import AsyncOperationStatusError
from ._models_py3 import B2CResourceSKU
from ._models_py3 import B2CTenantResource
from ._models_py3 import B2CTenantResourceList
from ._models_py3 import B2CTenantResourcePropertiesBillingConfig
from ._models_py3 import B2CTenantUpdateRequest
from ._models_py3 import CheckNameAvailabilityRequestBody
from ._models_py3 import CreateTenantRequestBody
from ._models_py3 import CreateTenantRequestBodyProperties
from ._models_py3 import ErrorAdditionalInfo
from ._models_py3 import ErrorResponse
from ._models_py3 import NameAvailabilityResponse
from ._models_py3 import Operation
from ._models_py3 import OperationDisplay
from ._models_py3 import OperationListResult
except (SyntaxError, ImportError):
from ._models import AsyncOperationStatus # type: ignore
from ._models import AsyncOperationStatusError # type: ignore
from ._models import B2CResourceSKU # type: ignore
from ._models import B2CTenantResource # type: ignore
from ._models import B2CTenantResourceList # type: ignore
from ._models import B2CTenantResourcePropertiesBillingConfig # type: ignore
from ._models import B2CTenantUpdateRequest # type: ignore
from ._models import CheckNameAvailabilityRequestBody # type: ignore
from ._models import CreateTenantRequestBody # type: ignore
from ._models import CreateTenantRequestBodyProperties # type: ignore
from ._models import ErrorAdditionalInfo # type: ignore
from ._models import ErrorResponse # type: ignore
from ._models import NameAvailabilityResponse # type: ignore
from ._models import Operation # type: ignore
from ._models import OperationDisplay # type: ignore
from ._models import OperationListResult # type: ignore
from ._cpim_configuration_client_enums import (
B2CResourceSKUName,
BillingType,
NameAvailabilityReasonType,
StatusType,
)
__all__ = [
'AsyncOperationStatus',
'AsyncOperationStatusError',
'B2CResourceSKU',
'B2CTenantResource',
'B2CTenantResourceList',
'B2CTenantResourcePropertiesBillingConfig',
'B2CTenantUpdateRequest',
'CheckNameAvailabilityRequestBody',
'CreateTenantRequestBody',
'CreateTenantRequestBodyProperties',
'ErrorAdditionalInfo',
'ErrorResponse',
'NameAvailabilityResponse',
'Operation',
'OperationDisplay',
'OperationListResult',
'B2CResourceSKUName',
'BillingType',
'NameAvailabilityReasonType',
'StatusType',
]
| 0.421433 | 0.091099 |
from typing import TYPE_CHECKING
from azure.mgmt.core import ARMPipelineClient
from msrest import Deserializer, Serializer
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Optional
from azure.core.credentials import TokenCredential
from ._configuration import CPIMConfigurationClientConfiguration
from .operations import Operations
from .operations import GuestUsagesOperations
from . import models
class CPIMConfigurationClient(object):
"""CPIM Configuration Client.
:ivar operations: Operations operations
:vartype operations: $(python-base-namespace).v2020_05_01_preview.operations.Operations
:ivar guest_usages: GuestUsagesOperations operations
:vartype guest_usages: $(python-base-namespace).v2020_05_01_preview.operations.GuestUsagesOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).
:type subscription_id: str
:param str base_url: Service URL
"""
def __init__(
self,
credential, # type: "TokenCredential"
subscription_id, # type: str
base_url=None, # type: Optional[str]
**kwargs # type: Any
):
# type: (...) -> None
if not base_url:
base_url = 'https://management.azure.com'
self._config = CPIMConfigurationClientConfiguration(credential, subscription_id, **kwargs)
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self.operations = Operations(
self._client, self._config, self._serialize, self._deserialize)
self.guest_usages = GuestUsagesOperations(
self._client, self._config, self._serialize, self._deserialize)
def close(self):
# type: () -> None
self._client.close()
def __enter__(self):
# type: () -> CPIMConfigurationClient
self._client.__enter__()
return self
def __exit__(self, *exc_details):
# type: (Any) -> None
self._client.__exit__(*exc_details)
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2020_05_01_preview/_cpim_configuration_client.py
|
_cpim_configuration_client.py
|
from typing import TYPE_CHECKING
from azure.mgmt.core import ARMPipelineClient
from msrest import Deserializer, Serializer
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Optional
from azure.core.credentials import TokenCredential
from ._configuration import CPIMConfigurationClientConfiguration
from .operations import Operations
from .operations import GuestUsagesOperations
from . import models
class CPIMConfigurationClient(object):
"""CPIM Configuration Client.
:ivar operations: Operations operations
:vartype operations: $(python-base-namespace).v2020_05_01_preview.operations.Operations
:ivar guest_usages: GuestUsagesOperations operations
:vartype guest_usages: $(python-base-namespace).v2020_05_01_preview.operations.GuestUsagesOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).
:type subscription_id: str
:param str base_url: Service URL
"""
def __init__(
self,
credential, # type: "TokenCredential"
subscription_id, # type: str
base_url=None, # type: Optional[str]
**kwargs # type: Any
):
# type: (...) -> None
if not base_url:
base_url = 'https://management.azure.com'
self._config = CPIMConfigurationClientConfiguration(credential, subscription_id, **kwargs)
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self.operations = Operations(
self._client, self._config, self._serialize, self._deserialize)
self.guest_usages = GuestUsagesOperations(
self._client, self._config, self._serialize, self._deserialize)
def close(self):
# type: () -> None
self._client.close()
def __enter__(self):
# type: () -> CPIMConfigurationClient
self._client.__enter__()
return self
def __exit__(self, *exc_details):
# type: (Any) -> None
self._client.__exit__(*exc_details)
| 0.832134 | 0.07244 |
from typing import TYPE_CHECKING
from azure.core.configuration import Configuration
from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMHttpLoggingPolicy
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any
from azure.core.credentials import TokenCredential
VERSION = "unknown"
class CPIMConfigurationClientConfiguration(Configuration):
"""Configuration for CPIMConfigurationClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).
:type subscription_id: str
"""
def __init__(
self,
credential, # type: "TokenCredential"
subscription_id, # type: str
**kwargs # type: Any
):
# type: (...) -> None
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
super(CPIMConfigurationClientConfiguration, self).__init__(**kwargs)
self.credential = credential
self.subscription_id = subscription_id
self.api_version = "2020-05-01-preview"
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
kwargs.setdefault('sdk_moniker', 'mgmt-azureadb2c/{}'.format(VERSION))
self._configure(**kwargs)
def _configure(
self,
**kwargs # type: Any
):
# type: (...) -> None
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
if self.credential and not self.authentication_policy:
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2020_05_01_preview/_configuration.py
|
_configuration.py
|
from typing import TYPE_CHECKING
from azure.core.configuration import Configuration
from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMHttpLoggingPolicy
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any
from azure.core.credentials import TokenCredential
VERSION = "unknown"
class CPIMConfigurationClientConfiguration(Configuration):
"""Configuration for CPIMConfigurationClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).
:type subscription_id: str
"""
def __init__(
self,
credential, # type: "TokenCredential"
subscription_id, # type: str
**kwargs # type: Any
):
# type: (...) -> None
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
super(CPIMConfigurationClientConfiguration, self).__init__(**kwargs)
self.credential = credential
self.subscription_id = subscription_id
self.api_version = "2020-05-01-preview"
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
kwargs.setdefault('sdk_moniker', 'mgmt-azureadb2c/{}'.format(VERSION))
self._configure(**kwargs)
def _configure(
self,
**kwargs # type: Any
):
# type: (...) -> None
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
if self.credential and not self.authentication_policy:
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
| 0.787278 | 0.077065 |
from typing import TYPE_CHECKING
import warnings
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpRequest, HttpResponse
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
class Operations(object):
"""Operations operations.
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.
:ivar models: Alias to model classes used in this operation group.
:type models: ~$(python-base-namespace).v2020_05_01_preview.models
:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
"""
models = _models
def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config
def list(
self,
**kwargs # type: Any
):
# type: (...) -> Iterable["_models.OperationListResult"]
"""Lists the operations available from this provider.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either OperationListResult or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.OperationListResult]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list.metadata['url'] # type: ignore
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request
def extract_data(pipeline_response):
deserialized = self._deserialize('OperationListResult', pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(
get_next, extract_data
)
list.metadata = {'url': '/providers/Microsoft.AzureActiveDirectory/operations'} # type: ignore
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2020_05_01_preview/operations/_operations.py
|
_operations.py
|
from typing import TYPE_CHECKING
import warnings
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpRequest, HttpResponse
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
class Operations(object):
"""Operations operations.
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.
:ivar models: Alias to model classes used in this operation group.
:type models: ~$(python-base-namespace).v2020_05_01_preview.models
:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
"""
models = _models
def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config
def list(
self,
**kwargs # type: Any
):
# type: (...) -> Iterable["_models.OperationListResult"]
"""Lists the operations available from this provider.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either OperationListResult or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.OperationListResult]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list.metadata['url'] # type: ignore
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request
def extract_data(pipeline_response):
deserialized = self._deserialize('OperationListResult', pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(
get_next, extract_data
)
list.metadata = {'url': '/providers/Microsoft.AzureActiveDirectory/operations'} # type: ignore
| 0.836488 | 0.101857 |
from typing import TYPE_CHECKING
import warnings
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpRequest, HttpResponse
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
class GuestUsagesOperations(object):
"""GuestUsagesOperations operations.
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.
:ivar models: Alias to model classes used in this operation group.
:type models: ~$(python-base-namespace).v2020_05_01_preview.models
:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
"""
models = _models
def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config
def create(
self,
resource_group_name, # type: str
resource_name, # type: str
resource=None, # type: Optional["_models.GuestUsagesResource"]
**kwargs # type: Any
):
# type: (...) -> "_models.GuestUsagesResource"
"""Creates a Guest Usages resource.
Creates a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:param resource: Guest Usages resource to be created.
:type resource: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestUsagesResource, or the result of cls(response)
:rtype: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResource"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
content_type = kwargs.pop("content_type", "application/json")
accept = "application/json"
# Construct URL
url = self.create.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['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]
if resource is not None:
body_content = self._serialize.body(resource, 'GuestUsagesResource')
else:
body_content = None
body_content_kwargs['content'] = body_content
request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('GuestUsagesResource', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
def update(
self,
resource_group_name, # type: str
resource_name, # type: str
resource_patch=None, # type: Optional["_models.GuestUsagesResourcePatch"]
**kwargs # type: Any
):
# type: (...) -> "_models.GuestUsagesResource"
"""Updates a Guest Usages resource.
Updates a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:param resource_patch: Guest Usages Resource to be updated.
:type resource_patch: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResourcePatch
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestUsagesResource, or the result of cls(response)
:rtype: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResource"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
content_type = kwargs.pop("content_type", "application/json")
accept = "application/json"
# Construct URL
url = self.update.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['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]
if resource_patch is not None:
body_content = self._serialize.body(resource_patch, 'GuestUsagesResourcePatch')
else:
body_content = None
body_content_kwargs['content'] = body_content
request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('GuestUsagesResource', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
def delete(
self,
resource_group_name, # type: str
resource_name, # type: str
**kwargs # type: Any
):
# type: (...) -> None
"""Deletes a Guest Usages resource.
Deletes a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None, or the result of cls(response)
:rtype: None
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType[None]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
# Construct URL
url = self.delete.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
request = self._client.delete(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
def get(
self,
resource_group_name, # type: str
resource_name, # type: str
**kwargs # type: Any
):
# type: (...) -> "_models.GuestUsagesResource"
"""Gets a Guest Usages resource.
Gets a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestUsagesResource, or the result of cls(response)
:rtype: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResource"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
# Construct URL
url = self.get.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('GuestUsagesResource', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
def list_by_subscription(
self,
**kwargs # type: Any
):
# type: (...) -> Iterable["_models.GuestUsagesResourceList"]
"""Gets Guest Usages resources under a subscription.
Gets Guest Usages resources under a subscription for the Microsoft.AzureActiveDirectory
resource provider.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either GuestUsagesResourceList or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResourceList]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResourceList"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_by_subscription.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request
def extract_data(pipeline_response):
deserialized = self._deserialize('GuestUsagesResourceList', pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(
get_next, extract_data
)
list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AzureActiveDirectory/guestUsages'} # type: ignore
def list_by_resource_group(
self,
resource_group_name, # type: str
**kwargs # type: Any
):
# type: (...) -> Iterable["_models.GuestUsagesResourceList"]
"""Gets Guest Usages resources under resource group.
Gets Guest Usages resources under a resource group for the Microsoft.AzureActiveDirectory
resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either GuestUsagesResourceList or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResourceList]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResourceList"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_by_resource_group.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request
def extract_data(pipeline_response):
deserialized = self._deserialize('GuestUsagesResourceList', pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(
get_next, extract_data
)
list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages'} # type: ignore
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2020_05_01_preview/operations/_guest_usages_operations.py
|
_guest_usages_operations.py
|
from typing import TYPE_CHECKING
import warnings
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpRequest, HttpResponse
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
class GuestUsagesOperations(object):
"""GuestUsagesOperations operations.
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.
:ivar models: Alias to model classes used in this operation group.
:type models: ~$(python-base-namespace).v2020_05_01_preview.models
:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
"""
models = _models
def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config
def create(
self,
resource_group_name, # type: str
resource_name, # type: str
resource=None, # type: Optional["_models.GuestUsagesResource"]
**kwargs # type: Any
):
# type: (...) -> "_models.GuestUsagesResource"
"""Creates a Guest Usages resource.
Creates a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:param resource: Guest Usages resource to be created.
:type resource: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestUsagesResource, or the result of cls(response)
:rtype: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResource"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
content_type = kwargs.pop("content_type", "application/json")
accept = "application/json"
# Construct URL
url = self.create.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['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]
if resource is not None:
body_content = self._serialize.body(resource, 'GuestUsagesResource')
else:
body_content = None
body_content_kwargs['content'] = body_content
request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('GuestUsagesResource', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
def update(
self,
resource_group_name, # type: str
resource_name, # type: str
resource_patch=None, # type: Optional["_models.GuestUsagesResourcePatch"]
**kwargs # type: Any
):
# type: (...) -> "_models.GuestUsagesResource"
"""Updates a Guest Usages resource.
Updates a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:param resource_patch: Guest Usages Resource to be updated.
:type resource_patch: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResourcePatch
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestUsagesResource, or the result of cls(response)
:rtype: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResource"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
content_type = kwargs.pop("content_type", "application/json")
accept = "application/json"
# Construct URL
url = self.update.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['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]
if resource_patch is not None:
body_content = self._serialize.body(resource_patch, 'GuestUsagesResourcePatch')
else:
body_content = None
body_content_kwargs['content'] = body_content
request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('GuestUsagesResource', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
def delete(
self,
resource_group_name, # type: str
resource_name, # type: str
**kwargs # type: Any
):
# type: (...) -> None
"""Deletes a Guest Usages resource.
Deletes a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None, or the result of cls(response)
:rtype: None
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType[None]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
# Construct URL
url = self.delete.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
request = self._client.delete(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
def get(
self,
resource_group_name, # type: str
resource_name, # type: str
**kwargs # type: Any
):
# type: (...) -> "_models.GuestUsagesResource"
"""Gets a Guest Usages resource.
Gets a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestUsagesResource, or the result of cls(response)
:rtype: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResource"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
# Construct URL
url = self.get.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('GuestUsagesResource', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
def list_by_subscription(
self,
**kwargs # type: Any
):
# type: (...) -> Iterable["_models.GuestUsagesResourceList"]
"""Gets Guest Usages resources under a subscription.
Gets Guest Usages resources under a subscription for the Microsoft.AzureActiveDirectory
resource provider.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either GuestUsagesResourceList or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResourceList]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResourceList"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_by_subscription.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request
def extract_data(pipeline_response):
deserialized = self._deserialize('GuestUsagesResourceList', pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(
get_next, extract_data
)
list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AzureActiveDirectory/guestUsages'} # type: ignore
def list_by_resource_group(
self,
resource_group_name, # type: str
**kwargs # type: Any
):
# type: (...) -> Iterable["_models.GuestUsagesResourceList"]
"""Gets Guest Usages resources under resource group.
Gets Guest Usages resources under a resource group for the Microsoft.AzureActiveDirectory
resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either GuestUsagesResourceList or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResourceList]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResourceList"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_by_resource_group.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request
def extract_data(pipeline_response):
deserialized = self._deserialize('GuestUsagesResourceList', pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(
get_next, extract_data
)
list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages'} # type: ignore
| 0.802013 | 0.086362 |
from typing import Any, Optional, TYPE_CHECKING
from azure.mgmt.core import AsyncARMPipelineClient
from msrest import Deserializer, Serializer
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
from ._configuration import CPIMConfigurationClientConfiguration
from .operations import Operations
from .operations import GuestUsagesOperations
from .. import models
class CPIMConfigurationClient(object):
"""CPIM Configuration Client.
:ivar operations: Operations operations
:vartype operations: $(python-base-namespace).v2020_05_01_preview.aio.operations.Operations
:ivar guest_usages: GuestUsagesOperations operations
:vartype guest_usages: $(python-base-namespace).v2020_05_01_preview.aio.operations.GuestUsagesOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).
:type subscription_id: str
:param str base_url: Service URL
"""
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
base_url: Optional[str] = None,
**kwargs: Any
) -> None:
if not base_url:
base_url = 'https://management.azure.com'
self._config = CPIMConfigurationClientConfiguration(credential, subscription_id, **kwargs)
self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self.operations = Operations(
self._client, self._config, self._serialize, self._deserialize)
self.guest_usages = GuestUsagesOperations(
self._client, self._config, self._serialize, self._deserialize)
async def close(self) -> None:
await self._client.close()
async def __aenter__(self) -> "CPIMConfigurationClient":
await self._client.__aenter__()
return self
async def __aexit__(self, *exc_details) -> None:
await self._client.__aexit__(*exc_details)
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2020_05_01_preview/aio/_cpim_configuration_client.py
|
_cpim_configuration_client.py
|
from typing import Any, Optional, TYPE_CHECKING
from azure.mgmt.core import AsyncARMPipelineClient
from msrest import Deserializer, Serializer
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
from ._configuration import CPIMConfigurationClientConfiguration
from .operations import Operations
from .operations import GuestUsagesOperations
from .. import models
class CPIMConfigurationClient(object):
"""CPIM Configuration Client.
:ivar operations: Operations operations
:vartype operations: $(python-base-namespace).v2020_05_01_preview.aio.operations.Operations
:ivar guest_usages: GuestUsagesOperations operations
:vartype guest_usages: $(python-base-namespace).v2020_05_01_preview.aio.operations.GuestUsagesOperations
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).
:type subscription_id: str
:param str base_url: Service URL
"""
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
base_url: Optional[str] = None,
**kwargs: Any
) -> None:
if not base_url:
base_url = 'https://management.azure.com'
self._config = CPIMConfigurationClientConfiguration(credential, subscription_id, **kwargs)
self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self.operations = Operations(
self._client, self._config, self._serialize, self._deserialize)
self.guest_usages = GuestUsagesOperations(
self._client, self._config, self._serialize, self._deserialize)
async def close(self) -> None:
await self._client.close()
async def __aenter__(self) -> "CPIMConfigurationClient":
await self._client.__aenter__()
return self
async def __aexit__(self, *exc_details) -> None:
await self._client.__aexit__(*exc_details)
| 0.839043 | 0.082623 |
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
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
VERSION = "unknown"
class CPIMConfigurationClientConfiguration(Configuration):
"""Configuration for CPIMConfigurationClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).
:type subscription_id: str
"""
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
**kwargs: Any
) -> None:
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
super(CPIMConfigurationClientConfiguration, self).__init__(**kwargs)
self.credential = credential
self.subscription_id = subscription_id
self.api_version = "2020-05-01-preview"
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
kwargs.setdefault('sdk_moniker', 'mgmt-azureadb2c/{}'.format(VERSION))
self._configure(**kwargs)
def _configure(
self,
**kwargs: Any
) -> None:
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
if self.credential and not self.authentication_policy:
self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2020_05_01_preview/aio/_configuration.py
|
_configuration.py
|
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
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
VERSION = "unknown"
class CPIMConfigurationClientConfiguration(Configuration):
"""Configuration for CPIMConfigurationClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000).
:type subscription_id: str
"""
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
**kwargs: Any
) -> None:
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
super(CPIMConfigurationClientConfiguration, self).__init__(**kwargs)
self.credential = credential
self.subscription_id = subscription_id
self.api_version = "2020-05-01-preview"
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
kwargs.setdefault('sdk_moniker', 'mgmt-azureadb2c/{}'.format(VERSION))
self._configure(**kwargs)
def _configure(
self,
**kwargs: Any
) -> None:
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
if self.credential and not self.authentication_policy:
self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
| 0.818592 | 0.075483 |
from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar
import warnings
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class Operations:
"""Operations async operations.
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.
:ivar models: Alias to model classes used in this operation group.
:type models: ~$(python-base-namespace).v2020_05_01_preview.models
:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
"""
models = _models
def __init__(self, client, config, serializer, deserializer) -> None:
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config
def list(
self,
**kwargs
) -> AsyncIterable["_models.OperationListResult"]:
"""Lists the operations available from this provider.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either OperationListResult or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.OperationListResult]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list.metadata['url'] # type: ignore
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request
async def extract_data(pipeline_response):
deserialized = self._deserialize('OperationListResult', pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(
get_next, extract_data
)
list.metadata = {'url': '/providers/Microsoft.AzureActiveDirectory/operations'} # type: ignore
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2020_05_01_preview/aio/operations/_operations.py
|
_operations.py
|
from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar
import warnings
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class Operations:
"""Operations async operations.
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.
:ivar models: Alias to model classes used in this operation group.
:type models: ~$(python-base-namespace).v2020_05_01_preview.models
:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
"""
models = _models
def __init__(self, client, config, serializer, deserializer) -> None:
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config
def list(
self,
**kwargs
) -> AsyncIterable["_models.OperationListResult"]:
"""Lists the operations available from this provider.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either OperationListResult or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.OperationListResult]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list.metadata['url'] # type: ignore
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request
async def extract_data(pipeline_response):
deserialized = self._deserialize('OperationListResult', pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(
get_next, extract_data
)
list.metadata = {'url': '/providers/Microsoft.AzureActiveDirectory/operations'} # type: ignore
| 0.876621 | 0.121947 |
from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar
import warnings
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class GuestUsagesOperations:
"""GuestUsagesOperations async operations.
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.
:ivar models: Alias to model classes used in this operation group.
:type models: ~$(python-base-namespace).v2020_05_01_preview.models
:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
"""
models = _models
def __init__(self, client, config, serializer, deserializer) -> None:
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config
async def create(
self,
resource_group_name: str,
resource_name: str,
resource: Optional["_models.GuestUsagesResource"] = None,
**kwargs
) -> "_models.GuestUsagesResource":
"""Creates a Guest Usages resource.
Creates a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:param resource: Guest Usages resource to be created.
:type resource: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestUsagesResource, or the result of cls(response)
:rtype: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResource"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
content_type = kwargs.pop("content_type", "application/json")
accept = "application/json"
# Construct URL
url = self.create.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['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]
if resource is not None:
body_content = self._serialize.body(resource, 'GuestUsagesResource')
else:
body_content = None
body_content_kwargs['content'] = body_content
request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('GuestUsagesResource', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
async def update(
self,
resource_group_name: str,
resource_name: str,
resource_patch: Optional["_models.GuestUsagesResourcePatch"] = None,
**kwargs
) -> "_models.GuestUsagesResource":
"""Updates a Guest Usages resource.
Updates a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:param resource_patch: Guest Usages Resource to be updated.
:type resource_patch: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResourcePatch
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestUsagesResource, or the result of cls(response)
:rtype: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResource"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
content_type = kwargs.pop("content_type", "application/json")
accept = "application/json"
# Construct URL
url = self.update.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['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]
if resource_patch is not None:
body_content = self._serialize.body(resource_patch, 'GuestUsagesResourcePatch')
else:
body_content = None
body_content_kwargs['content'] = body_content
request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('GuestUsagesResource', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
async def delete(
self,
resource_group_name: str,
resource_name: str,
**kwargs
) -> None:
"""Deletes a Guest Usages resource.
Deletes a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None, or the result of cls(response)
:rtype: None
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType[None]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
# Construct URL
url = self.delete.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
request = self._client.delete(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
async def get(
self,
resource_group_name: str,
resource_name: str,
**kwargs
) -> "_models.GuestUsagesResource":
"""Gets a Guest Usages resource.
Gets a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestUsagesResource, or the result of cls(response)
:rtype: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResource"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
# Construct URL
url = self.get.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('GuestUsagesResource', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
def list_by_subscription(
self,
**kwargs
) -> AsyncIterable["_models.GuestUsagesResourceList"]:
"""Gets Guest Usages resources under a subscription.
Gets Guest Usages resources under a subscription for the Microsoft.AzureActiveDirectory
resource provider.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either GuestUsagesResourceList or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResourceList]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResourceList"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_by_subscription.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request
async def extract_data(pipeline_response):
deserialized = self._deserialize('GuestUsagesResourceList', pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(
get_next, extract_data
)
list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AzureActiveDirectory/guestUsages'} # type: ignore
def list_by_resource_group(
self,
resource_group_name: str,
**kwargs
) -> AsyncIterable["_models.GuestUsagesResourceList"]:
"""Gets Guest Usages resources under resource group.
Gets Guest Usages resources under a resource group for the Microsoft.AzureActiveDirectory
resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either GuestUsagesResourceList or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResourceList]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResourceList"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_by_resource_group.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request
async def extract_data(pipeline_response):
deserialized = self._deserialize('GuestUsagesResourceList', pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(
get_next, extract_data
)
list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages'} # type: ignore
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2020_05_01_preview/aio/operations/_guest_usages_operations.py
|
_guest_usages_operations.py
|
from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar
import warnings
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class GuestUsagesOperations:
"""GuestUsagesOperations async operations.
You should not instantiate this class directly. Instead, you should create a Client instance that
instantiates it for you and attaches it as an attribute.
:ivar models: Alias to model classes used in this operation group.
:type models: ~$(python-base-namespace).v2020_05_01_preview.models
:param client: Client for service requests.
:param config: Configuration of service client.
:param serializer: An object model serializer.
:param deserializer: An object model deserializer.
"""
models = _models
def __init__(self, client, config, serializer, deserializer) -> None:
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config
async def create(
self,
resource_group_name: str,
resource_name: str,
resource: Optional["_models.GuestUsagesResource"] = None,
**kwargs
) -> "_models.GuestUsagesResource":
"""Creates a Guest Usages resource.
Creates a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:param resource: Guest Usages resource to be created.
:type resource: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestUsagesResource, or the result of cls(response)
:rtype: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResource"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
content_type = kwargs.pop("content_type", "application/json")
accept = "application/json"
# Construct URL
url = self.create.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['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]
if resource is not None:
body_content = self._serialize.body(resource, 'GuestUsagesResource')
else:
body_content = None
body_content_kwargs['content'] = body_content
request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('GuestUsagesResource', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
async def update(
self,
resource_group_name: str,
resource_name: str,
resource_patch: Optional["_models.GuestUsagesResourcePatch"] = None,
**kwargs
) -> "_models.GuestUsagesResource":
"""Updates a Guest Usages resource.
Updates a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:param resource_patch: Guest Usages Resource to be updated.
:type resource_patch: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResourcePatch
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestUsagesResource, or the result of cls(response)
:rtype: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResource"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
content_type = kwargs.pop("content_type", "application/json")
accept = "application/json"
# Construct URL
url = self.update.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['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]
if resource_patch is not None:
body_content = self._serialize.body(resource_patch, 'GuestUsagesResourcePatch')
else:
body_content = None
body_content_kwargs['content'] = body_content
request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('GuestUsagesResource', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
async def delete(
self,
resource_group_name: str,
resource_name: str,
**kwargs
) -> None:
"""Deletes a Guest Usages resource.
Deletes a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None, or the result of cls(response)
:rtype: None
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType[None]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
# Construct URL
url = self.delete.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
request = self._client.delete(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
async def get(
self,
resource_group_name: str,
resource_name: str,
**kwargs
) -> "_models.GuestUsagesResource":
"""Gets a Guest Usages resource.
Gets a Guest Usages resource for the Microsoft.AzureActiveDirectory resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:param resource_name: The initial domain name of the AAD tenant.
:type resource_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestUsagesResource, or the result of cls(response)
:rtype: ~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResource"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
# Construct URL
url = self.get.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceName': self._serialize.url("resource_name", resource_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
request = self._client.get(url, query_parameters, header_parameters)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
deserialized = self._deserialize('GuestUsagesResource', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages/{resourceName}'} # type: ignore
def list_by_subscription(
self,
**kwargs
) -> AsyncIterable["_models.GuestUsagesResourceList"]:
"""Gets Guest Usages resources under a subscription.
Gets Guest Usages resources under a subscription for the Microsoft.AzureActiveDirectory
resource provider.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either GuestUsagesResourceList or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResourceList]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResourceList"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_by_subscription.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request
async def extract_data(pipeline_response):
deserialized = self._deserialize('GuestUsagesResourceList', pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(
get_next, extract_data
)
list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AzureActiveDirectory/guestUsages'} # type: ignore
def list_by_resource_group(
self,
resource_group_name: str,
**kwargs
) -> AsyncIterable["_models.GuestUsagesResourceList"]:
"""Gets Guest Usages resources under resource group.
Gets Guest Usages resources under a resource group for the Microsoft.AzureActiveDirectory
resource provider.
:param resource_group_name: The name of the resource group.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either GuestUsagesResourceList or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResourceList]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestUsagesResourceList"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))
api_version = "2020-05-01-preview"
accept = "application/json"
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_by_resource_group.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request
async def extract_data(pipeline_response):
deserialized = self._deserialize('GuestUsagesResourceList', pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(
get_next, extract_data
)
list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureActiveDirectory/guestUsages'} # type: ignore
| 0.847306 | 0.095181 |
import msrest.serialization
class ErrorAdditionalInfo(msrest.serialization.Model):
"""The resource management error additional info.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar type: The additional info type.
:vartype type: str
:ivar info: The additional info.
:vartype info: object
"""
_validation = {
'type': {'readonly': True},
'info': {'readonly': True},
}
_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'info': {'key': 'info', 'type': 'object'},
}
def __init__(
self,
**kwargs
):
super(ErrorAdditionalInfo, self).__init__(**kwargs)
self.type = None
self.info = None
class ErrorResponse(msrest.serialization.Model):
"""Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: The error code.
:vartype code: str
:ivar message: The error message.
:vartype message: str
:ivar target: The error target.
:vartype target: str
:ivar details: The error details.
:vartype details: list[~$(python-base-namespace).v2020_05_01_preview.models.ErrorResponse]
:ivar additional_info: The error additional info.
:vartype additional_info: list[~$(python-base-
namespace).v2020_05_01_preview.models.ErrorAdditionalInfo]
"""
_validation = {
'code': {'readonly': True},
'message': {'readonly': True},
'target': {'readonly': True},
'details': {'readonly': True},
'additional_info': {'readonly': True},
}
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
'target': {'key': 'target', 'type': 'str'},
'details': {'key': 'details', 'type': '[ErrorResponse]'},
'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'},
}
def __init__(
self,
**kwargs
):
super(ErrorResponse, self).__init__(**kwargs)
self.code = None
self.message = None
self.target = None
self.details = None
self.additional_info = None
class GuestUsagesResource(msrest.serialization.Model):
"""Guest Usages Resource.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: An identifier that represents the Guest Usages resource.
:vartype id: str
:ivar name: The name of the Guest Usages resource.
:vartype name: str
:ivar type: The type of the Guest Usages resource.
:vartype type: str
:param location: Location of the Guest Usages resource.
:type location: str
:param tags: A set of tags. Key-value pairs of additional resource provisioning properties.
:type tags: dict[str, str]
:param tenant_id: An identifier for the tenant for which the resource is being created.
:type tenant_id: str
"""
_validation = {
'id': {'readonly': True},
'name': {'readonly': True},
'type': {'readonly': True},
}
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'},
'location': {'key': 'location', 'type': 'str'},
'tags': {'key': 'tags', 'type': '{str}'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(GuestUsagesResource, self).__init__(**kwargs)
self.id = None
self.name = None
self.type = None
self.location = kwargs.get('location', None)
self.tags = kwargs.get('tags', None)
self.tenant_id = kwargs.get('tenant_id', None)
class GuestUsagesResourceList(msrest.serialization.Model):
"""The collection of guest usages resources.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of guest usages resources.
:vartype value: list[~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[GuestUsagesResource]'},
}
def __init__(
self,
**kwargs
):
super(GuestUsagesResourceList, self).__init__(**kwargs)
self.value = None
class GuestUsagesResourcePatch(msrest.serialization.Model):
"""Guest Usages Resource for Patch.
:param tags: A set of tags. Key-value pairs of additional resource provisioning properties.
:type tags: dict[str, str]
"""
_attribute_map = {
'tags': {'key': 'tags', 'type': '{str}'},
}
def __init__(
self,
**kwargs
):
super(GuestUsagesResourcePatch, self).__init__(**kwargs)
self.tags = kwargs.get('tags', None)
class Operation(msrest.serialization.Model):
"""Microsoft.AzureActiveDirectory REST API operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Operation name: {provider}/{resource}/{operation}.
:vartype name: str
:param display: The object that represents the operation.
:type display: ~$(python-base-namespace).v2020_05_01_preview.models.OperationDisplay
"""
_validation = {
'name': {'readonly': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'display': {'key': 'display', 'type': 'OperationDisplay'},
}
def __init__(
self,
**kwargs
):
super(Operation, self).__init__(**kwargs)
self.name = None
self.display = kwargs.get('display', None)
class OperationDisplay(msrest.serialization.Model):
"""The object that represents the operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar provider: Service provider: Microsoft.AzureActiveDirectory.
:vartype provider: str
:ivar resource: Resource on which the operation is performed: GuestUsages, etc.
:vartype resource: str
:ivar operation: Operation type: Read, write, delete, etc.
:vartype operation: str
:param description: Friendly name of the operation.
:type description: str
"""
_validation = {
'provider': {'readonly': True},
'resource': {'readonly': True},
'operation': {'readonly': True},
}
_attribute_map = {
'provider': {'key': 'provider', 'type': 'str'},
'resource': {'key': 'resource', 'type': 'str'},
'operation': {'key': 'operation', 'type': 'str'},
'description': {'key': 'description', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(OperationDisplay, self).__init__(**kwargs)
self.provider = None
self.resource = None
self.operation = None
self.description = kwargs.get('description', None)
class OperationListResult(msrest.serialization.Model):
"""Result of listing operations for the resourceProvider.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of cpim service operations supported by the Microsoft.AzureActiveDirectory
resource provider.
:vartype value: list[~$(python-base-namespace).v2020_05_01_preview.models.Operation]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[Operation]'},
}
def __init__(
self,
**kwargs
):
super(OperationListResult, self).__init__(**kwargs)
self.value = None
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2020_05_01_preview/models/_models.py
|
_models.py
|
import msrest.serialization
class ErrorAdditionalInfo(msrest.serialization.Model):
"""The resource management error additional info.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar type: The additional info type.
:vartype type: str
:ivar info: The additional info.
:vartype info: object
"""
_validation = {
'type': {'readonly': True},
'info': {'readonly': True},
}
_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'info': {'key': 'info', 'type': 'object'},
}
def __init__(
self,
**kwargs
):
super(ErrorAdditionalInfo, self).__init__(**kwargs)
self.type = None
self.info = None
class ErrorResponse(msrest.serialization.Model):
"""Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: The error code.
:vartype code: str
:ivar message: The error message.
:vartype message: str
:ivar target: The error target.
:vartype target: str
:ivar details: The error details.
:vartype details: list[~$(python-base-namespace).v2020_05_01_preview.models.ErrorResponse]
:ivar additional_info: The error additional info.
:vartype additional_info: list[~$(python-base-
namespace).v2020_05_01_preview.models.ErrorAdditionalInfo]
"""
_validation = {
'code': {'readonly': True},
'message': {'readonly': True},
'target': {'readonly': True},
'details': {'readonly': True},
'additional_info': {'readonly': True},
}
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
'target': {'key': 'target', 'type': 'str'},
'details': {'key': 'details', 'type': '[ErrorResponse]'},
'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'},
}
def __init__(
self,
**kwargs
):
super(ErrorResponse, self).__init__(**kwargs)
self.code = None
self.message = None
self.target = None
self.details = None
self.additional_info = None
class GuestUsagesResource(msrest.serialization.Model):
"""Guest Usages Resource.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: An identifier that represents the Guest Usages resource.
:vartype id: str
:ivar name: The name of the Guest Usages resource.
:vartype name: str
:ivar type: The type of the Guest Usages resource.
:vartype type: str
:param location: Location of the Guest Usages resource.
:type location: str
:param tags: A set of tags. Key-value pairs of additional resource provisioning properties.
:type tags: dict[str, str]
:param tenant_id: An identifier for the tenant for which the resource is being created.
:type tenant_id: str
"""
_validation = {
'id': {'readonly': True},
'name': {'readonly': True},
'type': {'readonly': True},
}
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'},
'location': {'key': 'location', 'type': 'str'},
'tags': {'key': 'tags', 'type': '{str}'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(GuestUsagesResource, self).__init__(**kwargs)
self.id = None
self.name = None
self.type = None
self.location = kwargs.get('location', None)
self.tags = kwargs.get('tags', None)
self.tenant_id = kwargs.get('tenant_id', None)
class GuestUsagesResourceList(msrest.serialization.Model):
"""The collection of guest usages resources.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of guest usages resources.
:vartype value: list[~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[GuestUsagesResource]'},
}
def __init__(
self,
**kwargs
):
super(GuestUsagesResourceList, self).__init__(**kwargs)
self.value = None
class GuestUsagesResourcePatch(msrest.serialization.Model):
"""Guest Usages Resource for Patch.
:param tags: A set of tags. Key-value pairs of additional resource provisioning properties.
:type tags: dict[str, str]
"""
_attribute_map = {
'tags': {'key': 'tags', 'type': '{str}'},
}
def __init__(
self,
**kwargs
):
super(GuestUsagesResourcePatch, self).__init__(**kwargs)
self.tags = kwargs.get('tags', None)
class Operation(msrest.serialization.Model):
"""Microsoft.AzureActiveDirectory REST API operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Operation name: {provider}/{resource}/{operation}.
:vartype name: str
:param display: The object that represents the operation.
:type display: ~$(python-base-namespace).v2020_05_01_preview.models.OperationDisplay
"""
_validation = {
'name': {'readonly': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'display': {'key': 'display', 'type': 'OperationDisplay'},
}
def __init__(
self,
**kwargs
):
super(Operation, self).__init__(**kwargs)
self.name = None
self.display = kwargs.get('display', None)
class OperationDisplay(msrest.serialization.Model):
"""The object that represents the operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar provider: Service provider: Microsoft.AzureActiveDirectory.
:vartype provider: str
:ivar resource: Resource on which the operation is performed: GuestUsages, etc.
:vartype resource: str
:ivar operation: Operation type: Read, write, delete, etc.
:vartype operation: str
:param description: Friendly name of the operation.
:type description: str
"""
_validation = {
'provider': {'readonly': True},
'resource': {'readonly': True},
'operation': {'readonly': True},
}
_attribute_map = {
'provider': {'key': 'provider', 'type': 'str'},
'resource': {'key': 'resource', 'type': 'str'},
'operation': {'key': 'operation', 'type': 'str'},
'description': {'key': 'description', 'type': 'str'},
}
def __init__(
self,
**kwargs
):
super(OperationDisplay, self).__init__(**kwargs)
self.provider = None
self.resource = None
self.operation = None
self.description = kwargs.get('description', None)
class OperationListResult(msrest.serialization.Model):
"""Result of listing operations for the resourceProvider.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of cpim service operations supported by the Microsoft.AzureActiveDirectory
resource provider.
:vartype value: list[~$(python-base-namespace).v2020_05_01_preview.models.Operation]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[Operation]'},
}
def __init__(
self,
**kwargs
):
super(OperationListResult, self).__init__(**kwargs)
self.value = None
| 0.837885 | 0.172764 |
from typing import Dict, Optional
import msrest.serialization
class ErrorAdditionalInfo(msrest.serialization.Model):
"""The resource management error additional info.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar type: The additional info type.
:vartype type: str
:ivar info: The additional info.
:vartype info: object
"""
_validation = {
'type': {'readonly': True},
'info': {'readonly': True},
}
_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'info': {'key': 'info', 'type': 'object'},
}
def __init__(
self,
**kwargs
):
super(ErrorAdditionalInfo, self).__init__(**kwargs)
self.type = None
self.info = None
class ErrorResponse(msrest.serialization.Model):
"""Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: The error code.
:vartype code: str
:ivar message: The error message.
:vartype message: str
:ivar target: The error target.
:vartype target: str
:ivar details: The error details.
:vartype details: list[~$(python-base-namespace).v2020_05_01_preview.models.ErrorResponse]
:ivar additional_info: The error additional info.
:vartype additional_info: list[~$(python-base-
namespace).v2020_05_01_preview.models.ErrorAdditionalInfo]
"""
_validation = {
'code': {'readonly': True},
'message': {'readonly': True},
'target': {'readonly': True},
'details': {'readonly': True},
'additional_info': {'readonly': True},
}
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
'target': {'key': 'target', 'type': 'str'},
'details': {'key': 'details', 'type': '[ErrorResponse]'},
'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'},
}
def __init__(
self,
**kwargs
):
super(ErrorResponse, self).__init__(**kwargs)
self.code = None
self.message = None
self.target = None
self.details = None
self.additional_info = None
class GuestUsagesResource(msrest.serialization.Model):
"""Guest Usages Resource.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: An identifier that represents the Guest Usages resource.
:vartype id: str
:ivar name: The name of the Guest Usages resource.
:vartype name: str
:ivar type: The type of the Guest Usages resource.
:vartype type: str
:param location: Location of the Guest Usages resource.
:type location: str
:param tags: A set of tags. Key-value pairs of additional resource provisioning properties.
:type tags: dict[str, str]
:param tenant_id: An identifier for the tenant for which the resource is being created.
:type tenant_id: str
"""
_validation = {
'id': {'readonly': True},
'name': {'readonly': True},
'type': {'readonly': True},
}
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'},
'location': {'key': 'location', 'type': 'str'},
'tags': {'key': 'tags', 'type': '{str}'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
def __init__(
self,
*,
location: Optional[str] = None,
tags: Optional[Dict[str, str]] = None,
tenant_id: Optional[str] = None,
**kwargs
):
super(GuestUsagesResource, self).__init__(**kwargs)
self.id = None
self.name = None
self.type = None
self.location = location
self.tags = tags
self.tenant_id = tenant_id
class GuestUsagesResourceList(msrest.serialization.Model):
"""The collection of guest usages resources.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of guest usages resources.
:vartype value: list[~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[GuestUsagesResource]'},
}
def __init__(
self,
**kwargs
):
super(GuestUsagesResourceList, self).__init__(**kwargs)
self.value = None
class GuestUsagesResourcePatch(msrest.serialization.Model):
"""Guest Usages Resource for Patch.
:param tags: A set of tags. Key-value pairs of additional resource provisioning properties.
:type tags: dict[str, str]
"""
_attribute_map = {
'tags': {'key': 'tags', 'type': '{str}'},
}
def __init__(
self,
*,
tags: Optional[Dict[str, str]] = None,
**kwargs
):
super(GuestUsagesResourcePatch, self).__init__(**kwargs)
self.tags = tags
class Operation(msrest.serialization.Model):
"""Microsoft.AzureActiveDirectory REST API operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Operation name: {provider}/{resource}/{operation}.
:vartype name: str
:param display: The object that represents the operation.
:type display: ~$(python-base-namespace).v2020_05_01_preview.models.OperationDisplay
"""
_validation = {
'name': {'readonly': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'display': {'key': 'display', 'type': 'OperationDisplay'},
}
def __init__(
self,
*,
display: Optional["OperationDisplay"] = None,
**kwargs
):
super(Operation, self).__init__(**kwargs)
self.name = None
self.display = display
class OperationDisplay(msrest.serialization.Model):
"""The object that represents the operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar provider: Service provider: Microsoft.AzureActiveDirectory.
:vartype provider: str
:ivar resource: Resource on which the operation is performed: GuestUsages, etc.
:vartype resource: str
:ivar operation: Operation type: Read, write, delete, etc.
:vartype operation: str
:param description: Friendly name of the operation.
:type description: str
"""
_validation = {
'provider': {'readonly': True},
'resource': {'readonly': True},
'operation': {'readonly': True},
}
_attribute_map = {
'provider': {'key': 'provider', 'type': 'str'},
'resource': {'key': 'resource', 'type': 'str'},
'operation': {'key': 'operation', 'type': 'str'},
'description': {'key': 'description', 'type': 'str'},
}
def __init__(
self,
*,
description: Optional[str] = None,
**kwargs
):
super(OperationDisplay, self).__init__(**kwargs)
self.provider = None
self.resource = None
self.operation = None
self.description = description
class OperationListResult(msrest.serialization.Model):
"""Result of listing operations for the resourceProvider.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of cpim service operations supported by the Microsoft.AzureActiveDirectory
resource provider.
:vartype value: list[~$(python-base-namespace).v2020_05_01_preview.models.Operation]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[Operation]'},
}
def __init__(
self,
**kwargs
):
super(OperationListResult, self).__init__(**kwargs)
self.value = None
|
azure-mgmt-azureadb2c
|
/azure-mgmt-azureadb2c-1.0.0b2.zip/azure-mgmt-azureadb2c-1.0.0b2/azure/mgmt/azureadb2c/v2020_05_01_preview/models/_models_py3.py
|
_models_py3.py
|
from typing import Dict, Optional
import msrest.serialization
class ErrorAdditionalInfo(msrest.serialization.Model):
"""The resource management error additional info.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar type: The additional info type.
:vartype type: str
:ivar info: The additional info.
:vartype info: object
"""
_validation = {
'type': {'readonly': True},
'info': {'readonly': True},
}
_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'info': {'key': 'info', 'type': 'object'},
}
def __init__(
self,
**kwargs
):
super(ErrorAdditionalInfo, self).__init__(**kwargs)
self.type = None
self.info = None
class ErrorResponse(msrest.serialization.Model):
"""Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: The error code.
:vartype code: str
:ivar message: The error message.
:vartype message: str
:ivar target: The error target.
:vartype target: str
:ivar details: The error details.
:vartype details: list[~$(python-base-namespace).v2020_05_01_preview.models.ErrorResponse]
:ivar additional_info: The error additional info.
:vartype additional_info: list[~$(python-base-
namespace).v2020_05_01_preview.models.ErrorAdditionalInfo]
"""
_validation = {
'code': {'readonly': True},
'message': {'readonly': True},
'target': {'readonly': True},
'details': {'readonly': True},
'additional_info': {'readonly': True},
}
_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
'target': {'key': 'target', 'type': 'str'},
'details': {'key': 'details', 'type': '[ErrorResponse]'},
'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'},
}
def __init__(
self,
**kwargs
):
super(ErrorResponse, self).__init__(**kwargs)
self.code = None
self.message = None
self.target = None
self.details = None
self.additional_info = None
class GuestUsagesResource(msrest.serialization.Model):
"""Guest Usages Resource.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: An identifier that represents the Guest Usages resource.
:vartype id: str
:ivar name: The name of the Guest Usages resource.
:vartype name: str
:ivar type: The type of the Guest Usages resource.
:vartype type: str
:param location: Location of the Guest Usages resource.
:type location: str
:param tags: A set of tags. Key-value pairs of additional resource provisioning properties.
:type tags: dict[str, str]
:param tenant_id: An identifier for the tenant for which the resource is being created.
:type tenant_id: str
"""
_validation = {
'id': {'readonly': True},
'name': {'readonly': True},
'type': {'readonly': True},
}
_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'},
'type': {'key': 'type', 'type': 'str'},
'location': {'key': 'location', 'type': 'str'},
'tags': {'key': 'tags', 'type': '{str}'},
'tenant_id': {'key': 'properties.tenantId', 'type': 'str'},
}
def __init__(
self,
*,
location: Optional[str] = None,
tags: Optional[Dict[str, str]] = None,
tenant_id: Optional[str] = None,
**kwargs
):
super(GuestUsagesResource, self).__init__(**kwargs)
self.id = None
self.name = None
self.type = None
self.location = location
self.tags = tags
self.tenant_id = tenant_id
class GuestUsagesResourceList(msrest.serialization.Model):
"""The collection of guest usages resources.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of guest usages resources.
:vartype value: list[~$(python-base-namespace).v2020_05_01_preview.models.GuestUsagesResource]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[GuestUsagesResource]'},
}
def __init__(
self,
**kwargs
):
super(GuestUsagesResourceList, self).__init__(**kwargs)
self.value = None
class GuestUsagesResourcePatch(msrest.serialization.Model):
"""Guest Usages Resource for Patch.
:param tags: A set of tags. Key-value pairs of additional resource provisioning properties.
:type tags: dict[str, str]
"""
_attribute_map = {
'tags': {'key': 'tags', 'type': '{str}'},
}
def __init__(
self,
*,
tags: Optional[Dict[str, str]] = None,
**kwargs
):
super(GuestUsagesResourcePatch, self).__init__(**kwargs)
self.tags = tags
class Operation(msrest.serialization.Model):
"""Microsoft.AzureActiveDirectory REST API operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Operation name: {provider}/{resource}/{operation}.
:vartype name: str
:param display: The object that represents the operation.
:type display: ~$(python-base-namespace).v2020_05_01_preview.models.OperationDisplay
"""
_validation = {
'name': {'readonly': True},
}
_attribute_map = {
'name': {'key': 'name', 'type': 'str'},
'display': {'key': 'display', 'type': 'OperationDisplay'},
}
def __init__(
self,
*,
display: Optional["OperationDisplay"] = None,
**kwargs
):
super(Operation, self).__init__(**kwargs)
self.name = None
self.display = display
class OperationDisplay(msrest.serialization.Model):
"""The object that represents the operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar provider: Service provider: Microsoft.AzureActiveDirectory.
:vartype provider: str
:ivar resource: Resource on which the operation is performed: GuestUsages, etc.
:vartype resource: str
:ivar operation: Operation type: Read, write, delete, etc.
:vartype operation: str
:param description: Friendly name of the operation.
:type description: str
"""
_validation = {
'provider': {'readonly': True},
'resource': {'readonly': True},
'operation': {'readonly': True},
}
_attribute_map = {
'provider': {'key': 'provider', 'type': 'str'},
'resource': {'key': 'resource', 'type': 'str'},
'operation': {'key': 'operation', 'type': 'str'},
'description': {'key': 'description', 'type': 'str'},
}
def __init__(
self,
*,
description: Optional[str] = None,
**kwargs
):
super(OperationDisplay, self).__init__(**kwargs)
self.provider = None
self.resource = None
self.operation = None
self.description = description
class OperationListResult(msrest.serialization.Model):
"""Result of listing operations for the resourceProvider.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of cpim service operations supported by the Microsoft.AzureActiveDirectory
resource provider.
:vartype value: list[~$(python-base-namespace).v2020_05_01_preview.models.Operation]
"""
_validation = {
'value': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': '[Operation]'},
}
def __init__(
self,
**kwargs
):
super(OperationListResult, self).__init__(**kwargs)
self.value = None
| 0.918594 | 0.215083 |
# Microsoft Azure SDK for Python
This is the Microsoft Azure Azure Arc Data Management Client Library.
This package has been tested with Python 3.7+.
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).
## _Disclaimer_
_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_
# Usage
To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt)
For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/)
Code samples for this package can be found at [Azure Arc Data Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com.
Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
# Provide Feedback
If you encounter any bugs or have suggestions, please file an issue in the
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
section of the project.

|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/README.md
|
README.md
|
# Microsoft Azure SDK for Python
This is the Microsoft Azure Azure Arc Data Management Client Library.
This package has been tested with Python 3.7+.
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).
## _Disclaimer_
_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_
# Usage
To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt)
For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/)
Code samples for this package can be found at [Azure Arc Data Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com.
Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
# Provide Feedback
If you encounter any bugs or have suggestions, please file an issue in the
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
section of the project.

| 0.796965 | 0.643679 |
# Release History
## 2.0.0b1 (2022-11-18)
### Features Added
- Added operation group ActiveDirectoryConnectorsOperations
- Added operation group PostgresInstancesOperations
- Model DataControllerUpdate has a new parameter properties
- Model ProxyResource has a new parameter system_data
- Model Resource has a new parameter system_data
- Model SqlManagedInstanceProperties has a new parameter active_directory_information
- Model SqlServerInstanceProperties has a new parameter host_type
### Breaking Changes
- Renamed operation DataControllersOperations.patch_data_controller to DataControllersOperations.begin_patch_data_controller
## 1.0.0 (2021-10-26)
**Features**
- Model DataControllerProperties has a new parameter logs_dashboard_credential
- Model DataControllerProperties has a new parameter metrics_dashboard_credential
## 1.0.0b1 (2021-09-15)
* Initial Release
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/CHANGELOG.md
|
CHANGELOG.md
|
# Release History
## 2.0.0b1 (2022-11-18)
### Features Added
- Added operation group ActiveDirectoryConnectorsOperations
- Added operation group PostgresInstancesOperations
- Model DataControllerUpdate has a new parameter properties
- Model ProxyResource has a new parameter system_data
- Model Resource has a new parameter system_data
- Model SqlManagedInstanceProperties has a new parameter active_directory_information
- Model SqlServerInstanceProperties has a new parameter host_type
### Breaking Changes
- Renamed operation DataControllersOperations.patch_data_controller to DataControllersOperations.begin_patch_data_controller
## 1.0.0 (2021-10-26)
**Features**
- Model DataControllerProperties has a new parameter logs_dashboard_credential
- Model DataControllerProperties has a new parameter metrics_dashboard_credential
## 1.0.0b1 (2021-09-15)
* Initial Release
| 0.520984 | 0.210665 |
import sys
from typing import Any, TYPE_CHECKING
from azure.core.configuration import Configuration
from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
from ._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class AzureArcDataManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureArcDataManagementClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the Azure subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2022-03-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(AzureArcDataManagementClientConfiguration, self).__init__(**kwargs)
api_version: Literal["2022-03-01-preview"] = kwargs.pop("api_version", "2022-03-01-preview")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-azurearcdata/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = ARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/_configuration.py
|
_configuration.py
|
import sys
from typing import Any, TYPE_CHECKING
from azure.core.configuration import Configuration
from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
from ._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class AzureArcDataManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureArcDataManagementClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the Azure subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2022-03-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(AzureArcDataManagementClientConfiguration, self).__init__(**kwargs)
api_version: Literal["2022-03-01-preview"] = kwargs.pop("api_version", "2022-03-01-preview")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-azurearcdata/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = ARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
| 0.557845 | 0.079639 |
from copy import deepcopy
from typing import Any, TYPE_CHECKING
from azure.core.rest import HttpRequest, HttpResponse
from azure.mgmt.core import ARMPipelineClient
from . import models as _models
from ._configuration import AzureArcDataManagementClientConfiguration
from ._serialization import Deserializer, Serializer
from .operations import (
ActiveDirectoryConnectorsOperations,
DataControllersOperations,
Operations,
PostgresInstancesOperations,
SqlManagedInstancesOperations,
SqlServerInstancesOperations,
)
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class AzureArcDataManagementClient: # pylint: disable=client-accepts-api-version-keyword
"""The AzureArcData management API provides a RESTful set of web APIs to manage Azure Data
Services on Azure Arc Resources.
:ivar operations: Operations operations
:vartype operations: azure.mgmt.azurearcdata.operations.Operations
:ivar sql_managed_instances: SqlManagedInstancesOperations operations
:vartype sql_managed_instances:
azure.mgmt.azurearcdata.operations.SqlManagedInstancesOperations
:ivar sql_server_instances: SqlServerInstancesOperations operations
:vartype sql_server_instances: azure.mgmt.azurearcdata.operations.SqlServerInstancesOperations
:ivar data_controllers: DataControllersOperations operations
:vartype data_controllers: azure.mgmt.azurearcdata.operations.DataControllersOperations
:ivar active_directory_connectors: ActiveDirectoryConnectorsOperations operations
:vartype active_directory_connectors:
azure.mgmt.azurearcdata.operations.ActiveDirectoryConnectorsOperations
:ivar postgres_instances: PostgresInstancesOperations operations
:vartype postgres_instances: azure.mgmt.azurearcdata.operations.PostgresInstancesOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the Azure subscription. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2022-03-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
"""
def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = AzureArcDataManagementClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.sql_managed_instances = SqlManagedInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.sql_server_instances = SqlServerInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.data_controllers = DataControllersOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.active_directory_connectors = ActiveDirectoryConnectorsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.postgres_instances = PostgresInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.HttpResponse
"""
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) -> None:
self._client.close()
def __enter__(self) -> "AzureArcDataManagementClient":
self._client.__enter__()
return self
def __exit__(self, *exc_details) -> None:
self._client.__exit__(*exc_details)
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/_azure_arc_data_management_client.py
|
_azure_arc_data_management_client.py
|
from copy import deepcopy
from typing import Any, TYPE_CHECKING
from azure.core.rest import HttpRequest, HttpResponse
from azure.mgmt.core import ARMPipelineClient
from . import models as _models
from ._configuration import AzureArcDataManagementClientConfiguration
from ._serialization import Deserializer, Serializer
from .operations import (
ActiveDirectoryConnectorsOperations,
DataControllersOperations,
Operations,
PostgresInstancesOperations,
SqlManagedInstancesOperations,
SqlServerInstancesOperations,
)
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class AzureArcDataManagementClient: # pylint: disable=client-accepts-api-version-keyword
"""The AzureArcData management API provides a RESTful set of web APIs to manage Azure Data
Services on Azure Arc Resources.
:ivar operations: Operations operations
:vartype operations: azure.mgmt.azurearcdata.operations.Operations
:ivar sql_managed_instances: SqlManagedInstancesOperations operations
:vartype sql_managed_instances:
azure.mgmt.azurearcdata.operations.SqlManagedInstancesOperations
:ivar sql_server_instances: SqlServerInstancesOperations operations
:vartype sql_server_instances: azure.mgmt.azurearcdata.operations.SqlServerInstancesOperations
:ivar data_controllers: DataControllersOperations operations
:vartype data_controllers: azure.mgmt.azurearcdata.operations.DataControllersOperations
:ivar active_directory_connectors: ActiveDirectoryConnectorsOperations operations
:vartype active_directory_connectors:
azure.mgmt.azurearcdata.operations.ActiveDirectoryConnectorsOperations
:ivar postgres_instances: PostgresInstancesOperations operations
:vartype postgres_instances: azure.mgmt.azurearcdata.operations.PostgresInstancesOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the Azure subscription. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2022-03-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
"""
def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = AzureArcDataManagementClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.sql_managed_instances = SqlManagedInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.sql_server_instances = SqlServerInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.data_controllers = DataControllersOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.active_directory_connectors = ActiveDirectoryConnectorsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.postgres_instances = PostgresInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.HttpResponse
"""
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) -> None:
self._client.close()
def __enter__(self) -> "AzureArcDataManagementClient":
self._client.__enter__()
return self
def __exit__(self, *exc_details) -> None:
self._client.__exit__(*exc_details)
| 0.841598 | 0.13966 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/postgresInstances"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, postgres_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"postgresInstanceName": _SERIALIZER.url("postgres_instance_name", postgres_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str, postgres_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"postgresInstanceName": _SERIALIZER.url("postgres_instance_name", postgres_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, postgres_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"postgresInstanceName": _SERIALIZER.url("postgres_instance_name", postgres_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, postgres_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"postgresInstanceName": _SERIALIZER.url("postgres_instance_name", postgres_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
class PostgresInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.AzureArcDataManagementClient`'s
:attr:`postgres_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> Iterable["_models.PostgresInstance"]:
"""List postgres Instance resources in the subscription.
List postgres Instance resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either PostgresInstance or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PostgresInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PostgresInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/postgresInstances"}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.PostgresInstance"]:
"""List postgres Instance resources in the resource group.
Get a postgres Instances list by Resource group name.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either PostgresInstance or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PostgresInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PostgresInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances"
}
@distributed_trace
def get(self, resource_group_name: str, postgres_instance_name: str, **kwargs: Any) -> _models.PostgresInstance:
"""Retrieves a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
def _create_initial(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: Union[_models.PostgresInstance, IO],
**kwargs: Any
) -> _models.PostgresInstance:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(resource, (IO, bytes)):
_content = resource
else:
_json = self._serialize.body(resource, "PostgresInstance")
request = build_create_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
@overload
def begin_create(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: _models.PostgresInstance,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.PostgresInstance]:
"""Creates or replaces a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param resource: The postgres instance. Required.
:type resource: ~azure.mgmt.azurearcdata.models.PostgresInstance
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either PostgresInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.PostgresInstance]:
"""Creates or replaces a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param resource: The postgres instance. Required.
:type resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either PostgresInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: Union[_models.PostgresInstance, IO],
**kwargs: Any
) -> LROPoller[_models.PostgresInstance]:
"""Creates or replaces a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param resource: The postgres instance. Is either a model type or a IO type. Required.
:type resource: ~azure.mgmt.azurearcdata.models.PostgresInstance or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either PostgresInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_initial(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
resource=resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, postgres_instance_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
@distributed_trace
def begin_delete(self, resource_group_name: str, postgres_instance_name: str, **kwargs: Any) -> LROPoller[None]:
"""Deletes a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
@overload
def update(
self,
resource_group_name: str,
postgres_instance_name: str,
parameters: _models.PostgresInstanceUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.PostgresInstance:
"""Updates a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param parameters: The Postgres Instance. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.PostgresInstanceUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
postgres_instance_name: str,
parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.PostgresInstance:
"""Updates a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param parameters: The Postgres Instance. Required.
:type parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
postgres_instance_name: str,
parameters: Union[_models.PostgresInstanceUpdate, IO],
**kwargs: Any
) -> _models.PostgresInstance:
"""Updates a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param parameters: The Postgres Instance. Is either a model type or a IO type. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.PostgresInstanceUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IO, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "PostgresInstanceUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/operations/_postgres_instances_operations.py
|
_postgres_instances_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/postgresInstances"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, postgres_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"postgresInstanceName": _SERIALIZER.url("postgres_instance_name", postgres_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str, postgres_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"postgresInstanceName": _SERIALIZER.url("postgres_instance_name", postgres_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, postgres_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"postgresInstanceName": _SERIALIZER.url("postgres_instance_name", postgres_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, postgres_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"postgresInstanceName": _SERIALIZER.url("postgres_instance_name", postgres_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
class PostgresInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.AzureArcDataManagementClient`'s
:attr:`postgres_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> Iterable["_models.PostgresInstance"]:
"""List postgres Instance resources in the subscription.
List postgres Instance resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either PostgresInstance or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PostgresInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PostgresInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/postgresInstances"}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.PostgresInstance"]:
"""List postgres Instance resources in the resource group.
Get a postgres Instances list by Resource group name.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either PostgresInstance or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PostgresInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PostgresInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances"
}
@distributed_trace
def get(self, resource_group_name: str, postgres_instance_name: str, **kwargs: Any) -> _models.PostgresInstance:
"""Retrieves a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
def _create_initial(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: Union[_models.PostgresInstance, IO],
**kwargs: Any
) -> _models.PostgresInstance:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(resource, (IO, bytes)):
_content = resource
else:
_json = self._serialize.body(resource, "PostgresInstance")
request = build_create_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
@overload
def begin_create(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: _models.PostgresInstance,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.PostgresInstance]:
"""Creates or replaces a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param resource: The postgres instance. Required.
:type resource: ~azure.mgmt.azurearcdata.models.PostgresInstance
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either PostgresInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.PostgresInstance]:
"""Creates or replaces a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param resource: The postgres instance. Required.
:type resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either PostgresInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: Union[_models.PostgresInstance, IO],
**kwargs: Any
) -> LROPoller[_models.PostgresInstance]:
"""Creates or replaces a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param resource: The postgres instance. Is either a model type or a IO type. Required.
:type resource: ~azure.mgmt.azurearcdata.models.PostgresInstance or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either PostgresInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_initial(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
resource=resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, postgres_instance_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
@distributed_trace
def begin_delete(self, resource_group_name: str, postgres_instance_name: str, **kwargs: Any) -> LROPoller[None]:
"""Deletes a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
@overload
def update(
self,
resource_group_name: str,
postgres_instance_name: str,
parameters: _models.PostgresInstanceUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.PostgresInstance:
"""Updates a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param parameters: The Postgres Instance. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.PostgresInstanceUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
postgres_instance_name: str,
parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.PostgresInstance:
"""Updates a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param parameters: The Postgres Instance. Required.
:type parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
postgres_instance_name: str,
parameters: Union[_models.PostgresInstanceUpdate, IO],
**kwargs: Any
) -> _models.PostgresInstance:
"""Updates a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param parameters: The Postgres Instance. Is either a model type or a IO type. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.PostgresInstanceUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IO, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "PostgresInstanceUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
| 0.572603 | 0.076098 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/sqlServerInstances"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, sql_server_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlServerInstanceName": _SERIALIZER.url("sql_server_instance_name", sql_server_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str, sql_server_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlServerInstanceName": _SERIALIZER.url("sql_server_instance_name", sql_server_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, sql_server_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlServerInstanceName": _SERIALIZER.url("sql_server_instance_name", sql_server_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, sql_server_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlServerInstanceName": _SERIALIZER.url("sql_server_instance_name", sql_server_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
class SqlServerInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.AzureArcDataManagementClient`'s
:attr:`sql_server_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> Iterable["_models.SqlServerInstance"]:
"""List sqlServerInstance resources in the subscription.
List sqlServerInstance resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlServerInstance or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlServerInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlServerInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/sqlServerInstances"}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SqlServerInstance"]:
"""List sqlServerInstance resources in the resource group.
Gets all sqlServerInstances in a resource group.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlServerInstance or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlServerInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlServerInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances"
}
@distributed_trace
def get(self, resource_group_name: str, sql_server_instance_name: str, **kwargs: Any) -> _models.SqlServerInstance:
"""Retrieves a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
def _create_initial(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: Union[_models.SqlServerInstance, IO],
**kwargs: Any
) -> _models.SqlServerInstance:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(sql_server_instance, (IO, bytes)):
_content = sql_server_instance
else:
_json = self._serialize.body(sql_server_instance, "SqlServerInstance")
request = build_create_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
@overload
def begin_create(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: _models.SqlServerInstance,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.SqlServerInstance]:
"""Creates or replaces a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param sql_server_instance: The SQL Server Instance to be created or updated. Required.
:type sql_server_instance: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either SqlServerInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.SqlServerInstance]:
"""Creates or replaces a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param sql_server_instance: The SQL Server Instance to be created or updated. Required.
:type sql_server_instance: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either SqlServerInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: Union[_models.SqlServerInstance, IO],
**kwargs: Any
) -> LROPoller[_models.SqlServerInstance]:
"""Creates or replaces a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param sql_server_instance: The SQL Server Instance to be created or updated. Is either a model
type or a IO type. Required.
:type sql_server_instance: ~azure.mgmt.azurearcdata.models.SqlServerInstance or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either SqlServerInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_initial(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
sql_server_instance=sql_server_instance,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, sql_server_instance_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
@distributed_trace
def begin_delete(self, resource_group_name: str, sql_server_instance_name: str, **kwargs: Any) -> LROPoller[None]:
"""Deletes a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
@overload
def update(
self,
resource_group_name: str,
sql_server_instance_name: str,
parameters: _models.SqlServerInstanceUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlServerInstance:
"""Updates a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param parameters: The SQL Server Instance. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlServerInstanceUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
sql_server_instance_name: str,
parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlServerInstance:
"""Updates a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param parameters: The SQL Server Instance. Required.
:type parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
sql_server_instance_name: str,
parameters: Union[_models.SqlServerInstanceUpdate, IO],
**kwargs: Any
) -> _models.SqlServerInstance:
"""Updates a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param parameters: The SQL Server Instance. Is either a model type or a IO type. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlServerInstanceUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IO, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "SqlServerInstanceUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/operations/_sql_server_instances_operations.py
|
_sql_server_instances_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/sqlServerInstances"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, sql_server_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlServerInstanceName": _SERIALIZER.url("sql_server_instance_name", sql_server_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str, sql_server_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlServerInstanceName": _SERIALIZER.url("sql_server_instance_name", sql_server_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, sql_server_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlServerInstanceName": _SERIALIZER.url("sql_server_instance_name", sql_server_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, sql_server_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlServerInstanceName": _SERIALIZER.url("sql_server_instance_name", sql_server_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
class SqlServerInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.AzureArcDataManagementClient`'s
:attr:`sql_server_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> Iterable["_models.SqlServerInstance"]:
"""List sqlServerInstance resources in the subscription.
List sqlServerInstance resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlServerInstance or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlServerInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlServerInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/sqlServerInstances"}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SqlServerInstance"]:
"""List sqlServerInstance resources in the resource group.
Gets all sqlServerInstances in a resource group.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlServerInstance or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlServerInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlServerInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances"
}
@distributed_trace
def get(self, resource_group_name: str, sql_server_instance_name: str, **kwargs: Any) -> _models.SqlServerInstance:
"""Retrieves a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
def _create_initial(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: Union[_models.SqlServerInstance, IO],
**kwargs: Any
) -> _models.SqlServerInstance:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(sql_server_instance, (IO, bytes)):
_content = sql_server_instance
else:
_json = self._serialize.body(sql_server_instance, "SqlServerInstance")
request = build_create_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
@overload
def begin_create(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: _models.SqlServerInstance,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.SqlServerInstance]:
"""Creates or replaces a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param sql_server_instance: The SQL Server Instance to be created or updated. Required.
:type sql_server_instance: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either SqlServerInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.SqlServerInstance]:
"""Creates or replaces a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param sql_server_instance: The SQL Server Instance to be created or updated. Required.
:type sql_server_instance: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either SqlServerInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: Union[_models.SqlServerInstance, IO],
**kwargs: Any
) -> LROPoller[_models.SqlServerInstance]:
"""Creates or replaces a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param sql_server_instance: The SQL Server Instance to be created or updated. Is either a model
type or a IO type. Required.
:type sql_server_instance: ~azure.mgmt.azurearcdata.models.SqlServerInstance or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either SqlServerInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_initial(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
sql_server_instance=sql_server_instance,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, sql_server_instance_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
@distributed_trace
def begin_delete(self, resource_group_name: str, sql_server_instance_name: str, **kwargs: Any) -> LROPoller[None]:
"""Deletes a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
@overload
def update(
self,
resource_group_name: str,
sql_server_instance_name: str,
parameters: _models.SqlServerInstanceUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlServerInstance:
"""Updates a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param parameters: The SQL Server Instance. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlServerInstanceUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
sql_server_instance_name: str,
parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlServerInstance:
"""Updates a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param parameters: The SQL Server Instance. Required.
:type parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
sql_server_instance_name: str,
parameters: Union[_models.SqlServerInstanceUpdate, IO],
**kwargs: Any
) -> _models.SqlServerInstance:
"""Updates a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param parameters: The SQL Server Instance. Is either a model type or a IO type. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlServerInstanceUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IO, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "SqlServerInstanceUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
| 0.507812 | 0.085366 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/sqlManagedInstances"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, sql_managed_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlManagedInstanceName": _SERIALIZER.url("sql_managed_instance_name", sql_managed_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str, sql_managed_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlManagedInstanceName": _SERIALIZER.url("sql_managed_instance_name", sql_managed_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, sql_managed_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlManagedInstanceName": _SERIALIZER.url("sql_managed_instance_name", sql_managed_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, sql_managed_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlManagedInstanceName": _SERIALIZER.url("sql_managed_instance_name", sql_managed_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
class SqlManagedInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.AzureArcDataManagementClient`'s
:attr:`sql_managed_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> Iterable["_models.SqlManagedInstance"]:
"""List sqlManagedInstance resources in the subscription.
List sqlManagedInstance resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlManagedInstance or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlManagedInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlManagedInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/sqlManagedInstances"}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SqlManagedInstance"]:
"""List sqlManagedInstance resources in the resource group.
Gets all sqlManagedInstances in a resource group.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlManagedInstance or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlManagedInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlManagedInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances"
}
@distributed_trace
def get(
self, resource_group_name: str, sql_managed_instance_name: str, **kwargs: Any
) -> _models.SqlManagedInstance:
"""Retrieves a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
def _create_initial(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: Union[_models.SqlManagedInstance, IO],
**kwargs: Any
) -> _models.SqlManagedInstance:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(sql_managed_instance, (IO, bytes)):
_content = sql_managed_instance
else:
_json = self._serialize.body(sql_managed_instance, "SqlManagedInstance")
request = build_create_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
@overload
def begin_create(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: _models.SqlManagedInstance,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.SqlManagedInstance]:
"""Creates or replaces a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param sql_managed_instance: The SQL Managed Instance to be created or updated. Required.
:type sql_managed_instance: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either SqlManagedInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.SqlManagedInstance]:
"""Creates or replaces a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param sql_managed_instance: The SQL Managed Instance to be created or updated. Required.
:type sql_managed_instance: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either SqlManagedInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: Union[_models.SqlManagedInstance, IO],
**kwargs: Any
) -> LROPoller[_models.SqlManagedInstance]:
"""Creates or replaces a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param sql_managed_instance: The SQL Managed Instance to be created or updated. Is either a
model type or a IO type. Required.
:type sql_managed_instance: ~azure.mgmt.azurearcdata.models.SqlManagedInstance or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either SqlManagedInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_initial(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
sql_managed_instance=sql_managed_instance,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, sql_managed_instance_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
@distributed_trace
def begin_delete(self, resource_group_name: str, sql_managed_instance_name: str, **kwargs: Any) -> LROPoller[None]:
"""Deletes a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
@overload
def update(
self,
resource_group_name: str,
sql_managed_instance_name: str,
parameters: _models.SqlManagedInstanceUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlManagedInstance:
"""Updates a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param parameters: The SQL Managed Instance. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
sql_managed_instance_name: str,
parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlManagedInstance:
"""Updates a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param parameters: The SQL Managed Instance. Required.
:type parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
sql_managed_instance_name: str,
parameters: Union[_models.SqlManagedInstanceUpdate, IO],
**kwargs: Any
) -> _models.SqlManagedInstance:
"""Updates a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param parameters: The SQL Managed Instance. Is either a model type or a IO type. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IO, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "SqlManagedInstanceUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/operations/_sql_managed_instances_operations.py
|
_sql_managed_instances_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/sqlManagedInstances"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, sql_managed_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlManagedInstanceName": _SERIALIZER.url("sql_managed_instance_name", sql_managed_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str, sql_managed_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlManagedInstanceName": _SERIALIZER.url("sql_managed_instance_name", sql_managed_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, sql_managed_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlManagedInstanceName": _SERIALIZER.url("sql_managed_instance_name", sql_managed_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, sql_managed_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"sqlManagedInstanceName": _SERIALIZER.url("sql_managed_instance_name", sql_managed_instance_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
class SqlManagedInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.AzureArcDataManagementClient`'s
:attr:`sql_managed_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> Iterable["_models.SqlManagedInstance"]:
"""List sqlManagedInstance resources in the subscription.
List sqlManagedInstance resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlManagedInstance or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlManagedInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlManagedInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/sqlManagedInstances"}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SqlManagedInstance"]:
"""List sqlManagedInstance resources in the resource group.
Gets all sqlManagedInstances in a resource group.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlManagedInstance or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlManagedInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlManagedInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances"
}
@distributed_trace
def get(
self, resource_group_name: str, sql_managed_instance_name: str, **kwargs: Any
) -> _models.SqlManagedInstance:
"""Retrieves a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
def _create_initial(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: Union[_models.SqlManagedInstance, IO],
**kwargs: Any
) -> _models.SqlManagedInstance:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(sql_managed_instance, (IO, bytes)):
_content = sql_managed_instance
else:
_json = self._serialize.body(sql_managed_instance, "SqlManagedInstance")
request = build_create_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
@overload
def begin_create(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: _models.SqlManagedInstance,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.SqlManagedInstance]:
"""Creates or replaces a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param sql_managed_instance: The SQL Managed Instance to be created or updated. Required.
:type sql_managed_instance: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either SqlManagedInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.SqlManagedInstance]:
"""Creates or replaces a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param sql_managed_instance: The SQL Managed Instance to be created or updated. Required.
:type sql_managed_instance: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either SqlManagedInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: Union[_models.SqlManagedInstance, IO],
**kwargs: Any
) -> LROPoller[_models.SqlManagedInstance]:
"""Creates or replaces a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param sql_managed_instance: The SQL Managed Instance to be created or updated. Is either a
model type or a IO type. Required.
:type sql_managed_instance: ~azure.mgmt.azurearcdata.models.SqlManagedInstance or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either SqlManagedInstance or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_initial(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
sql_managed_instance=sql_managed_instance,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, sql_managed_instance_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
@distributed_trace
def begin_delete(self, resource_group_name: str, sql_managed_instance_name: str, **kwargs: Any) -> LROPoller[None]:
"""Deletes a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
@overload
def update(
self,
resource_group_name: str,
sql_managed_instance_name: str,
parameters: _models.SqlManagedInstanceUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlManagedInstance:
"""Updates a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param parameters: The SQL Managed Instance. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
sql_managed_instance_name: str,
parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlManagedInstance:
"""Updates a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param parameters: The SQL Managed Instance. Required.
:type parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
sql_managed_instance_name: str,
parameters: Union[_models.SqlManagedInstanceUpdate, IO],
**kwargs: Any
) -> _models.SqlManagedInstance:
"""Updates a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param parameters: The SQL Managed Instance. Is either a model type or a IO type. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IO, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "SqlManagedInstanceUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
| 0.50708 | 0.085518 |
import sys
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/providers/Microsoft.AzureArcData/operations")
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.AzureArcDataManagementClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> Iterable["_models.Operation"]:
"""Lists all of the available Azure Data Services on Azure Arc API operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Operation or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.Operation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {"url": "/providers/Microsoft.AzureArcData/operations"}
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/operations/_operations.py
|
_operations.py
|
import sys
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/providers/Microsoft.AzureArcData/operations")
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.AzureArcDataManagementClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> Iterable["_models.Operation"]:
"""Lists all of the available Azure Data Services on Azure Arc API operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Operation or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.Operation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {"url": "/providers/Microsoft.AzureArcData/operations"}
| 0.635675 | 0.077274 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(
resource_group_name: str, data_controller_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
"activeDirectoryConnectorName": _SERIALIZER.url(
"active_directory_connector_name", active_directory_connector_name, "str"
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
"activeDirectoryConnectorName": _SERIALIZER.url(
"active_directory_connector_name", active_directory_connector_name, "str"
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
"activeDirectoryConnectorName": _SERIALIZER.url(
"active_directory_connector_name", active_directory_connector_name, "str"
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class ActiveDirectoryConnectorsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.AzureArcDataManagementClient`'s
:attr:`active_directory_connectors` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> Iterable["_models.ActiveDirectoryConnectorResource"]:
"""List the active directory connectors associated with the given data controller.
List the active directory connectors associated with the given data controller.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either ActiveDirectoryConnectorResource or the result of
cls(response)
:rtype:
~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ActiveDirectoryConnectorListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ActiveDirectoryConnectorListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors"
}
def _create_initial(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: Union[_models.ActiveDirectoryConnectorResource, IO],
**kwargs: Any
) -> _models.ActiveDirectoryConnectorResource:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ActiveDirectoryConnectorResource] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(active_directory_connector_resource, (IO, bytes)):
_content = active_directory_connector_resource
else:
_json = self._serialize.body(active_directory_connector_resource, "ActiveDirectoryConnectorResource")
request = build_create_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
@overload
def begin_create(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: _models.ActiveDirectoryConnectorResource,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.ActiveDirectoryConnectorResource]:
"""Creates or replaces an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:param active_directory_connector_resource: desc. Required.
:type active_directory_connector_resource:
~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either ActiveDirectoryConnectorResource or the
result of cls(response)
:rtype:
~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.ActiveDirectoryConnectorResource]:
"""Creates or replaces an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:param active_directory_connector_resource: desc. Required.
:type active_directory_connector_resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either ActiveDirectoryConnectorResource or the
result of cls(response)
:rtype:
~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: Union[_models.ActiveDirectoryConnectorResource, IO],
**kwargs: Any
) -> LROPoller[_models.ActiveDirectoryConnectorResource]:
"""Creates or replaces an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:param active_directory_connector_resource: desc. Is either a model type or a IO type.
Required.
:type active_directory_connector_resource:
~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either ActiveDirectoryConnectorResource or the
result of cls(response)
:rtype:
~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ActiveDirectoryConnectorResource] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_initial(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
active_directory_connector_resource=active_directory_connector_resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, data_controller_name: str, active_directory_connector_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
@distributed_trace
def begin_delete(
self, resource_group_name: str, data_controller_name: str, active_directory_connector_name: str, **kwargs: Any
) -> LROPoller[None]:
"""Deletes an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
@distributed_trace
def get(
self, resource_group_name: str, data_controller_name: str, active_directory_connector_name: str, **kwargs: Any
) -> _models.ActiveDirectoryConnectorResource:
"""Retrieves an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ActiveDirectoryConnectorResource or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ActiveDirectoryConnectorResource] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/operations/_active_directory_connectors_operations.py
|
_active_directory_connectors_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(
resource_group_name: str, data_controller_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
"activeDirectoryConnectorName": _SERIALIZER.url(
"active_directory_connector_name", active_directory_connector_name, "str"
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
"activeDirectoryConnectorName": _SERIALIZER.url(
"active_directory_connector_name", active_directory_connector_name, "str"
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
"activeDirectoryConnectorName": _SERIALIZER.url(
"active_directory_connector_name", active_directory_connector_name, "str"
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class ActiveDirectoryConnectorsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.AzureArcDataManagementClient`'s
:attr:`active_directory_connectors` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> Iterable["_models.ActiveDirectoryConnectorResource"]:
"""List the active directory connectors associated with the given data controller.
List the active directory connectors associated with the given data controller.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either ActiveDirectoryConnectorResource or the result of
cls(response)
:rtype:
~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ActiveDirectoryConnectorListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ActiveDirectoryConnectorListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors"
}
def _create_initial(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: Union[_models.ActiveDirectoryConnectorResource, IO],
**kwargs: Any
) -> _models.ActiveDirectoryConnectorResource:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ActiveDirectoryConnectorResource] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(active_directory_connector_resource, (IO, bytes)):
_content = active_directory_connector_resource
else:
_json = self._serialize.body(active_directory_connector_resource, "ActiveDirectoryConnectorResource")
request = build_create_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
@overload
def begin_create(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: _models.ActiveDirectoryConnectorResource,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.ActiveDirectoryConnectorResource]:
"""Creates or replaces an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:param active_directory_connector_resource: desc. Required.
:type active_directory_connector_resource:
~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either ActiveDirectoryConnectorResource or the
result of cls(response)
:rtype:
~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.ActiveDirectoryConnectorResource]:
"""Creates or replaces an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:param active_directory_connector_resource: desc. Required.
:type active_directory_connector_resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either ActiveDirectoryConnectorResource or the
result of cls(response)
:rtype:
~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: Union[_models.ActiveDirectoryConnectorResource, IO],
**kwargs: Any
) -> LROPoller[_models.ActiveDirectoryConnectorResource]:
"""Creates or replaces an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:param active_directory_connector_resource: desc. Is either a model type or a IO type.
Required.
:type active_directory_connector_resource:
~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either ActiveDirectoryConnectorResource or the
result of cls(response)
:rtype:
~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ActiveDirectoryConnectorResource] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_initial(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
active_directory_connector_resource=active_directory_connector_resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, data_controller_name: str, active_directory_connector_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
@distributed_trace
def begin_delete(
self, resource_group_name: str, data_controller_name: str, active_directory_connector_name: str, **kwargs: Any
) -> LROPoller[None]:
"""Deletes an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
@distributed_trace
def get(
self, resource_group_name: str, data_controller_name: str, active_directory_connector_name: str, **kwargs: Any
) -> _models.ActiveDirectoryConnectorResource:
"""Retrieves an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ActiveDirectoryConnectorResource or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ActiveDirectoryConnectorResource] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
| 0.550607 | 0.068382 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_list_in_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/dataControllers"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_in_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_put_data_controller_request(
resource_group_name: str, data_controller_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_data_controller_request(
resource_group_name: str, data_controller_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_data_controller_request(
resource_group_name: str, data_controller_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_patch_data_controller_request(
resource_group_name: str, data_controller_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
class DataControllersOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.AzureArcDataManagementClient`'s
:attr:`data_controllers` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_in_subscription(self, **kwargs: Any) -> Iterable["_models.DataControllerResource"]:
"""List dataController resources in the subscription.
List dataController resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PageOfDataControllerResource] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_in_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_in_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PageOfDataControllerResource", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_in_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/dataControllers"
}
@distributed_trace
def list_in_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.DataControllerResource"]:
"""List dataController resources in the resource group.
List dataController resources in the resource group.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PageOfDataControllerResource] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_in_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_in_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PageOfDataControllerResource", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_in_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers"
}
def _put_data_controller_initial(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerResource, IO],
**kwargs: Any
) -> _models.DataControllerResource:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(data_controller_resource, (IO, bytes)):
_content = data_controller_resource
else:
_json = self._serialize.body(data_controller_resource, "DataControllerResource")
request = build_put_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._put_data_controller_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_put_data_controller_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@overload
def begin_put_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: _models.DataControllerResource,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.DataControllerResource]:
"""Creates or replaces a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: desc. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerResource
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_put_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.DataControllerResource]:
"""Creates or replaces a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: desc. Required.
:type data_controller_resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_put_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerResource, IO],
**kwargs: Any
) -> LROPoller[_models.DataControllerResource]:
"""Creates or replaces a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: desc. Is either a model type or a IO type. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerResource or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._put_data_controller_initial(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
data_controller_resource=data_controller_resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_put_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
def _delete_data_controller_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_data_controller_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_data_controller_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@distributed_trace
def begin_delete_data_controller(
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> LROPoller[None]:
"""Deletes a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_data_controller_initial( # type: ignore
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@distributed_trace
def get_data_controller(
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> _models.DataControllerResource:
"""Retrieves a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DataControllerResource or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.DataControllerResource
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
request = build_get_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get_data_controller.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
def _patch_data_controller_initial(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerUpdate, IO],
**kwargs: Any
) -> Optional[_models.DataControllerResource]:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[Optional[_models.DataControllerResource]] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(data_controller_resource, (IO, bytes)):
_content = data_controller_resource
else:
_json = self._serialize.body(data_controller_resource, "DataControllerUpdate")
request = build_patch_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._patch_data_controller_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
deserialized = None
if response.status_code == 200:
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
_patch_data_controller_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@overload
def begin_patch_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: _models.DataControllerUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.DataControllerResource]:
"""Updates a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: The update data controller resource. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_patch_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.DataControllerResource]:
"""Updates a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: The update data controller resource. Required.
:type data_controller_resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_patch_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerUpdate, IO],
**kwargs: Any
) -> LROPoller[_models.DataControllerResource]:
"""Updates a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: The update data controller resource. Is either a model type or
a IO type. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._patch_data_controller_initial(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
data_controller_resource=data_controller_resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_patch_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/operations/_data_controllers_operations.py
|
_data_controllers_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_list_in_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/dataControllers"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_in_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_put_data_controller_request(
resource_group_name: str, data_controller_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_data_controller_request(
resource_group_name: str, data_controller_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_data_controller_request(
resource_group_name: str, data_controller_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_patch_data_controller_request(
resource_group_name: str, data_controller_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2022-03-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
"dataControllerName": _SERIALIZER.url("data_controller_name", data_controller_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
class DataControllersOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.AzureArcDataManagementClient`'s
:attr:`data_controllers` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_in_subscription(self, **kwargs: Any) -> Iterable["_models.DataControllerResource"]:
"""List dataController resources in the subscription.
List dataController resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PageOfDataControllerResource] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_in_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_in_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PageOfDataControllerResource", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_in_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/dataControllers"
}
@distributed_trace
def list_in_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.DataControllerResource"]:
"""List dataController resources in the resource group.
List dataController resources in the resource group.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PageOfDataControllerResource] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_in_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_in_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PageOfDataControllerResource", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_in_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers"
}
def _put_data_controller_initial(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerResource, IO],
**kwargs: Any
) -> _models.DataControllerResource:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(data_controller_resource, (IO, bytes)):
_content = data_controller_resource
else:
_json = self._serialize.body(data_controller_resource, "DataControllerResource")
request = build_put_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._put_data_controller_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_put_data_controller_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@overload
def begin_put_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: _models.DataControllerResource,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.DataControllerResource]:
"""Creates or replaces a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: desc. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerResource
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_put_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.DataControllerResource]:
"""Creates or replaces a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: desc. Required.
:type data_controller_resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_put_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerResource, IO],
**kwargs: Any
) -> LROPoller[_models.DataControllerResource]:
"""Creates or replaces a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: desc. Is either a model type or a IO type. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerResource or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._put_data_controller_initial(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
data_controller_resource=data_controller_resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_put_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
def _delete_data_controller_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_data_controller_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_data_controller_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@distributed_trace
def begin_delete_data_controller(
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> LROPoller[None]:
"""Deletes a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_data_controller_initial( # type: ignore
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@distributed_trace
def get_data_controller(
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> _models.DataControllerResource:
"""Retrieves a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DataControllerResource or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.DataControllerResource
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
request = build_get_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get_data_controller.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
def _patch_data_controller_initial(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerUpdate, IO],
**kwargs: Any
) -> Optional[_models.DataControllerResource]:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[Optional[_models.DataControllerResource]] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(data_controller_resource, (IO, bytes)):
_content = data_controller_resource
else:
_json = self._serialize.body(data_controller_resource, "DataControllerUpdate")
request = build_patch_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._patch_data_controller_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
deserialized = None
if response.status_code == 200:
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
_patch_data_controller_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@overload
def begin_patch_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: _models.DataControllerUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.DataControllerResource]:
"""Updates a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: The update data controller resource. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_patch_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.DataControllerResource]:
"""Updates a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: The update data controller resource. Required.
:type data_controller_resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_patch_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerUpdate, IO],
**kwargs: Any
) -> LROPoller[_models.DataControllerResource]:
"""Updates a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: The update data controller resource. Is either a model type or
a IO type. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either DataControllerResource or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._patch_data_controller_initial(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
data_controller_resource=data_controller_resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_patch_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
| 0.588061 | 0.085061 |
import sys
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, AsyncARMChallengeAuthenticationPolicy
from .._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class AzureArcDataManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureArcDataManagementClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the Azure subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2022-03-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(AzureArcDataManagementClientConfiguration, self).__init__(**kwargs)
api_version: Literal["2022-03-01-preview"] = kwargs.pop("api_version", "2022-03-01-preview")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-azurearcdata/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/aio/_configuration.py
|
_configuration.py
|
import sys
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, AsyncARMChallengeAuthenticationPolicy
from .._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class AzureArcDataManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureArcDataManagementClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the Azure subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2022-03-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(AzureArcDataManagementClientConfiguration, self).__init__(**kwargs)
api_version: Literal["2022-03-01-preview"] = kwargs.pop("api_version", "2022-03-01-preview")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-azurearcdata/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
| 0.555676 | 0.080177 |
from copy import deepcopy
from typing import Any, Awaitable, TYPE_CHECKING
from azure.core.rest import AsyncHttpResponse, HttpRequest
from azure.mgmt.core import AsyncARMPipelineClient
from .. import models as _models
from .._serialization import Deserializer, Serializer
from ._configuration import AzureArcDataManagementClientConfiguration
from .operations import (
ActiveDirectoryConnectorsOperations,
DataControllersOperations,
Operations,
PostgresInstancesOperations,
SqlManagedInstancesOperations,
SqlServerInstancesOperations,
)
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class AzureArcDataManagementClient: # pylint: disable=client-accepts-api-version-keyword
"""The AzureArcData management API provides a RESTful set of web APIs to manage Azure Data
Services on Azure Arc Resources.
:ivar operations: Operations operations
:vartype operations: azure.mgmt.azurearcdata.aio.operations.Operations
:ivar sql_managed_instances: SqlManagedInstancesOperations operations
:vartype sql_managed_instances:
azure.mgmt.azurearcdata.aio.operations.SqlManagedInstancesOperations
:ivar sql_server_instances: SqlServerInstancesOperations operations
:vartype sql_server_instances:
azure.mgmt.azurearcdata.aio.operations.SqlServerInstancesOperations
:ivar data_controllers: DataControllersOperations operations
:vartype data_controllers: azure.mgmt.azurearcdata.aio.operations.DataControllersOperations
:ivar active_directory_connectors: ActiveDirectoryConnectorsOperations operations
:vartype active_directory_connectors:
azure.mgmt.azurearcdata.aio.operations.ActiveDirectoryConnectorsOperations
:ivar postgres_instances: PostgresInstancesOperations operations
:vartype postgres_instances: azure.mgmt.azurearcdata.aio.operations.PostgresInstancesOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the Azure subscription. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2022-03-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
"""
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = AzureArcDataManagementClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.sql_managed_instances = SqlManagedInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.sql_server_instances = SqlServerInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.data_controllers = DataControllersOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.active_directory_connectors = ActiveDirectoryConnectorsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.postgres_instances = PostgresInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client._send_request(request)
<AsyncHttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.AsyncHttpResponse
"""
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()
async def __aenter__(self) -> "AzureArcDataManagementClient":
await self._client.__aenter__()
return self
async def __aexit__(self, *exc_details) -> None:
await self._client.__aexit__(*exc_details)
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/aio/_azure_arc_data_management_client.py
|
_azure_arc_data_management_client.py
|
from copy import deepcopy
from typing import Any, Awaitable, TYPE_CHECKING
from azure.core.rest import AsyncHttpResponse, HttpRequest
from azure.mgmt.core import AsyncARMPipelineClient
from .. import models as _models
from .._serialization import Deserializer, Serializer
from ._configuration import AzureArcDataManagementClientConfiguration
from .operations import (
ActiveDirectoryConnectorsOperations,
DataControllersOperations,
Operations,
PostgresInstancesOperations,
SqlManagedInstancesOperations,
SqlServerInstancesOperations,
)
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class AzureArcDataManagementClient: # pylint: disable=client-accepts-api-version-keyword
"""The AzureArcData management API provides a RESTful set of web APIs to manage Azure Data
Services on Azure Arc Resources.
:ivar operations: Operations operations
:vartype operations: azure.mgmt.azurearcdata.aio.operations.Operations
:ivar sql_managed_instances: SqlManagedInstancesOperations operations
:vartype sql_managed_instances:
azure.mgmt.azurearcdata.aio.operations.SqlManagedInstancesOperations
:ivar sql_server_instances: SqlServerInstancesOperations operations
:vartype sql_server_instances:
azure.mgmt.azurearcdata.aio.operations.SqlServerInstancesOperations
:ivar data_controllers: DataControllersOperations operations
:vartype data_controllers: azure.mgmt.azurearcdata.aio.operations.DataControllersOperations
:ivar active_directory_connectors: ActiveDirectoryConnectorsOperations operations
:vartype active_directory_connectors:
azure.mgmt.azurearcdata.aio.operations.ActiveDirectoryConnectorsOperations
:ivar postgres_instances: PostgresInstancesOperations operations
:vartype postgres_instances: azure.mgmt.azurearcdata.aio.operations.PostgresInstancesOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the Azure subscription. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2022-03-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
"""
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = AzureArcDataManagementClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.sql_managed_instances = SqlManagedInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.sql_server_instances = SqlServerInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.data_controllers = DataControllersOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.active_directory_connectors = ActiveDirectoryConnectorsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.postgres_instances = PostgresInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client._send_request(request)
<AsyncHttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.AsyncHttpResponse
"""
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()
async def __aenter__(self) -> "AzureArcDataManagementClient":
await self._client.__aenter__()
return self
async def __aexit__(self, *exc_details) -> None:
await self._client.__aexit__(*exc_details)
| 0.819641 | 0.144059 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._postgres_instances_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_resource_group_request,
build_list_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class PostgresInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.aio.AzureArcDataManagementClient`'s
:attr:`postgres_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> AsyncIterable["_models.PostgresInstance"]:
"""List postgres Instance resources in the subscription.
List postgres Instance resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either PostgresInstance or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PostgresInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PostgresInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/postgresInstances"}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.PostgresInstance"]:
"""List postgres Instance resources in the resource group.
Get a postgres Instances list by Resource group name.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either PostgresInstance or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PostgresInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PostgresInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, postgres_instance_name: str, **kwargs: Any
) -> _models.PostgresInstance:
"""Retrieves a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
async def _create_initial(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: Union[_models.PostgresInstance, IO],
**kwargs: Any
) -> _models.PostgresInstance:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(resource, (IO, bytes)):
_content = resource
else:
_json = self._serialize.body(resource, "PostgresInstance")
request = build_create_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
@overload
async def begin_create(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: _models.PostgresInstance,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.PostgresInstance]:
"""Creates or replaces a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param resource: The postgres instance. Required.
:type resource: ~azure.mgmt.azurearcdata.models.PostgresInstance
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either PostgresInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.PostgresInstance]:
"""Creates or replaces a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param resource: The postgres instance. Required.
:type resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either PostgresInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: Union[_models.PostgresInstance, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.PostgresInstance]:
"""Creates or replaces a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param resource: The postgres instance. Is either a model type or a IO type. Required.
:type resource: ~azure.mgmt.azurearcdata.models.PostgresInstance or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either PostgresInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_initial(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
resource=resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, postgres_instance_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, postgres_instance_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Deletes a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
@overload
async def update(
self,
resource_group_name: str,
postgres_instance_name: str,
parameters: _models.PostgresInstanceUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.PostgresInstance:
"""Updates a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param parameters: The Postgres Instance. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.PostgresInstanceUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
postgres_instance_name: str,
parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.PostgresInstance:
"""Updates a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param parameters: The Postgres Instance. Required.
:type parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
postgres_instance_name: str,
parameters: Union[_models.PostgresInstanceUpdate, IO],
**kwargs: Any
) -> _models.PostgresInstance:
"""Updates a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param parameters: The Postgres Instance. Is either a model type or a IO type. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.PostgresInstanceUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IO, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "PostgresInstanceUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/aio/operations/_postgres_instances_operations.py
|
_postgres_instances_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._postgres_instances_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_resource_group_request,
build_list_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class PostgresInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.aio.AzureArcDataManagementClient`'s
:attr:`postgres_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> AsyncIterable["_models.PostgresInstance"]:
"""List postgres Instance resources in the subscription.
List postgres Instance resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either PostgresInstance or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PostgresInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PostgresInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/postgresInstances"}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.PostgresInstance"]:
"""List postgres Instance resources in the resource group.
Get a postgres Instances list by Resource group name.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either PostgresInstance or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PostgresInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PostgresInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, postgres_instance_name: str, **kwargs: Any
) -> _models.PostgresInstance:
"""Retrieves a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
async def _create_initial(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: Union[_models.PostgresInstance, IO],
**kwargs: Any
) -> _models.PostgresInstance:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(resource, (IO, bytes)):
_content = resource
else:
_json = self._serialize.body(resource, "PostgresInstance")
request = build_create_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
@overload
async def begin_create(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: _models.PostgresInstance,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.PostgresInstance]:
"""Creates or replaces a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param resource: The postgres instance. Required.
:type resource: ~azure.mgmt.azurearcdata.models.PostgresInstance
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either PostgresInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.PostgresInstance]:
"""Creates or replaces a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param resource: The postgres instance. Required.
:type resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either PostgresInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create(
self,
resource_group_name: str,
postgres_instance_name: str,
resource: Union[_models.PostgresInstance, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.PostgresInstance]:
"""Creates or replaces a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param resource: The postgres instance. Is either a model type or a IO type. Required.
:type resource: ~azure.mgmt.azurearcdata.models.PostgresInstance or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either PostgresInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.PostgresInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_initial(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
resource=resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, postgres_instance_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, postgres_instance_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Deletes a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
@overload
async def update(
self,
resource_group_name: str,
postgres_instance_name: str,
parameters: _models.PostgresInstanceUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.PostgresInstance:
"""Updates a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param parameters: The Postgres Instance. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.PostgresInstanceUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
postgres_instance_name: str,
parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.PostgresInstance:
"""Updates a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param parameters: The Postgres Instance. Required.
:type parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
postgres_instance_name: str,
parameters: Union[_models.PostgresInstanceUpdate, IO],
**kwargs: Any
) -> _models.PostgresInstance:
"""Updates a postgres Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param postgres_instance_name: Name of Postgres Instance. Required.
:type postgres_instance_name: str
:param parameters: The Postgres Instance. Is either a model type or a IO type. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.PostgresInstanceUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: PostgresInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.PostgresInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.PostgresInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IO, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "PostgresInstanceUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
postgres_instance_name=postgres_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("PostgresInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/postgresInstances/{postgresInstanceName}"
}
| 0.673836 | 0.076132 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._sql_server_instances_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_resource_group_request,
build_list_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class SqlServerInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.aio.AzureArcDataManagementClient`'s
:attr:`sql_server_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> AsyncIterable["_models.SqlServerInstance"]:
"""List sqlServerInstance resources in the subscription.
List sqlServerInstance resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlServerInstance or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlServerInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlServerInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/sqlServerInstances"}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.SqlServerInstance"]:
"""List sqlServerInstance resources in the resource group.
Gets all sqlServerInstances in a resource group.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlServerInstance or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlServerInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlServerInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, sql_server_instance_name: str, **kwargs: Any
) -> _models.SqlServerInstance:
"""Retrieves a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
async def _create_initial(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: Union[_models.SqlServerInstance, IO],
**kwargs: Any
) -> _models.SqlServerInstance:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(sql_server_instance, (IO, bytes)):
_content = sql_server_instance
else:
_json = self._serialize.body(sql_server_instance, "SqlServerInstance")
request = build_create_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
@overload
async def begin_create(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: _models.SqlServerInstance,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.SqlServerInstance]:
"""Creates or replaces a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param sql_server_instance: The SQL Server Instance to be created or updated. Required.
:type sql_server_instance: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either SqlServerInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.SqlServerInstance]:
"""Creates or replaces a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param sql_server_instance: The SQL Server Instance to be created or updated. Required.
:type sql_server_instance: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either SqlServerInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: Union[_models.SqlServerInstance, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.SqlServerInstance]:
"""Creates or replaces a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param sql_server_instance: The SQL Server Instance to be created or updated. Is either a model
type or a IO type. Required.
:type sql_server_instance: ~azure.mgmt.azurearcdata.models.SqlServerInstance or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either SqlServerInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_initial(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
sql_server_instance=sql_server_instance,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, sql_server_instance_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, sql_server_instance_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Deletes a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
@overload
async def update(
self,
resource_group_name: str,
sql_server_instance_name: str,
parameters: _models.SqlServerInstanceUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlServerInstance:
"""Updates a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param parameters: The SQL Server Instance. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlServerInstanceUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
sql_server_instance_name: str,
parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlServerInstance:
"""Updates a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param parameters: The SQL Server Instance. Required.
:type parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
sql_server_instance_name: str,
parameters: Union[_models.SqlServerInstanceUpdate, IO],
**kwargs: Any
) -> _models.SqlServerInstance:
"""Updates a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param parameters: The SQL Server Instance. Is either a model type or a IO type. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlServerInstanceUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IO, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "SqlServerInstanceUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/aio/operations/_sql_server_instances_operations.py
|
_sql_server_instances_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._sql_server_instances_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_resource_group_request,
build_list_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class SqlServerInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.aio.AzureArcDataManagementClient`'s
:attr:`sql_server_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> AsyncIterable["_models.SqlServerInstance"]:
"""List sqlServerInstance resources in the subscription.
List sqlServerInstance resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlServerInstance or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlServerInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlServerInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/sqlServerInstances"}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.SqlServerInstance"]:
"""List sqlServerInstance resources in the resource group.
Gets all sqlServerInstances in a resource group.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlServerInstance or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlServerInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlServerInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, sql_server_instance_name: str, **kwargs: Any
) -> _models.SqlServerInstance:
"""Retrieves a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
async def _create_initial(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: Union[_models.SqlServerInstance, IO],
**kwargs: Any
) -> _models.SqlServerInstance:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(sql_server_instance, (IO, bytes)):
_content = sql_server_instance
else:
_json = self._serialize.body(sql_server_instance, "SqlServerInstance")
request = build_create_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
@overload
async def begin_create(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: _models.SqlServerInstance,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.SqlServerInstance]:
"""Creates or replaces a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param sql_server_instance: The SQL Server Instance to be created or updated. Required.
:type sql_server_instance: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either SqlServerInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.SqlServerInstance]:
"""Creates or replaces a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param sql_server_instance: The SQL Server Instance to be created or updated. Required.
:type sql_server_instance: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either SqlServerInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create(
self,
resource_group_name: str,
sql_server_instance_name: str,
sql_server_instance: Union[_models.SqlServerInstance, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.SqlServerInstance]:
"""Creates or replaces a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param sql_server_instance: The SQL Server Instance to be created or updated. Is either a model
type or a IO type. Required.
:type sql_server_instance: ~azure.mgmt.azurearcdata.models.SqlServerInstance or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either SqlServerInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_initial(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
sql_server_instance=sql_server_instance,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, sql_server_instance_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, sql_server_instance_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Deletes a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
@overload
async def update(
self,
resource_group_name: str,
sql_server_instance_name: str,
parameters: _models.SqlServerInstanceUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlServerInstance:
"""Updates a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param parameters: The SQL Server Instance. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlServerInstanceUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
sql_server_instance_name: str,
parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlServerInstance:
"""Updates a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param parameters: The SQL Server Instance. Required.
:type parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
sql_server_instance_name: str,
parameters: Union[_models.SqlServerInstanceUpdate, IO],
**kwargs: Any
) -> _models.SqlServerInstance:
"""Updates a SQL Server Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_server_instance_name: Name of SQL Server Instance. Required.
:type sql_server_instance_name: str
:param parameters: The SQL Server Instance. Is either a model type or a IO type. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlServerInstanceUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlServerInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlServerInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlServerInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IO, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "SqlServerInstanceUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
sql_server_instance_name=sql_server_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlServerInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlServerInstances/{sqlServerInstanceName}"
}
| 0.655997 | 0.071982 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._sql_managed_instances_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_resource_group_request,
build_list_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class SqlManagedInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.aio.AzureArcDataManagementClient`'s
:attr:`sql_managed_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> AsyncIterable["_models.SqlManagedInstance"]:
"""List sqlManagedInstance resources in the subscription.
List sqlManagedInstance resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlManagedInstance or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlManagedInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlManagedInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/sqlManagedInstances"}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.SqlManagedInstance"]:
"""List sqlManagedInstance resources in the resource group.
Gets all sqlManagedInstances in a resource group.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlManagedInstance or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlManagedInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlManagedInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, sql_managed_instance_name: str, **kwargs: Any
) -> _models.SqlManagedInstance:
"""Retrieves a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
async def _create_initial(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: Union[_models.SqlManagedInstance, IO],
**kwargs: Any
) -> _models.SqlManagedInstance:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(sql_managed_instance, (IO, bytes)):
_content = sql_managed_instance
else:
_json = self._serialize.body(sql_managed_instance, "SqlManagedInstance")
request = build_create_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
@overload
async def begin_create(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: _models.SqlManagedInstance,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.SqlManagedInstance]:
"""Creates or replaces a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param sql_managed_instance: The SQL Managed Instance to be created or updated. Required.
:type sql_managed_instance: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either SqlManagedInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.SqlManagedInstance]:
"""Creates or replaces a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param sql_managed_instance: The SQL Managed Instance to be created or updated. Required.
:type sql_managed_instance: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either SqlManagedInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: Union[_models.SqlManagedInstance, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.SqlManagedInstance]:
"""Creates or replaces a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param sql_managed_instance: The SQL Managed Instance to be created or updated. Is either a
model type or a IO type. Required.
:type sql_managed_instance: ~azure.mgmt.azurearcdata.models.SqlManagedInstance or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either SqlManagedInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_initial(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
sql_managed_instance=sql_managed_instance,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, sql_managed_instance_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, sql_managed_instance_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Deletes a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
@overload
async def update(
self,
resource_group_name: str,
sql_managed_instance_name: str,
parameters: _models.SqlManagedInstanceUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlManagedInstance:
"""Updates a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param parameters: The SQL Managed Instance. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
sql_managed_instance_name: str,
parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlManagedInstance:
"""Updates a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param parameters: The SQL Managed Instance. Required.
:type parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
sql_managed_instance_name: str,
parameters: Union[_models.SqlManagedInstanceUpdate, IO],
**kwargs: Any
) -> _models.SqlManagedInstance:
"""Updates a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param parameters: The SQL Managed Instance. Is either a model type or a IO type. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IO, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "SqlManagedInstanceUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/aio/operations/_sql_managed_instances_operations.py
|
_sql_managed_instances_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._sql_managed_instances_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_resource_group_request,
build_list_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class SqlManagedInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.aio.AzureArcDataManagementClient`'s
:attr:`sql_managed_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> AsyncIterable["_models.SqlManagedInstance"]:
"""List sqlManagedInstance resources in the subscription.
List sqlManagedInstance resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlManagedInstance or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlManagedInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlManagedInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/sqlManagedInstances"}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.SqlManagedInstance"]:
"""List sqlManagedInstance resources in the resource group.
Gets all sqlManagedInstances in a resource group.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either SqlManagedInstance or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlManagedInstanceListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("SqlManagedInstanceListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, sql_managed_instance_name: str, **kwargs: Any
) -> _models.SqlManagedInstance:
"""Retrieves a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
async def _create_initial(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: Union[_models.SqlManagedInstance, IO],
**kwargs: Any
) -> _models.SqlManagedInstance:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(sql_managed_instance, (IO, bytes)):
_content = sql_managed_instance
else:
_json = self._serialize.body(sql_managed_instance, "SqlManagedInstance")
request = build_create_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
@overload
async def begin_create(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: _models.SqlManagedInstance,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.SqlManagedInstance]:
"""Creates or replaces a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param sql_managed_instance: The SQL Managed Instance to be created or updated. Required.
:type sql_managed_instance: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either SqlManagedInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.SqlManagedInstance]:
"""Creates or replaces a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param sql_managed_instance: The SQL Managed Instance to be created or updated. Required.
:type sql_managed_instance: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either SqlManagedInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create(
self,
resource_group_name: str,
sql_managed_instance_name: str,
sql_managed_instance: Union[_models.SqlManagedInstance, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.SqlManagedInstance]:
"""Creates or replaces a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param sql_managed_instance: The SQL Managed Instance to be created or updated. Is either a
model type or a IO type. Required.
:type sql_managed_instance: ~azure.mgmt.azurearcdata.models.SqlManagedInstance or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either SqlManagedInstance or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_initial(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
sql_managed_instance=sql_managed_instance,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, sql_managed_instance_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, sql_managed_instance_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Deletes a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
@overload
async def update(
self,
resource_group_name: str,
sql_managed_instance_name: str,
parameters: _models.SqlManagedInstanceUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlManagedInstance:
"""Updates a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param parameters: The SQL Managed Instance. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
sql_managed_instance_name: str,
parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.SqlManagedInstance:
"""Updates a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param parameters: The SQL Managed Instance. Required.
:type parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
sql_managed_instance_name: str,
parameters: Union[_models.SqlManagedInstanceUpdate, IO],
**kwargs: Any
) -> _models.SqlManagedInstance:
"""Updates a SQL Managed Instance resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param sql_managed_instance_name: Name of SQL Managed Instance. Required.
:type sql_managed_instance_name: str
:param parameters: The SQL Managed Instance. Is either a model type or a IO type. Required.
:type parameters: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: SqlManagedInstance or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.SqlManagedInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.SqlManagedInstance] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(parameters, (IO, bytes)):
_content = parameters
else:
_json = self._serialize.body(parameters, "SqlManagedInstanceUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
sql_managed_instance_name=sql_managed_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("SqlManagedInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/sqlManagedInstances/{sqlManagedInstanceName}"
}
| 0.648578 | 0.072178 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._operations import build_list_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.aio.AzureArcDataManagementClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]:
"""Lists all of the available Azure Data Services on Azure Arc API operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Operation or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.Operation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {"url": "/providers/Microsoft.AzureArcData/operations"}
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/aio/operations/_operations.py
|
_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._operations import build_list_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.aio.AzureArcDataManagementClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]:
"""Lists all of the available Azure Data Services on Azure Arc API operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Operation or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.Operation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {"url": "/providers/Microsoft.AzureArcData/operations"}
| 0.618089 | 0.087252 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._active_directory_connectors_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class ActiveDirectoryConnectorsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.aio.AzureArcDataManagementClient`'s
:attr:`active_directory_connectors` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> AsyncIterable["_models.ActiveDirectoryConnectorResource"]:
"""List the active directory connectors associated with the given data controller.
List the active directory connectors associated with the given data controller.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either ActiveDirectoryConnectorResource or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ActiveDirectoryConnectorListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ActiveDirectoryConnectorListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors"
}
async def _create_initial(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: Union[_models.ActiveDirectoryConnectorResource, IO],
**kwargs: Any
) -> _models.ActiveDirectoryConnectorResource:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ActiveDirectoryConnectorResource] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(active_directory_connector_resource, (IO, bytes)):
_content = active_directory_connector_resource
else:
_json = self._serialize.body(active_directory_connector_resource, "ActiveDirectoryConnectorResource")
request = build_create_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
@overload
async def begin_create(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: _models.ActiveDirectoryConnectorResource,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.ActiveDirectoryConnectorResource]:
"""Creates or replaces an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:param active_directory_connector_resource: desc. Required.
:type active_directory_connector_resource:
~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either ActiveDirectoryConnectorResource or
the result of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.ActiveDirectoryConnectorResource]:
"""Creates or replaces an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:param active_directory_connector_resource: desc. Required.
:type active_directory_connector_resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either ActiveDirectoryConnectorResource or
the result of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: Union[_models.ActiveDirectoryConnectorResource, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.ActiveDirectoryConnectorResource]:
"""Creates or replaces an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:param active_directory_connector_resource: desc. Is either a model type or a IO type.
Required.
:type active_directory_connector_resource:
~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either ActiveDirectoryConnectorResource or
the result of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ActiveDirectoryConnectorResource] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_initial(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
active_directory_connector_resource=active_directory_connector_resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, data_controller_name: str, active_directory_connector_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, data_controller_name: str, active_directory_connector_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Deletes an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, data_controller_name: str, active_directory_connector_name: str, **kwargs: Any
) -> _models.ActiveDirectoryConnectorResource:
"""Retrieves an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ActiveDirectoryConnectorResource or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ActiveDirectoryConnectorResource] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/aio/operations/_active_directory_connectors_operations.py
|
_active_directory_connectors_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._active_directory_connectors_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class ActiveDirectoryConnectorsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.aio.AzureArcDataManagementClient`'s
:attr:`active_directory_connectors` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> AsyncIterable["_models.ActiveDirectoryConnectorResource"]:
"""List the active directory connectors associated with the given data controller.
List the active directory connectors associated with the given data controller.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either ActiveDirectoryConnectorResource or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ActiveDirectoryConnectorListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ActiveDirectoryConnectorListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors"
}
async def _create_initial(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: Union[_models.ActiveDirectoryConnectorResource, IO],
**kwargs: Any
) -> _models.ActiveDirectoryConnectorResource:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ActiveDirectoryConnectorResource] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(active_directory_connector_resource, (IO, bytes)):
_content = active_directory_connector_resource
else:
_json = self._serialize.body(active_directory_connector_resource, "ActiveDirectoryConnectorResource")
request = build_create_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
@overload
async def begin_create(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: _models.ActiveDirectoryConnectorResource,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.ActiveDirectoryConnectorResource]:
"""Creates or replaces an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:param active_directory_connector_resource: desc. Required.
:type active_directory_connector_resource:
~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either ActiveDirectoryConnectorResource or
the result of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.ActiveDirectoryConnectorResource]:
"""Creates or replaces an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:param active_directory_connector_resource: desc. Required.
:type active_directory_connector_resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either ActiveDirectoryConnectorResource or
the result of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create(
self,
resource_group_name: str,
data_controller_name: str,
active_directory_connector_name: str,
active_directory_connector_resource: Union[_models.ActiveDirectoryConnectorResource, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.ActiveDirectoryConnectorResource]:
"""Creates or replaces an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:param active_directory_connector_resource: desc. Is either a model type or a IO type.
Required.
:type active_directory_connector_resource:
~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either ActiveDirectoryConnectorResource or
the result of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ActiveDirectoryConnectorResource] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_initial(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
active_directory_connector_resource=active_directory_connector_resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, data_controller_name: str, active_directory_connector_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, data_controller_name: str, active_directory_connector_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Deletes an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, data_controller_name: str, active_directory_connector_name: str, **kwargs: Any
) -> _models.ActiveDirectoryConnectorResource:
"""Retrieves an Active Directory connector resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param active_directory_connector_name: The name of the Active Directory connector instance.
Required.
:type active_directory_connector_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ActiveDirectoryConnectorResource or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ActiveDirectoryConnectorResource] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
active_directory_connector_name=active_directory_connector_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ActiveDirectoryConnectorResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}/activeDirectoryConnectors/{activeDirectoryConnectorName}"
}
| 0.715126 | 0.080719 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._data_controllers_operations import (
build_delete_data_controller_request,
build_get_data_controller_request,
build_list_in_group_request,
build_list_in_subscription_request,
build_patch_data_controller_request,
build_put_data_controller_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class DataControllersOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.aio.AzureArcDataManagementClient`'s
:attr:`data_controllers` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_in_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataControllerResource"]:
"""List dataController resources in the subscription.
List dataController resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either DataControllerResource or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PageOfDataControllerResource] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_in_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_in_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PageOfDataControllerResource", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_in_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/dataControllers"
}
@distributed_trace
def list_in_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.DataControllerResource"]:
"""List dataController resources in the resource group.
List dataController resources in the resource group.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either DataControllerResource or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PageOfDataControllerResource] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_in_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_in_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PageOfDataControllerResource", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_in_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers"
}
async def _put_data_controller_initial(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerResource, IO],
**kwargs: Any
) -> _models.DataControllerResource:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(data_controller_resource, (IO, bytes)):
_content = data_controller_resource
else:
_json = self._serialize.body(data_controller_resource, "DataControllerResource")
request = build_put_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._put_data_controller_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_put_data_controller_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@overload
async def begin_put_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: _models.DataControllerResource,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.DataControllerResource]:
"""Creates or replaces a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: desc. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerResource
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either DataControllerResource or the result
of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_put_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.DataControllerResource]:
"""Creates or replaces a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: desc. Required.
:type data_controller_resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either DataControllerResource or the result
of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_put_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerResource, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.DataControllerResource]:
"""Creates or replaces a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: desc. Is either a model type or a IO type. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerResource or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either DataControllerResource or the result
of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._put_data_controller_initial(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
data_controller_resource=data_controller_resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_put_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
async def _delete_data_controller_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_data_controller_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_data_controller_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@distributed_trace_async
async def begin_delete_data_controller(
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Deletes a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_data_controller_initial( # type: ignore
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@distributed_trace_async
async def get_data_controller(
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> _models.DataControllerResource:
"""Retrieves a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DataControllerResource or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.DataControllerResource
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
request = build_get_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get_data_controller.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
async def _patch_data_controller_initial(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerUpdate, IO],
**kwargs: Any
) -> Optional[_models.DataControllerResource]:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[Optional[_models.DataControllerResource]] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(data_controller_resource, (IO, bytes)):
_content = data_controller_resource
else:
_json = self._serialize.body(data_controller_resource, "DataControllerUpdate")
request = build_patch_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._patch_data_controller_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
deserialized = None
if response.status_code == 200:
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
_patch_data_controller_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@overload
async def begin_patch_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: _models.DataControllerUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.DataControllerResource]:
"""Updates a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: The update data controller resource. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either DataControllerResource or the result
of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_patch_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.DataControllerResource]:
"""Updates a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: The update data controller resource. Required.
:type data_controller_resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either DataControllerResource or the result
of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_patch_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerUpdate, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.DataControllerResource]:
"""Updates a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: The update data controller resource. Is either a model type or
a IO type. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either DataControllerResource or the result
of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._patch_data_controller_initial(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
data_controller_resource=data_controller_resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_patch_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/aio/operations/_data_controllers_operations.py
|
_data_controllers_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._data_controllers_operations import (
build_delete_data_controller_request,
build_get_data_controller_request,
build_list_in_group_request,
build_list_in_subscription_request,
build_patch_data_controller_request,
build_put_data_controller_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class DataControllersOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurearcdata.aio.AzureArcDataManagementClient`'s
:attr:`data_controllers` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_in_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataControllerResource"]:
"""List dataController resources in the subscription.
List dataController resources in the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either DataControllerResource or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PageOfDataControllerResource] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_in_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_in_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PageOfDataControllerResource", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_in_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureArcData/dataControllers"
}
@distributed_trace
def list_in_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.DataControllerResource"]:
"""List dataController resources in the resource group.
List dataController resources in the resource group.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either DataControllerResource or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.PageOfDataControllerResource] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_in_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_in_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("PageOfDataControllerResource", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_in_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers"
}
async def _put_data_controller_initial(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerResource, IO],
**kwargs: Any
) -> _models.DataControllerResource:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(data_controller_resource, (IO, bytes)):
_content = data_controller_resource
else:
_json = self._serialize.body(data_controller_resource, "DataControllerResource")
request = build_put_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._put_data_controller_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_put_data_controller_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@overload
async def begin_put_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: _models.DataControllerResource,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.DataControllerResource]:
"""Creates or replaces a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: desc. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerResource
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either DataControllerResource or the result
of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_put_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.DataControllerResource]:
"""Creates or replaces a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: desc. Required.
:type data_controller_resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either DataControllerResource or the result
of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_put_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerResource, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.DataControllerResource]:
"""Creates or replaces a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: desc. Is either a model type or a IO type. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerResource or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either DataControllerResource or the result
of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._put_data_controller_initial(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
data_controller_resource=data_controller_resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_put_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
async def _delete_data_controller_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_data_controller_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_data_controller_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@distributed_trace_async
async def begin_delete_data_controller(
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Deletes a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_data_controller_initial( # type: ignore
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@distributed_trace_async
async def get_data_controller(
self, resource_group_name: str, data_controller_name: str, **kwargs: Any
) -> _models.DataControllerResource:
"""Retrieves a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DataControllerResource or the result of cls(response)
:rtype: ~azure.mgmt.azurearcdata.models.DataControllerResource
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
request = build_get_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get_data_controller.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
async def _patch_data_controller_initial(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerUpdate, IO],
**kwargs: Any
) -> Optional[_models.DataControllerResource]:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[Optional[_models.DataControllerResource]] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(data_controller_resource, (IO, bytes)):
_content = data_controller_resource
else:
_json = self._serialize.body(data_controller_resource, "DataControllerUpdate")
request = build_patch_data_controller_request(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._patch_data_controller_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
deserialized = None
if response.status_code == 200:
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
_patch_data_controller_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
@overload
async def begin_patch_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: _models.DataControllerUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.DataControllerResource]:
"""Updates a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: The update data controller resource. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either DataControllerResource or the result
of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_patch_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.DataControllerResource]:
"""Updates a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: The update data controller resource. Required.
:type data_controller_resource: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either DataControllerResource or the result
of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_patch_data_controller(
self,
resource_group_name: str,
data_controller_name: str,
data_controller_resource: Union[_models.DataControllerUpdate, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.DataControllerResource]:
"""Updates a dataController resource.
:param resource_group_name: The name of the Azure resource group. Required.
:type resource_group_name: str
:param data_controller_name: The name of the data controller. Required.
:type data_controller_name: str
:param data_controller_resource: The update data controller resource. Is either a model type or
a IO type. Required.
:type data_controller_resource: ~azure.mgmt.azurearcdata.models.DataControllerUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either DataControllerResource or the result
of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurearcdata.models.DataControllerResource]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-03-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DataControllerResource] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._patch_data_controller_initial(
resource_group_name=resource_group_name,
data_controller_name=data_controller_name,
data_controller_resource=data_controller_resource,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("DataControllerResource", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_patch_data_controller.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureArcData/dataControllers/{dataControllerName}"
}
| 0.666497 | 0.080719 |
from enum import Enum
from azure.core import CaseInsensitiveEnumMeta
class AccountProvisioningMode(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The service account provisioning mode for this Active Directory connector."""
AUTOMATIC = "automatic"
MANUAL = "manual"
class ArcSqlManagedInstanceLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The license type to apply for this managed instance."""
BASE_PRICE = "BasePrice"
LICENSE_INCLUDED = "LicenseIncluded"
DISASTER_RECOVERY = "DisasterRecovery"
class ArcSqlServerLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""SQL Server license type."""
UNDEFINED = "Undefined"
FREE = "Free"
HADR = "HADR"
SERVER_CAL = "ServerCAL"
LICENSE_ONLY = "LicenseOnly"
PAYG = "PAYG"
PAID = "Paid"
class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The cloud connectivity status."""
CONNECTED = "Connected"
DISCONNECTED = "Disconnected"
REGISTERED = "Registered"
UNKNOWN = "Unknown"
class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The type of identity that created the resource."""
USER = "User"
APPLICATION = "Application"
MANAGED_IDENTITY = "ManagedIdentity"
KEY = "Key"
class DefenderStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Status of Azure Defender."""
PROTECTED = "Protected"
UNPROTECTED = "Unprotected"
UNKNOWN = "Unknown"
class EditionType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""SQL Server edition."""
EVALUATION = "Evaluation"
ENTERPRISE = "Enterprise"
STANDARD = "Standard"
WEB = "Web"
DEVELOPER = "Developer"
EXPRESS = "Express"
class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The type of extendedLocation."""
CUSTOM_LOCATION = "CustomLocation"
class HostType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of host for Azure Arc SQL Server."""
AZURE_VIRTUAL_MACHINE = "Azure Virtual Machine"
AZURE_VM_WARE_VIRTUAL_MACHINE = "Azure VMWare Virtual Machine"
AZURE_KUBERNETES_SERVICE = "Azure Kubernetes Service"
AWS_VM_WARE_VIRTUAL_MACHINE = "AWS VMWare Virtual Machine"
AWS_KUBERNETES_SERVICE = "AWS Kubernetes Service"
GCP_VM_WARE_VIRTUAL_MACHINE = "GCP VMWare Virtual Machine"
GCP_KUBERNETES_SERVICE = "GCP Kubernetes Service"
CONTAINER = "Container"
VIRTUAL_MACHINE = "Virtual Machine"
PHYSICAL_SERVER = "Physical Server"
AWS_VIRTUAL_MACHINE = "AWS Virtual Machine"
GCP_VIRTUAL_MACHINE = "GCP Virtual Machine"
OTHER = "Other"
class Infrastructure(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The infrastructure the data controller is running on."""
AZURE = "azure"
GCP = "gcp"
AWS = "aws"
ALIBABA = "alibaba"
ONPREMISES = "onpremises"
OTHER = "other"
class OperationOrigin(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The intended executor of the operation."""
USER = "user"
SYSTEM = "system"
class SqlManagedInstanceSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The pricing tier for the instance."""
GENERAL_PURPOSE = "GeneralPurpose"
BUSINESS_CRITICAL = "BusinessCritical"
class SqlVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""SQL Server version."""
SQL_SERVER2012 = "SQL Server 2012"
SQL_SERVER2014 = "SQL Server 2014"
SQL_SERVER2016 = "SQL Server 2016"
SQL_SERVER2017 = "SQL Server 2017"
SQL_SERVER2019 = "SQL Server 2019"
SQL_SERVER2022 = "SQL Server 2022"
UNKNOWN = "Unknown"
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/models/_azure_arc_data_management_client_enums.py
|
_azure_arc_data_management_client_enums.py
|
from enum import Enum
from azure.core import CaseInsensitiveEnumMeta
class AccountProvisioningMode(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The service account provisioning mode for this Active Directory connector."""
AUTOMATIC = "automatic"
MANUAL = "manual"
class ArcSqlManagedInstanceLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The license type to apply for this managed instance."""
BASE_PRICE = "BasePrice"
LICENSE_INCLUDED = "LicenseIncluded"
DISASTER_RECOVERY = "DisasterRecovery"
class ArcSqlServerLicenseType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""SQL Server license type."""
UNDEFINED = "Undefined"
FREE = "Free"
HADR = "HADR"
SERVER_CAL = "ServerCAL"
LICENSE_ONLY = "LicenseOnly"
PAYG = "PAYG"
PAID = "Paid"
class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The cloud connectivity status."""
CONNECTED = "Connected"
DISCONNECTED = "Disconnected"
REGISTERED = "Registered"
UNKNOWN = "Unknown"
class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The type of identity that created the resource."""
USER = "User"
APPLICATION = "Application"
MANAGED_IDENTITY = "ManagedIdentity"
KEY = "Key"
class DefenderStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Status of Azure Defender."""
PROTECTED = "Protected"
UNPROTECTED = "Unprotected"
UNKNOWN = "Unknown"
class EditionType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""SQL Server edition."""
EVALUATION = "Evaluation"
ENTERPRISE = "Enterprise"
STANDARD = "Standard"
WEB = "Web"
DEVELOPER = "Developer"
EXPRESS = "Express"
class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The type of extendedLocation."""
CUSTOM_LOCATION = "CustomLocation"
class HostType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of host for Azure Arc SQL Server."""
AZURE_VIRTUAL_MACHINE = "Azure Virtual Machine"
AZURE_VM_WARE_VIRTUAL_MACHINE = "Azure VMWare Virtual Machine"
AZURE_KUBERNETES_SERVICE = "Azure Kubernetes Service"
AWS_VM_WARE_VIRTUAL_MACHINE = "AWS VMWare Virtual Machine"
AWS_KUBERNETES_SERVICE = "AWS Kubernetes Service"
GCP_VM_WARE_VIRTUAL_MACHINE = "GCP VMWare Virtual Machine"
GCP_KUBERNETES_SERVICE = "GCP Kubernetes Service"
CONTAINER = "Container"
VIRTUAL_MACHINE = "Virtual Machine"
PHYSICAL_SERVER = "Physical Server"
AWS_VIRTUAL_MACHINE = "AWS Virtual Machine"
GCP_VIRTUAL_MACHINE = "GCP Virtual Machine"
OTHER = "Other"
class Infrastructure(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The infrastructure the data controller is running on."""
AZURE = "azure"
GCP = "gcp"
AWS = "aws"
ALIBABA = "alibaba"
ONPREMISES = "onpremises"
OTHER = "other"
class OperationOrigin(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The intended executor of the operation."""
USER = "user"
SYSTEM = "system"
class SqlManagedInstanceSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The pricing tier for the instance."""
GENERAL_PURPOSE = "GeneralPurpose"
BUSINESS_CRITICAL = "BusinessCritical"
class SqlVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""SQL Server version."""
SQL_SERVER2012 = "SQL Server 2012"
SQL_SERVER2014 = "SQL Server 2014"
SQL_SERVER2016 = "SQL Server 2016"
SQL_SERVER2017 = "SQL Server 2017"
SQL_SERVER2019 = "SQL Server 2019"
SQL_SERVER2022 = "SQL Server 2022"
UNKNOWN = "Unknown"
| 0.796094 | 0.112356 |
import datetime
import sys
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union
from .. import _serialization
if sys.version_info >= (3, 9):
from collections.abc import MutableMapping
else:
from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from .. import models as _models
JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object
class ActiveDirectoryConnectorDNSDetails(_serialization.Model):
"""DNS server details.
All required parameters must be populated in order to send to Azure.
:ivar domain_name: DNS domain name for which DNS lookups should be forwarded to the Active
Directory DNS servers.
:vartype domain_name: str
:ivar nameserver_ip_addresses: List of Active Directory DNS server IP addresses. Required.
:vartype nameserver_ip_addresses: list[str]
:ivar replicas: Replica count for DNS proxy service. Default value is 1.
:vartype replicas: int
:ivar prefer_k8_s_dns_for_ptr_lookups: Flag indicating whether to prefer Kubernetes DNS server
response over AD DNS server response for IP address lookups.
:vartype prefer_k8_s_dns_for_ptr_lookups: bool
"""
_validation = {
"nameserver_ip_addresses": {"required": True},
}
_attribute_map = {
"domain_name": {"key": "domainName", "type": "str"},
"nameserver_ip_addresses": {"key": "nameserverIPAddresses", "type": "[str]"},
"replicas": {"key": "replicas", "type": "int"},
"prefer_k8_s_dns_for_ptr_lookups": {"key": "preferK8sDnsForPtrLookups", "type": "bool"},
}
def __init__(
self,
*,
nameserver_ip_addresses: List[str],
domain_name: Optional[str] = None,
replicas: int = 1,
prefer_k8_s_dns_for_ptr_lookups: bool = True,
**kwargs
):
"""
:keyword domain_name: DNS domain name for which DNS lookups should be forwarded to the Active
Directory DNS servers.
:paramtype domain_name: str
:keyword nameserver_ip_addresses: List of Active Directory DNS server IP addresses. Required.
:paramtype nameserver_ip_addresses: list[str]
:keyword replicas: Replica count for DNS proxy service. Default value is 1.
:paramtype replicas: int
:keyword prefer_k8_s_dns_for_ptr_lookups: Flag indicating whether to prefer Kubernetes DNS
server response over AD DNS server response for IP address lookups.
:paramtype prefer_k8_s_dns_for_ptr_lookups: bool
"""
super().__init__(**kwargs)
self.domain_name = domain_name
self.nameserver_ip_addresses = nameserver_ip_addresses
self.replicas = replicas
self.prefer_k8_s_dns_for_ptr_lookups = prefer_k8_s_dns_for_ptr_lookups
class ActiveDirectoryConnectorDomainDetails(_serialization.Model):
"""Active Directory domain details.
All required parameters must be populated in order to send to Azure.
:ivar realm: Name (uppercase) of the Active Directory domain that this AD connector will be
associated with. Required.
:vartype realm: str
:ivar netbios_domain_name: NETBIOS name of the Active Directory domain.
:vartype netbios_domain_name: str
:ivar service_account_provisioning: The service account provisioning mode for this Active
Directory connector. Known values are: "automatic" and "manual".
:vartype service_account_provisioning: str or
~azure.mgmt.azurearcdata.models.AccountProvisioningMode
:ivar ou_distinguished_name: The distinguished name of the Active Directory Organizational
Unit.
:vartype ou_distinguished_name: str
:ivar domain_controllers: null. Required.
:vartype domain_controllers: ~azure.mgmt.azurearcdata.models.ActiveDirectoryDomainControllers
"""
_validation = {
"realm": {"required": True},
"domain_controllers": {"required": True},
}
_attribute_map = {
"realm": {"key": "realm", "type": "str"},
"netbios_domain_name": {"key": "netbiosDomainName", "type": "str"},
"service_account_provisioning": {"key": "serviceAccountProvisioning", "type": "str"},
"ou_distinguished_name": {"key": "ouDistinguishedName", "type": "str"},
"domain_controllers": {"key": "domainControllers", "type": "ActiveDirectoryDomainControllers"},
}
def __init__(
self,
*,
realm: str,
domain_controllers: "_models.ActiveDirectoryDomainControllers",
netbios_domain_name: Optional[str] = None,
service_account_provisioning: Union[str, "_models.AccountProvisioningMode"] = "manual",
ou_distinguished_name: Optional[str] = None,
**kwargs
):
"""
:keyword realm: Name (uppercase) of the Active Directory domain that this AD connector will be
associated with. Required.
:paramtype realm: str
:keyword netbios_domain_name: NETBIOS name of the Active Directory domain.
:paramtype netbios_domain_name: str
:keyword service_account_provisioning: The service account provisioning mode for this Active
Directory connector. Known values are: "automatic" and "manual".
:paramtype service_account_provisioning: str or
~azure.mgmt.azurearcdata.models.AccountProvisioningMode
:keyword ou_distinguished_name: The distinguished name of the Active Directory Organizational
Unit.
:paramtype ou_distinguished_name: str
:keyword domain_controllers: null. Required.
:paramtype domain_controllers: ~azure.mgmt.azurearcdata.models.ActiveDirectoryDomainControllers
"""
super().__init__(**kwargs)
self.realm = realm
self.netbios_domain_name = netbios_domain_name
self.service_account_provisioning = service_account_provisioning
self.ou_distinguished_name = ou_distinguished_name
self.domain_controllers = domain_controllers
class ActiveDirectoryConnectorListResult(_serialization.Model):
"""A list of active directory connectors.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: Array of results.
:vartype value: list[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:ivar next_link: Link to retrieve next page of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[ActiveDirectoryConnectorResource]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class ActiveDirectoryConnectorProperties(_serialization.Model):
"""The properties of an Active Directory connector resource.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar domain_service_account_login_information: Username and password for domain service
account authentication.
:vartype domain_service_account_login_information:
~azure.mgmt.azurearcdata.models.BasicLoginInformation
:ivar provisioning_state: The provisioning state of the Active Directory connector resource.
:vartype provisioning_state: str
:ivar spec: null. Required.
:vartype spec: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorSpec
:ivar status: null.
:vartype status: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorStatus
"""
_validation = {
"provisioning_state": {"readonly": True},
"spec": {"required": True},
}
_attribute_map = {
"domain_service_account_login_information": {
"key": "domainServiceAccountLoginInformation",
"type": "BasicLoginInformation",
},
"provisioning_state": {"key": "provisioningState", "type": "str"},
"spec": {"key": "spec", "type": "ActiveDirectoryConnectorSpec"},
"status": {"key": "status", "type": "ActiveDirectoryConnectorStatus"},
}
def __init__(
self,
*,
spec: "_models.ActiveDirectoryConnectorSpec",
domain_service_account_login_information: Optional["_models.BasicLoginInformation"] = None,
status: Optional["_models.ActiveDirectoryConnectorStatus"] = None,
**kwargs
):
"""
:keyword domain_service_account_login_information: Username and password for domain service
account authentication.
:paramtype domain_service_account_login_information:
~azure.mgmt.azurearcdata.models.BasicLoginInformation
:keyword spec: null. Required.
:paramtype spec: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorSpec
:keyword status: null.
:paramtype status: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorStatus
"""
super().__init__(**kwargs)
self.domain_service_account_login_information = domain_service_account_login_information
self.provisioning_state = None
self.spec = spec
self.status = status
class Resource(_serialization.Model):
"""Common fields that are returned in the response for all Azure Resource Manager resources.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.id = None
self.name = None
self.type = None
self.system_data = None
class ProxyResource(Resource):
"""The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
class ActiveDirectoryConnectorResource(ProxyResource):
"""Active directory connector resource.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
:ivar properties: null. Required.
:vartype properties: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorProperties
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"properties": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"properties": {"key": "properties", "type": "ActiveDirectoryConnectorProperties"},
}
def __init__(self, *, properties: "_models.ActiveDirectoryConnectorProperties", **kwargs):
"""
:keyword properties: null. Required.
:paramtype properties: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorProperties
"""
super().__init__(**kwargs)
self.properties = properties
class ActiveDirectoryConnectorSpec(_serialization.Model):
"""The specifications of the AD Kubernetes resource.
All required parameters must be populated in order to send to Azure.
:ivar active_directory: null. Required.
:vartype active_directory:
~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorDomainDetails
:ivar dns: null. Required.
:vartype dns: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorDNSDetails
"""
_validation = {
"active_directory": {"required": True},
"dns": {"required": True},
}
_attribute_map = {
"active_directory": {"key": "activeDirectory", "type": "ActiveDirectoryConnectorDomainDetails"},
"dns": {"key": "dns", "type": "ActiveDirectoryConnectorDNSDetails"},
}
def __init__(
self,
*,
active_directory: "_models.ActiveDirectoryConnectorDomainDetails",
dns: "_models.ActiveDirectoryConnectorDNSDetails",
**kwargs
):
"""
:keyword active_directory: null. Required.
:paramtype active_directory:
~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorDomainDetails
:keyword dns: null. Required.
:paramtype dns: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorDNSDetails
"""
super().__init__(**kwargs)
self.active_directory = active_directory
self.dns = dns
class ActiveDirectoryConnectorStatus(_serialization.Model):
"""The status of the Kubernetes custom resource.
:ivar additional_properties: Unmatched properties from the message are deserialized to this
collection.
:vartype additional_properties: dict[str, JSON]
:ivar last_update_time: The time that the custom resource was last updated.
:vartype last_update_time: str
:ivar observed_generation: The version of the replicaSet associated with the AD connector
custom resource.
:vartype observed_generation: int
:ivar state: The state of the AD connector custom resource.
:vartype state: str
"""
_attribute_map = {
"additional_properties": {"key": "", "type": "{object}"},
"last_update_time": {"key": "lastUpdateTime", "type": "str"},
"observed_generation": {"key": "observedGeneration", "type": "int"},
"state": {"key": "state", "type": "str"},
}
def __init__(
self,
*,
additional_properties: Optional[Dict[str, JSON]] = None,
last_update_time: Optional[str] = None,
observed_generation: Optional[int] = None,
state: Optional[str] = None,
**kwargs
):
"""
:keyword additional_properties: Unmatched properties from the message are deserialized to this
collection.
:paramtype additional_properties: dict[str, JSON]
:keyword last_update_time: The time that the custom resource was last updated.
:paramtype last_update_time: str
:keyword observed_generation: The version of the replicaSet associated with the AD connector
custom resource.
:paramtype observed_generation: int
:keyword state: The state of the AD connector custom resource.
:paramtype state: str
"""
super().__init__(**kwargs)
self.additional_properties = additional_properties
self.last_update_time = last_update_time
self.observed_generation = observed_generation
self.state = state
class ActiveDirectoryDomainController(_serialization.Model):
"""Information about a domain controller in the AD domain.
All required parameters must be populated in order to send to Azure.
:ivar hostname: Fully-qualified domain name of a domain controller in the AD domain. Required.
:vartype hostname: str
"""
_validation = {
"hostname": {"required": True},
}
_attribute_map = {
"hostname": {"key": "hostname", "type": "str"},
}
def __init__(self, *, hostname: str, **kwargs):
"""
:keyword hostname: Fully-qualified domain name of a domain controller in the AD domain.
Required.
:paramtype hostname: str
"""
super().__init__(**kwargs)
self.hostname = hostname
class ActiveDirectoryDomainControllers(_serialization.Model):
"""Details about the Active Directory domain controllers associated with this AD connector instance.
:ivar primary_domain_controller: Information about the Primary Domain Controller (PDC) in the
AD domain.
:vartype primary_domain_controller:
~azure.mgmt.azurearcdata.models.ActiveDirectoryDomainController
:ivar secondary_domain_controllers: null.
:vartype secondary_domain_controllers:
list[~azure.mgmt.azurearcdata.models.ActiveDirectoryDomainController]
"""
_attribute_map = {
"primary_domain_controller": {"key": "primaryDomainController", "type": "ActiveDirectoryDomainController"},
"secondary_domain_controllers": {
"key": "secondaryDomainControllers",
"type": "[ActiveDirectoryDomainController]",
},
}
def __init__(
self,
*,
primary_domain_controller: Optional["_models.ActiveDirectoryDomainController"] = None,
secondary_domain_controllers: Optional[List["_models.ActiveDirectoryDomainController"]] = None,
**kwargs
):
"""
:keyword primary_domain_controller: Information about the Primary Domain Controller (PDC) in
the AD domain.
:paramtype primary_domain_controller:
~azure.mgmt.azurearcdata.models.ActiveDirectoryDomainController
:keyword secondary_domain_controllers: null.
:paramtype secondary_domain_controllers:
list[~azure.mgmt.azurearcdata.models.ActiveDirectoryDomainController]
"""
super().__init__(**kwargs)
self.primary_domain_controller = primary_domain_controller
self.secondary_domain_controllers = secondary_domain_controllers
class ActiveDirectoryInformation(_serialization.Model):
"""Active Directory information that related to the resource.
:ivar keytab_information: Keytab information that is used for the Sql Managed Instance when
Active Directory authentication is used.
:vartype keytab_information: ~azure.mgmt.azurearcdata.models.KeytabInformation
"""
_attribute_map = {
"keytab_information": {"key": "keytabInformation", "type": "KeytabInformation"},
}
def __init__(self, *, keytab_information: Optional["_models.KeytabInformation"] = None, **kwargs):
"""
:keyword keytab_information: Keytab information that is used for the Sql Managed Instance when
Active Directory authentication is used.
:paramtype keytab_information: ~azure.mgmt.azurearcdata.models.KeytabInformation
"""
super().__init__(**kwargs)
self.keytab_information = keytab_information
class BasicLoginInformation(_serialization.Model):
"""Username and password for basic login authentication.
:ivar username: Login username.
:vartype username: str
:ivar password: Login password.
:vartype password: str
"""
_attribute_map = {
"username": {"key": "username", "type": "str"},
"password": {"key": "password", "type": "str"},
}
def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs):
"""
:keyword username: Login username.
:paramtype username: str
:keyword password: Login password.
:paramtype password: str
"""
super().__init__(**kwargs)
self.username = username
self.password = password
class CommonSku(_serialization.Model):
"""The resource model definition representing SKU for ARM resources.
All required parameters must be populated in order to send to Azure.
:ivar name: The name of the SKU. It is typically a letter+number code. Required.
:vartype name: str
:ivar dev: Whether dev/test is enabled. When the dev field is set to true, the resource is used
for dev/test purpose.
:vartype dev: bool
:ivar size: The SKU size. When the name field is the combination of tier and some other value,
this would be the standalone code.
:vartype size: str
:ivar family: If the service has different generations of hardware, for the same SKU, then that
can be captured here.
:vartype family: str
:ivar capacity: If the SKU supports scale out/in then the capacity integer should be included.
If scale out/in is not possible for the resource this may be omitted.
:vartype capacity: int
"""
_validation = {
"name": {"required": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"dev": {"key": "dev", "type": "bool"},
"size": {"key": "size", "type": "str"},
"family": {"key": "family", "type": "str"},
"capacity": {"key": "capacity", "type": "int"},
}
def __init__(
self,
*,
name: str,
dev: bool = True,
size: Optional[str] = None,
family: Optional[str] = None,
capacity: Optional[int] = None,
**kwargs
):
"""
:keyword name: The name of the SKU. It is typically a letter+number code. Required.
:paramtype name: str
:keyword dev: Whether dev/test is enabled. When the dev field is set to true, the resource is
used for dev/test purpose.
:paramtype dev: bool
:keyword size: The SKU size. When the name field is the combination of tier and some other
value, this would be the standalone code.
:paramtype size: str
:keyword family: If the service has different generations of hardware, for the same SKU, then
that can be captured here.
:paramtype family: str
:keyword capacity: If the SKU supports scale out/in then the capacity integer should be
included. If scale out/in is not possible for the resource this may be omitted.
:paramtype capacity: int
"""
super().__init__(**kwargs)
self.name = name
self.dev = dev
self.size = size
self.family = family
self.capacity = capacity
class DataControllerProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""The data controller properties.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar infrastructure: The infrastructure the data controller is running on. Known values are:
"azure", "gcp", "aws", "alibaba", "onpremises", and "other".
:vartype infrastructure: str or ~azure.mgmt.azurearcdata.models.Infrastructure
:ivar on_premise_property: Properties from the Kubernetes data controller.
:vartype on_premise_property: ~azure.mgmt.azurearcdata.models.OnPremiseProperty
:ivar k8_s_raw: The raw kubernetes information.
:vartype k8_s_raw: JSON
:ivar upload_watermark: Properties on upload watermark. Mostly timestamp for each upload data
type.
:vartype upload_watermark: ~azure.mgmt.azurearcdata.models.UploadWatermark
:ivar last_uploaded_date: Last uploaded date from Kubernetes cluster. Defaults to current date
time.
:vartype last_uploaded_date: ~datetime.datetime
:ivar basic_login_information: Deprecated. Azure Arc Data Services data controller no longer
expose any endpoint. All traffic are exposed through Kubernetes native API.
:vartype basic_login_information: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:ivar metrics_dashboard_credential: Login credential for metrics dashboard on the Kubernetes
cluster.
:vartype metrics_dashboard_credential: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:ivar logs_dashboard_credential: Login credential for logs dashboard on the Kubernetes cluster.
:vartype logs_dashboard_credential: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:ivar log_analytics_workspace_config: Log analytics workspace id and primary key.
:vartype log_analytics_workspace_config:
~azure.mgmt.azurearcdata.models.LogAnalyticsWorkspaceConfig
:ivar upload_service_principal: Deprecated. Service principal is deprecated in favor of Arc
Kubernetes service extension managed identity.
:vartype upload_service_principal: ~azure.mgmt.azurearcdata.models.UploadServicePrincipal
:ivar provisioning_state: The provisioning state of the Arc Data Controller resource.
:vartype provisioning_state: str
:ivar cluster_id: If a CustomLocation is provided, this contains the ARM id of the connected
cluster the custom location belongs to.
:vartype cluster_id: str
:ivar extension_id: If a CustomLocation is provided, this contains the ARM id of the extension
the custom location belongs to.
:vartype extension_id: str
"""
_validation = {
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"infrastructure": {"key": "infrastructure", "type": "str"},
"on_premise_property": {"key": "onPremiseProperty", "type": "OnPremiseProperty"},
"k8_s_raw": {"key": "k8sRaw", "type": "object"},
"upload_watermark": {"key": "uploadWatermark", "type": "UploadWatermark"},
"last_uploaded_date": {"key": "lastUploadedDate", "type": "iso-8601"},
"basic_login_information": {"key": "basicLoginInformation", "type": "BasicLoginInformation"},
"metrics_dashboard_credential": {"key": "metricsDashboardCredential", "type": "BasicLoginInformation"},
"logs_dashboard_credential": {"key": "logsDashboardCredential", "type": "BasicLoginInformation"},
"log_analytics_workspace_config": {"key": "logAnalyticsWorkspaceConfig", "type": "LogAnalyticsWorkspaceConfig"},
"upload_service_principal": {"key": "uploadServicePrincipal", "type": "UploadServicePrincipal"},
"provisioning_state": {"key": "provisioningState", "type": "str"},
"cluster_id": {"key": "clusterId", "type": "str"},
"extension_id": {"key": "extensionId", "type": "str"},
}
def __init__(
self,
*,
infrastructure: Union[str, "_models.Infrastructure"] = "other",
on_premise_property: Optional["_models.OnPremiseProperty"] = None,
k8_s_raw: Optional[JSON] = None,
upload_watermark: Optional["_models.UploadWatermark"] = None,
last_uploaded_date: Optional[datetime.datetime] = None,
basic_login_information: Optional["_models.BasicLoginInformation"] = None,
metrics_dashboard_credential: Optional["_models.BasicLoginInformation"] = None,
logs_dashboard_credential: Optional["_models.BasicLoginInformation"] = None,
log_analytics_workspace_config: Optional["_models.LogAnalyticsWorkspaceConfig"] = None,
upload_service_principal: Optional["_models.UploadServicePrincipal"] = None,
cluster_id: Optional[str] = None,
extension_id: Optional[str] = None,
**kwargs
):
"""
:keyword infrastructure: The infrastructure the data controller is running on. Known values
are: "azure", "gcp", "aws", "alibaba", "onpremises", and "other".
:paramtype infrastructure: str or ~azure.mgmt.azurearcdata.models.Infrastructure
:keyword on_premise_property: Properties from the Kubernetes data controller.
:paramtype on_premise_property: ~azure.mgmt.azurearcdata.models.OnPremiseProperty
:keyword k8_s_raw: The raw kubernetes information.
:paramtype k8_s_raw: JSON
:keyword upload_watermark: Properties on upload watermark. Mostly timestamp for each upload
data type.
:paramtype upload_watermark: ~azure.mgmt.azurearcdata.models.UploadWatermark
:keyword last_uploaded_date: Last uploaded date from Kubernetes cluster. Defaults to current
date time.
:paramtype last_uploaded_date: ~datetime.datetime
:keyword basic_login_information: Deprecated. Azure Arc Data Services data controller no longer
expose any endpoint. All traffic are exposed through Kubernetes native API.
:paramtype basic_login_information: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:keyword metrics_dashboard_credential: Login credential for metrics dashboard on the Kubernetes
cluster.
:paramtype metrics_dashboard_credential: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:keyword logs_dashboard_credential: Login credential for logs dashboard on the Kubernetes
cluster.
:paramtype logs_dashboard_credential: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:keyword log_analytics_workspace_config: Log analytics workspace id and primary key.
:paramtype log_analytics_workspace_config:
~azure.mgmt.azurearcdata.models.LogAnalyticsWorkspaceConfig
:keyword upload_service_principal: Deprecated. Service principal is deprecated in favor of Arc
Kubernetes service extension managed identity.
:paramtype upload_service_principal: ~azure.mgmt.azurearcdata.models.UploadServicePrincipal
:keyword cluster_id: If a CustomLocation is provided, this contains the ARM id of the connected
cluster the custom location belongs to.
:paramtype cluster_id: str
:keyword extension_id: If a CustomLocation is provided, this contains the ARM id of the
extension the custom location belongs to.
:paramtype extension_id: str
"""
super().__init__(**kwargs)
self.infrastructure = infrastructure
self.on_premise_property = on_premise_property
self.k8_s_raw = k8_s_raw
self.upload_watermark = upload_watermark
self.last_uploaded_date = last_uploaded_date
self.basic_login_information = basic_login_information
self.metrics_dashboard_credential = metrics_dashboard_credential
self.logs_dashboard_credential = logs_dashboard_credential
self.log_analytics_workspace_config = log_analytics_workspace_config
self.upload_service_principal = upload_service_principal
self.provisioning_state = None
self.cluster_id = cluster_id
self.extension_id = extension_id
class TrackedResource(Resource):
"""The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"location": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
}
def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
"""
super().__init__(**kwargs)
self.tags = tags
self.location = location
class DataControllerResource(TrackedResource):
"""Data controller resource.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurearcdata.models.ExtendedLocation
:ivar properties: The data controller's properties. Required.
:vartype properties: ~azure.mgmt.azurearcdata.models.DataControllerProperties
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"location": {"required": True},
"properties": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"properties": {"key": "properties", "type": "DataControllerProperties"},
}
def __init__(
self,
*,
location: str,
properties: "_models.DataControllerProperties",
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurearcdata.models.ExtendedLocation
:keyword properties: The data controller's properties. Required.
:paramtype properties: ~azure.mgmt.azurearcdata.models.DataControllerProperties
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.properties = properties
class DataControllerUpdate(_serialization.Model):
"""Used for updating a data controller resource.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar properties: The data controller's properties.
:vartype properties: ~azure.mgmt.azurearcdata.models.DataControllerProperties
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
"properties": {"key": "properties", "type": "DataControllerProperties"},
}
def __init__(
self,
*,
tags: Optional[Dict[str, str]] = None,
properties: Optional["_models.DataControllerProperties"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword properties: The data controller's properties.
:paramtype properties: ~azure.mgmt.azurearcdata.models.DataControllerProperties
"""
super().__init__(**kwargs)
self.tags = tags
self.properties = properties
class ErrorResponse(_serialization.Model):
"""An error response from the Azure Data on Azure Arc service.
:ivar error: null.
:vartype error: ~azure.mgmt.azurearcdata.models.ErrorResponseBody
"""
_attribute_map = {
"error": {"key": "error", "type": "ErrorResponseBody"},
}
def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs):
"""
:keyword error: null.
:paramtype error: ~azure.mgmt.azurearcdata.models.ErrorResponseBody
"""
super().__init__(**kwargs)
self.error = error
class ErrorResponseBody(_serialization.Model):
"""An error response from the Batch service.
:ivar code: An identifier for the error. Codes are invariant and are intended to be consumed
programmatically.
:vartype code: str
:ivar message: A message describing the error, intended to be suitable for display in a user
interface.
:vartype message: str
:ivar target: The target of the particular error. For example, the name of the property in
error.
:vartype target: str
:ivar details: A list of additional details about the error.
:vartype details: list[~azure.mgmt.azurearcdata.models.ErrorResponseBody]
"""
_attribute_map = {
"code": {"key": "code", "type": "str"},
"message": {"key": "message", "type": "str"},
"target": {"key": "target", "type": "str"},
"details": {"key": "details", "type": "[ErrorResponseBody]"},
}
def __init__(
self,
*,
code: Optional[str] = None,
message: Optional[str] = None,
target: Optional[str] = None,
details: Optional[List["_models.ErrorResponseBody"]] = None,
**kwargs
):
"""
:keyword code: An identifier for the error. Codes are invariant and are intended to be consumed
programmatically.
:paramtype code: str
:keyword message: A message describing the error, intended to be suitable for display in a user
interface.
:paramtype message: str
:keyword target: The target of the particular error. For example, the name of the property in
error.
:paramtype target: str
:keyword details: A list of additional details about the error.
:paramtype details: list[~azure.mgmt.azurearcdata.models.ErrorResponseBody]
"""
super().__init__(**kwargs)
self.code = code
self.message = message
self.target = target
self.details = details
class ExtendedLocation(_serialization.Model):
"""The complex type of the extended location.
:ivar name: The name of the extended location.
:vartype name: str
:ivar type: The type of the extended location. "CustomLocation"
:vartype type: str or ~azure.mgmt.azurearcdata.models.ExtendedLocationTypes
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
}
def __init__(
self,
*,
name: Optional[str] = None,
type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None,
**kwargs
):
"""
:keyword name: The name of the extended location.
:paramtype name: str
:keyword type: The type of the extended location. "CustomLocation"
:paramtype type: str or ~azure.mgmt.azurearcdata.models.ExtendedLocationTypes
"""
super().__init__(**kwargs)
self.name = name
self.type = type
class K8SResourceRequirements(_serialization.Model):
"""The kubernetes resource limits and requests used to restrict or reserve resource usage.
:ivar additional_properties: Unmatched properties from the message are deserialized to this
collection.
:vartype additional_properties: dict[str, JSON]
:ivar requests: Requests for a kubernetes resource type (e.g 'cpu', 'memory'). The 'cpu'
request must be less than or equal to 'cpu' limit. Default 'cpu' is 2, minimum is 1. Default
'memory' is '4Gi', minimum is '2Gi. If sku.tier is GeneralPurpose, maximum 'cpu' is 24 and
maximum 'memory' is '128Gi'.
:vartype requests: dict[str, str]
:ivar limits: Limits for a kubernetes resource type (e.g 'cpu', 'memory'). The 'cpu' request
must be less than or equal to 'cpu' limit. Default 'cpu' is 2, minimum is 1. Default 'memory'
is '4Gi', minimum is '2Gi. If sku.tier is GeneralPurpose, maximum 'cpu' is 24 and maximum
'memory' is '128Gi'.
:vartype limits: dict[str, str]
"""
_attribute_map = {
"additional_properties": {"key": "", "type": "{object}"},
"requests": {"key": "requests", "type": "{str}"},
"limits": {"key": "limits", "type": "{str}"},
}
def __init__(
self,
*,
additional_properties: Optional[Dict[str, JSON]] = None,
requests: Optional[Dict[str, str]] = None,
limits: Optional[Dict[str, str]] = None,
**kwargs
):
"""
:keyword additional_properties: Unmatched properties from the message are deserialized to this
collection.
:paramtype additional_properties: dict[str, JSON]
:keyword requests: Requests for a kubernetes resource type (e.g 'cpu', 'memory'). The 'cpu'
request must be less than or equal to 'cpu' limit. Default 'cpu' is 2, minimum is 1. Default
'memory' is '4Gi', minimum is '2Gi. If sku.tier is GeneralPurpose, maximum 'cpu' is 24 and
maximum 'memory' is '128Gi'.
:paramtype requests: dict[str, str]
:keyword limits: Limits for a kubernetes resource type (e.g 'cpu', 'memory'). The 'cpu' request
must be less than or equal to 'cpu' limit. Default 'cpu' is 2, minimum is 1. Default 'memory'
is '4Gi', minimum is '2Gi. If sku.tier is GeneralPurpose, maximum 'cpu' is 24 and maximum
'memory' is '128Gi'.
:paramtype limits: dict[str, str]
"""
super().__init__(**kwargs)
self.additional_properties = additional_properties
self.requests = requests
self.limits = limits
class K8SScheduling(_serialization.Model):
"""The kubernetes scheduling information.
:ivar additional_properties: Unmatched properties from the message are deserialized to this
collection.
:vartype additional_properties: dict[str, JSON]
:ivar default: The kubernetes scheduling options. It describes restrictions used to help
Kubernetes select appropriate nodes to host the database service.
:vartype default: ~azure.mgmt.azurearcdata.models.K8SSchedulingOptions
"""
_attribute_map = {
"additional_properties": {"key": "", "type": "{object}"},
"default": {"key": "default", "type": "K8SSchedulingOptions"},
}
def __init__(
self,
*,
additional_properties: Optional[Dict[str, JSON]] = None,
default: Optional["_models.K8SSchedulingOptions"] = None,
**kwargs
):
"""
:keyword additional_properties: Unmatched properties from the message are deserialized to this
collection.
:paramtype additional_properties: dict[str, JSON]
:keyword default: The kubernetes scheduling options. It describes restrictions used to help
Kubernetes select appropriate nodes to host the database service.
:paramtype default: ~azure.mgmt.azurearcdata.models.K8SSchedulingOptions
"""
super().__init__(**kwargs)
self.additional_properties = additional_properties
self.default = default
class K8SSchedulingOptions(_serialization.Model):
"""The kubernetes scheduling options. It describes restrictions used to help Kubernetes select appropriate nodes to host the database service.
:ivar additional_properties: Unmatched properties from the message are deserialized to this
collection.
:vartype additional_properties: dict[str, JSON]
:ivar resources: The kubernetes resource limits and requests used to restrict or reserve
resource usage.
:vartype resources: ~azure.mgmt.azurearcdata.models.K8SResourceRequirements
"""
_attribute_map = {
"additional_properties": {"key": "", "type": "{object}"},
"resources": {"key": "resources", "type": "K8SResourceRequirements"},
}
def __init__(
self,
*,
additional_properties: Optional[Dict[str, JSON]] = None,
resources: Optional["_models.K8SResourceRequirements"] = None,
**kwargs
):
"""
:keyword additional_properties: Unmatched properties from the message are deserialized to this
collection.
:paramtype additional_properties: dict[str, JSON]
:keyword resources: The kubernetes resource limits and requests used to restrict or reserve
resource usage.
:paramtype resources: ~azure.mgmt.azurearcdata.models.K8SResourceRequirements
"""
super().__init__(**kwargs)
self.additional_properties = additional_properties
self.resources = resources
class KeytabInformation(_serialization.Model):
"""Keytab used for authenticate with Active Directory.
:ivar keytab: A base64-encoded keytab.
:vartype keytab: str
"""
_attribute_map = {
"keytab": {"key": "keytab", "type": "str"},
}
def __init__(self, *, keytab: Optional[str] = None, **kwargs):
"""
:keyword keytab: A base64-encoded keytab.
:paramtype keytab: str
"""
super().__init__(**kwargs)
self.keytab = keytab
class LogAnalyticsWorkspaceConfig(_serialization.Model):
"""Log analytics workspace id and primary key.
:ivar workspace_id: Azure Log Analytics workspace ID.
:vartype workspace_id: str
:ivar primary_key: Primary key of the workspace.
:vartype primary_key: str
"""
_attribute_map = {
"workspace_id": {"key": "workspaceId", "type": "str"},
"primary_key": {"key": "primaryKey", "type": "str"},
}
def __init__(self, *, workspace_id: Optional[str] = None, primary_key: Optional[str] = None, **kwargs):
"""
:keyword workspace_id: Azure Log Analytics workspace ID.
:paramtype workspace_id: str
:keyword primary_key: Primary key of the workspace.
:paramtype primary_key: str
"""
super().__init__(**kwargs)
self.workspace_id = workspace_id
self.primary_key = primary_key
class OnPremiseProperty(_serialization.Model):
"""Properties from the Kubernetes data controller.
All required parameters must be populated in order to send to Azure.
:ivar id: A globally unique ID identifying the associated Kubernetes cluster. Required.
:vartype id: str
:ivar public_signing_key: Certificate that contains the Kubernetes cluster public key used to
verify signing. Required.
:vartype public_signing_key: str
:ivar signing_certificate_thumbprint: Unique thumbprint returned to customer to verify the
certificate being uploaded.
:vartype signing_certificate_thumbprint: str
"""
_validation = {
"id": {"required": True},
"public_signing_key": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"public_signing_key": {"key": "publicSigningKey", "type": "str"},
"signing_certificate_thumbprint": {"key": "signingCertificateThumbprint", "type": "str"},
}
def __init__(
self,
*,
id: str, # pylint: disable=redefined-builtin
public_signing_key: str,
signing_certificate_thumbprint: Optional[str] = None,
**kwargs
):
"""
:keyword id: A globally unique ID identifying the associated Kubernetes cluster. Required.
:paramtype id: str
:keyword public_signing_key: Certificate that contains the Kubernetes cluster public key used
to verify signing. Required.
:paramtype public_signing_key: str
:keyword signing_certificate_thumbprint: Unique thumbprint returned to customer to verify the
certificate being uploaded.
:paramtype signing_certificate_thumbprint: str
"""
super().__init__(**kwargs)
self.id = id
self.public_signing_key = public_signing_key
self.signing_certificate_thumbprint = signing_certificate_thumbprint
class Operation(_serialization.Model):
"""Azure Data Services on Azure Arc operation definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar name: The name of the operation being performed on this particular object. Required.
:vartype name: str
:ivar display: The localized display information for this particular operation / action.
Required.
:vartype display: ~azure.mgmt.azurearcdata.models.OperationDisplay
:ivar origin: The intended executor of the operation. Known values are: "user" and "system".
:vartype origin: str or ~azure.mgmt.azurearcdata.models.OperationOrigin
:ivar is_data_action: Indicates whether the operation is a data action. Required.
:vartype is_data_action: bool
:ivar properties: Additional descriptions for the operation.
:vartype properties: dict[str, JSON]
"""
_validation = {
"name": {"required": True},
"display": {"required": True},
"origin": {"readonly": True},
"is_data_action": {"required": True},
"properties": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"display": {"key": "display", "type": "OperationDisplay"},
"origin": {"key": "origin", "type": "str"},
"is_data_action": {"key": "isDataAction", "type": "bool"},
"properties": {"key": "properties", "type": "{object}"},
}
def __init__(self, *, name: str, display: "_models.OperationDisplay", is_data_action: bool, **kwargs):
"""
:keyword name: The name of the operation being performed on this particular object. Required.
:paramtype name: str
:keyword display: The localized display information for this particular operation / action.
Required.
:paramtype display: ~azure.mgmt.azurearcdata.models.OperationDisplay
:keyword is_data_action: Indicates whether the operation is a data action. Required.
:paramtype is_data_action: bool
"""
super().__init__(**kwargs)
self.name = name
self.display = display
self.origin = None
self.is_data_action = is_data_action
self.properties = None
class OperationDisplay(_serialization.Model):
"""Display metadata associated with the operation.
All required parameters must be populated in order to send to Azure.
:ivar provider: The localized friendly form of the resource provider name. Required.
:vartype provider: str
:ivar resource: The localized friendly form of the resource type related to this
action/operation. Required.
:vartype resource: str
:ivar operation: The localized friendly name for the operation. Required.
:vartype operation: str
:ivar description: The localized friendly description for the operation. Required.
:vartype description: str
"""
_validation = {
"provider": {"required": True},
"resource": {"required": True},
"operation": {"required": True},
"description": {"required": True},
}
_attribute_map = {
"provider": {"key": "provider", "type": "str"},
"resource": {"key": "resource", "type": "str"},
"operation": {"key": "operation", "type": "str"},
"description": {"key": "description", "type": "str"},
}
def __init__(self, *, provider: str, resource: str, operation: str, description: str, **kwargs):
"""
:keyword provider: The localized friendly form of the resource provider name. Required.
:paramtype provider: str
:keyword resource: The localized friendly form of the resource type related to this
action/operation. Required.
:paramtype resource: str
:keyword operation: The localized friendly name for the operation. Required.
:paramtype operation: str
:keyword description: The localized friendly description for the operation. Required.
:paramtype description: str
"""
super().__init__(**kwargs)
self.provider = provider
self.resource = resource
self.operation = operation
self.description = description
class OperationListResult(_serialization.Model):
"""Result of the request to list Azure Data Services on Azure Arc operations.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: Array of results.
:vartype value: list[~azure.mgmt.azurearcdata.models.Operation]
:ivar next_link: Link to retrieve next page of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[Operation]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class PageOfDataControllerResource(_serialization.Model):
"""A list of data controllers.
:ivar value: Array of results.
:vartype value: list[~azure.mgmt.azurearcdata.models.DataControllerResource]
:ivar next_link: Link to retrieve next page of results.
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[DataControllerResource]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self,
*,
value: Optional[List["_models.DataControllerResource"]] = None,
next_link: Optional[str] = None,
**kwargs
):
"""
:keyword value: Array of results.
:paramtype value: list[~azure.mgmt.azurearcdata.models.DataControllerResource]
:keyword next_link: Link to retrieve next page of results.
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class PostgresInstance(TrackedResource):
"""A Postgres Instance.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurearcdata.models.ExtendedLocation
:ivar properties: null. Required.
:vartype properties: ~azure.mgmt.azurearcdata.models.PostgresInstanceProperties
:ivar sku: Resource sku.
:vartype sku: ~azure.mgmt.azurearcdata.models.PostgresInstanceSku
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"location": {"required": True},
"properties": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"properties": {"key": "properties", "type": "PostgresInstanceProperties"},
"sku": {"key": "sku", "type": "PostgresInstanceSku"},
}
def __init__(
self,
*,
location: str,
properties: "_models.PostgresInstanceProperties",
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
sku: Optional["_models.PostgresInstanceSku"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurearcdata.models.ExtendedLocation
:keyword properties: null. Required.
:paramtype properties: ~azure.mgmt.azurearcdata.models.PostgresInstanceProperties
:keyword sku: Resource sku.
:paramtype sku: ~azure.mgmt.azurearcdata.models.PostgresInstanceSku
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.properties = properties
self.sku = sku
class PostgresInstanceListResult(_serialization.Model):
"""A list of PostgresInstance.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: Array of results.
:vartype value: list[~azure.mgmt.azurearcdata.models.PostgresInstance]
:ivar next_link: Link to retrieve next page of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[PostgresInstance]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class PostgresInstanceProperties(_serialization.Model):
"""Postgres Instance properties.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar data_controller_id: The data controller id.
:vartype data_controller_id: str
:ivar admin: The instance admin.
:vartype admin: str
:ivar basic_login_information: Username and password for basic authentication.
:vartype basic_login_information: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:ivar k8_s_raw: The raw kubernetes information.
:vartype k8_s_raw: JSON
:ivar last_uploaded_date: Last uploaded date from Kubernetes cluster. Defaults to current date
time.
:vartype last_uploaded_date: ~datetime.datetime
:ivar provisioning_state: The provisioning state of the Azure Arc-enabled PostgreSQL instance.
:vartype provisioning_state: str
"""
_validation = {
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"data_controller_id": {"key": "dataControllerId", "type": "str"},
"admin": {"key": "admin", "type": "str"},
"basic_login_information": {"key": "basicLoginInformation", "type": "BasicLoginInformation"},
"k8_s_raw": {"key": "k8sRaw", "type": "object"},
"last_uploaded_date": {"key": "lastUploadedDate", "type": "iso-8601"},
"provisioning_state": {"key": "provisioningState", "type": "str"},
}
def __init__(
self,
*,
data_controller_id: Optional[str] = None,
admin: Optional[str] = None,
basic_login_information: Optional["_models.BasicLoginInformation"] = None,
k8_s_raw: Optional[JSON] = None,
last_uploaded_date: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword data_controller_id: The data controller id.
:paramtype data_controller_id: str
:keyword admin: The instance admin.
:paramtype admin: str
:keyword basic_login_information: Username and password for basic authentication.
:paramtype basic_login_information: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:keyword k8_s_raw: The raw kubernetes information.
:paramtype k8_s_raw: JSON
:keyword last_uploaded_date: Last uploaded date from Kubernetes cluster. Defaults to current
date time.
:paramtype last_uploaded_date: ~datetime.datetime
"""
super().__init__(**kwargs)
self.data_controller_id = data_controller_id
self.admin = admin
self.basic_login_information = basic_login_information
self.k8_s_raw = k8_s_raw
self.last_uploaded_date = last_uploaded_date
self.provisioning_state = None
class PostgresInstanceSku(CommonSku):
"""The resource model definition representing SKU for Azure Database for PostgresSQL - Azure Arc.
All required parameters must be populated in order to send to Azure.
:ivar name: The name of the SKU. It is typically a letter+number code. Required.
:vartype name: str
:ivar dev: Whether dev/test is enabled. When the dev field is set to true, the resource is used
for dev/test purpose.
:vartype dev: bool
:ivar size: The SKU size. When the name field is the combination of tier and some other value,
this would be the standalone code.
:vartype size: str
:ivar family: If the service has different generations of hardware, for the same SKU, then that
can be captured here.
:vartype family: str
:ivar capacity: If the SKU supports scale out/in then the capacity integer should be included.
If scale out/in is not possible for the resource this may be omitted.
:vartype capacity: int
:ivar tier: This field is required to be implemented by the Resource Provider if the service
has more than one tier. Default value is "Hyperscale".
:vartype tier: str
"""
_validation = {
"name": {"required": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"dev": {"key": "dev", "type": "bool"},
"size": {"key": "size", "type": "str"},
"family": {"key": "family", "type": "str"},
"capacity": {"key": "capacity", "type": "int"},
"tier": {"key": "tier", "type": "str"},
}
def __init__(
self,
*,
name: str,
dev: bool = True,
size: Optional[str] = None,
family: Optional[str] = None,
capacity: Optional[int] = None,
tier: Literal["Hyperscale"] = "Hyperscale",
**kwargs
):
"""
:keyword name: The name of the SKU. It is typically a letter+number code. Required.
:paramtype name: str
:keyword dev: Whether dev/test is enabled. When the dev field is set to true, the resource is
used for dev/test purpose.
:paramtype dev: bool
:keyword size: The SKU size. When the name field is the combination of tier and some other
value, this would be the standalone code.
:paramtype size: str
:keyword family: If the service has different generations of hardware, for the same SKU, then
that can be captured here.
:paramtype family: str
:keyword capacity: If the SKU supports scale out/in then the capacity integer should be
included. If scale out/in is not possible for the resource this may be omitted.
:paramtype capacity: int
:keyword tier: This field is required to be implemented by the Resource Provider if the service
has more than one tier. Default value is "Hyperscale".
:paramtype tier: str
"""
super().__init__(name=name, dev=dev, size=size, family=family, capacity=capacity, **kwargs)
self.tier = tier
class PostgresInstanceUpdate(_serialization.Model):
"""An update to a Postgres Instance.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar properties: Postgres Instance properties.
:vartype properties: ~azure.mgmt.azurearcdata.models.PostgresInstanceProperties
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
"properties": {"key": "properties", "type": "PostgresInstanceProperties"},
}
def __init__(
self,
*,
tags: Optional[Dict[str, str]] = None,
properties: Optional["_models.PostgresInstanceProperties"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword properties: Postgres Instance properties.
:paramtype properties: ~azure.mgmt.azurearcdata.models.PostgresInstanceProperties
"""
super().__init__(**kwargs)
self.tags = tags
self.properties = properties
class SqlManagedInstance(TrackedResource):
"""A SqlManagedInstance.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar properties: null. Required.
:vartype properties: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceProperties
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurearcdata.models.ExtendedLocation
:ivar sku: Resource sku.
:vartype sku: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceSku
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"location": {"required": True},
"properties": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"properties": {"key": "properties", "type": "SqlManagedInstanceProperties"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"sku": {"key": "sku", "type": "SqlManagedInstanceSku"},
}
def __init__(
self,
*,
location: str,
properties: "_models.SqlManagedInstanceProperties",
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
sku: Optional["_models.SqlManagedInstanceSku"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword properties: null. Required.
:paramtype properties: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceProperties
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurearcdata.models.ExtendedLocation
:keyword sku: Resource sku.
:paramtype sku: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceSku
"""
super().__init__(tags=tags, location=location, **kwargs)
self.properties = properties
self.extended_location = extended_location
self.sku = sku
class SqlManagedInstanceK8SRaw(_serialization.Model):
"""The raw kubernetes information.
:ivar additional_properties: Unmatched properties from the message are deserialized to this
collection.
:vartype additional_properties: dict[str, JSON]
:ivar spec: The kubernetes spec information.
:vartype spec: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceK8SSpec
"""
_attribute_map = {
"additional_properties": {"key": "", "type": "{object}"},
"spec": {"key": "spec", "type": "SqlManagedInstanceK8SSpec"},
}
def __init__(
self,
*,
additional_properties: Optional[Dict[str, JSON]] = None,
spec: Optional["_models.SqlManagedInstanceK8SSpec"] = None,
**kwargs
):
"""
:keyword additional_properties: Unmatched properties from the message are deserialized to this
collection.
:paramtype additional_properties: dict[str, JSON]
:keyword spec: The kubernetes spec information.
:paramtype spec: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceK8SSpec
"""
super().__init__(**kwargs)
self.additional_properties = additional_properties
self.spec = spec
class SqlManagedInstanceK8SSpec(_serialization.Model):
"""The kubernetes spec information.
:ivar additional_properties: Unmatched properties from the message are deserialized to this
collection.
:vartype additional_properties: dict[str, JSON]
:ivar scheduling: The kubernetes scheduling information.
:vartype scheduling: ~azure.mgmt.azurearcdata.models.K8SScheduling
:ivar replicas: This option specifies the number of SQL Managed Instance replicas that will be
deployed in your Kubernetes cluster for high availability purposes. If sku.tier is
BusinessCritical, allowed values are '2' or '3' with default of '3'. If sku.tier is
GeneralPurpose, replicas must be '1'.
:vartype replicas: int
"""
_attribute_map = {
"additional_properties": {"key": "", "type": "{object}"},
"scheduling": {"key": "scheduling", "type": "K8SScheduling"},
"replicas": {"key": "replicas", "type": "int"},
}
def __init__(
self,
*,
additional_properties: Optional[Dict[str, JSON]] = None,
scheduling: Optional["_models.K8SScheduling"] = None,
replicas: Optional[int] = None,
**kwargs
):
"""
:keyword additional_properties: Unmatched properties from the message are deserialized to this
collection.
:paramtype additional_properties: dict[str, JSON]
:keyword scheduling: The kubernetes scheduling information.
:paramtype scheduling: ~azure.mgmt.azurearcdata.models.K8SScheduling
:keyword replicas: This option specifies the number of SQL Managed Instance replicas that will
be deployed in your Kubernetes cluster for high availability purposes. If sku.tier is
BusinessCritical, allowed values are '2' or '3' with default of '3'. If sku.tier is
GeneralPurpose, replicas must be '1'.
:paramtype replicas: int
"""
super().__init__(**kwargs)
self.additional_properties = additional_properties
self.scheduling = scheduling
self.replicas = replicas
class SqlManagedInstanceListResult(_serialization.Model):
"""A list of SqlManagedInstance.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: Array of results.
:vartype value: list[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:ivar next_link: Link to retrieve next page of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[SqlManagedInstance]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class SqlManagedInstanceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""Properties of sqlManagedInstance.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar data_controller_id: null.
:vartype data_controller_id: str
:ivar admin: The instance admin user.
:vartype admin: str
:ivar start_time: The instance start time.
:vartype start_time: str
:ivar end_time: The instance end time.
:vartype end_time: str
:ivar k8_s_raw: The raw kubernetes information.
:vartype k8_s_raw: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceK8SRaw
:ivar basic_login_information: Username and password for basic authentication.
:vartype basic_login_information: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:ivar last_uploaded_date: Last uploaded date from Kubernetes cluster. Defaults to current date
time.
:vartype last_uploaded_date: ~datetime.datetime
:ivar provisioning_state: The provisioning state of the Arc-enabled SQL Managed Instance
resource.
:vartype provisioning_state: str
:ivar active_directory_information: Active Directory information related to this SQL Managed
Instance.
:vartype active_directory_information:
~azure.mgmt.azurearcdata.models.ActiveDirectoryInformation
:ivar license_type: The license type to apply for this managed instance. Known values are:
"BasePrice", "LicenseIncluded", and "DisasterRecovery".
:vartype license_type: str or ~azure.mgmt.azurearcdata.models.ArcSqlManagedInstanceLicenseType
:ivar cluster_id: If a CustomLocation is provided, this contains the ARM id of the connected
cluster the custom location belongs to.
:vartype cluster_id: str
:ivar extension_id: If a CustomLocation is provided, this contains the ARM id of the extension
the custom location belongs to.
:vartype extension_id: str
"""
_validation = {
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"data_controller_id": {"key": "dataControllerId", "type": "str"},
"admin": {"key": "admin", "type": "str"},
"start_time": {"key": "startTime", "type": "str"},
"end_time": {"key": "endTime", "type": "str"},
"k8_s_raw": {"key": "k8sRaw", "type": "SqlManagedInstanceK8SRaw"},
"basic_login_information": {"key": "basicLoginInformation", "type": "BasicLoginInformation"},
"last_uploaded_date": {"key": "lastUploadedDate", "type": "iso-8601"},
"provisioning_state": {"key": "provisioningState", "type": "str"},
"active_directory_information": {"key": "activeDirectoryInformation", "type": "ActiveDirectoryInformation"},
"license_type": {"key": "licenseType", "type": "str"},
"cluster_id": {"key": "clusterId", "type": "str"},
"extension_id": {"key": "extensionId", "type": "str"},
}
def __init__(
self,
*,
data_controller_id: Optional[str] = None,
admin: Optional[str] = None,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
k8_s_raw: Optional["_models.SqlManagedInstanceK8SRaw"] = None,
basic_login_information: Optional["_models.BasicLoginInformation"] = None,
last_uploaded_date: Optional[datetime.datetime] = None,
active_directory_information: Optional["_models.ActiveDirectoryInformation"] = None,
license_type: Union[str, "_models.ArcSqlManagedInstanceLicenseType"] = "BasePrice",
cluster_id: Optional[str] = None,
extension_id: Optional[str] = None,
**kwargs
):
"""
:keyword data_controller_id: null.
:paramtype data_controller_id: str
:keyword admin: The instance admin user.
:paramtype admin: str
:keyword start_time: The instance start time.
:paramtype start_time: str
:keyword end_time: The instance end time.
:paramtype end_time: str
:keyword k8_s_raw: The raw kubernetes information.
:paramtype k8_s_raw: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceK8SRaw
:keyword basic_login_information: Username and password for basic authentication.
:paramtype basic_login_information: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:keyword last_uploaded_date: Last uploaded date from Kubernetes cluster. Defaults to current
date time.
:paramtype last_uploaded_date: ~datetime.datetime
:keyword active_directory_information: Active Directory information related to this SQL Managed
Instance.
:paramtype active_directory_information:
~azure.mgmt.azurearcdata.models.ActiveDirectoryInformation
:keyword license_type: The license type to apply for this managed instance. Known values are:
"BasePrice", "LicenseIncluded", and "DisasterRecovery".
:paramtype license_type: str or
~azure.mgmt.azurearcdata.models.ArcSqlManagedInstanceLicenseType
:keyword cluster_id: If a CustomLocation is provided, this contains the ARM id of the connected
cluster the custom location belongs to.
:paramtype cluster_id: str
:keyword extension_id: If a CustomLocation is provided, this contains the ARM id of the
extension the custom location belongs to.
:paramtype extension_id: str
"""
super().__init__(**kwargs)
self.data_controller_id = data_controller_id
self.admin = admin
self.start_time = start_time
self.end_time = end_time
self.k8_s_raw = k8_s_raw
self.basic_login_information = basic_login_information
self.last_uploaded_date = last_uploaded_date
self.provisioning_state = None
self.active_directory_information = active_directory_information
self.license_type = license_type
self.cluster_id = cluster_id
self.extension_id = extension_id
class SqlManagedInstanceSku(_serialization.Model):
"""The resource model definition representing SKU for Azure Managed Instance - Azure Arc.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar name: The name of the SKU. Required. Default value is "vCore".
:vartype name: str
:ivar tier: The pricing tier for the instance. Known values are: "GeneralPurpose" and
"BusinessCritical".
:vartype tier: str or ~azure.mgmt.azurearcdata.models.SqlManagedInstanceSkuTier
:ivar dev: Whether dev/test is enabled. When the dev field is set to true, the resource is used
for dev/test purpose.
:vartype dev: bool
:ivar size: The SKU size. When the name field is the combination of tier and some other value,
this would be the standalone code.
:vartype size: str
:ivar family: The SKU family.
:vartype family: str
:ivar capacity: The SKU capacity.
:vartype capacity: int
"""
_validation = {
"name": {"required": True, "constant": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"tier": {"key": "tier", "type": "str"},
"dev": {"key": "dev", "type": "bool"},
"size": {"key": "size", "type": "str"},
"family": {"key": "family", "type": "str"},
"capacity": {"key": "capacity", "type": "int"},
}
name = "vCore"
def __init__(
self,
*,
tier: Union[str, "_models.SqlManagedInstanceSkuTier"] = "GeneralPurpose",
dev: bool = True,
size: Optional[str] = None,
family: Optional[str] = None,
capacity: Optional[int] = None,
**kwargs
):
"""
:keyword tier: The pricing tier for the instance. Known values are: "GeneralPurpose" and
"BusinessCritical".
:paramtype tier: str or ~azure.mgmt.azurearcdata.models.SqlManagedInstanceSkuTier
:keyword dev: Whether dev/test is enabled. When the dev field is set to true, the resource is
used for dev/test purpose.
:paramtype dev: bool
:keyword size: The SKU size. When the name field is the combination of tier and some other
value, this would be the standalone code.
:paramtype size: str
:keyword family: The SKU family.
:paramtype family: str
:keyword capacity: The SKU capacity.
:paramtype capacity: int
"""
super().__init__(**kwargs)
self.tier = tier
self.dev = dev
self.size = size
self.family = family
self.capacity = capacity
class SqlManagedInstanceUpdate(_serialization.Model):
"""An update to a SQL Managed Instance.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class SqlServerInstance(TrackedResource):
"""A SqlServerInstance.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar properties: null.
:vartype properties: ~azure.mgmt.azurearcdata.models.SqlServerInstanceProperties
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"location": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"properties": {"key": "properties", "type": "SqlServerInstanceProperties"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
properties: Optional["_models.SqlServerInstanceProperties"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword properties: null.
:paramtype properties: ~azure.mgmt.azurearcdata.models.SqlServerInstanceProperties
"""
super().__init__(tags=tags, location=location, **kwargs)
self.properties = properties
class SqlServerInstanceListResult(_serialization.Model):
"""A list of SqlServerInstance.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: Array of results.
:vartype value: list[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:ivar next_link: Link to retrieve next page of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[SqlServerInstance]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class SqlServerInstanceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""Properties of SqlServerInstance.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar version: SQL Server version. Known values are: "SQL Server 2012", "SQL Server 2014", "SQL
Server 2016", "SQL Server 2017", "SQL Server 2019", "SQL Server 2022", and "Unknown".
:vartype version: str or ~azure.mgmt.azurearcdata.models.SqlVersion
:ivar edition: SQL Server edition. Known values are: "Evaluation", "Enterprise", "Standard",
"Web", "Developer", and "Express".
:vartype edition: str or ~azure.mgmt.azurearcdata.models.EditionType
:ivar container_resource_id: ARM Resource id of the container resource (Azure Arc for Servers).
Required.
:vartype container_resource_id: str
:ivar create_time: The time when the resource was created.
:vartype create_time: str
:ivar v_core: The number of logical processors used by the SQL Server instance.
:vartype v_core: str
:ivar status: The cloud connectivity status. Required. Known values are: "Connected",
"Disconnected", "Registered", and "Unknown".
:vartype status: str or ~azure.mgmt.azurearcdata.models.ConnectionStatus
:ivar patch_level: SQL Server update level.
:vartype patch_level: str
:ivar collation: SQL Server collation.
:vartype collation: str
:ivar current_version: SQL Server current version.
:vartype current_version: str
:ivar instance_name: SQL Server instance name.
:vartype instance_name: str
:ivar tcp_dynamic_ports: Dynamic TCP ports used by SQL Server.
:vartype tcp_dynamic_ports: str
:ivar tcp_static_ports: Static TCP ports used by SQL Server.
:vartype tcp_static_ports: str
:ivar product_id: SQL Server product ID.
:vartype product_id: str
:ivar license_type: SQL Server license type. Known values are: "Undefined", "Free", "HADR",
"ServerCAL", "LicenseOnly", "PAYG", and "Paid".
:vartype license_type: str or ~azure.mgmt.azurearcdata.models.ArcSqlServerLicenseType
:ivar azure_defender_status_last_updated: Timestamp of last Azure Defender status update.
:vartype azure_defender_status_last_updated: ~datetime.datetime
:ivar azure_defender_status: Status of Azure Defender. Known values are: "Protected",
"Unprotected", and "Unknown".
:vartype azure_defender_status: str or ~azure.mgmt.azurearcdata.models.DefenderStatus
:ivar provisioning_state: The provisioning state of the Arc-enabled SQL Server resource.
:vartype provisioning_state: str
:ivar host_type: Type of host for Azure Arc SQL Server. Known values are: "Azure Virtual
Machine", "Azure VMWare Virtual Machine", "Azure Kubernetes Service", "AWS VMWare Virtual
Machine", "AWS Kubernetes Service", "GCP VMWare Virtual Machine", "GCP Kubernetes Service",
"Container", "Virtual Machine", "Physical Server", "AWS Virtual Machine", "GCP Virtual
Machine", and "Other".
:vartype host_type: str or ~azure.mgmt.azurearcdata.models.HostType
"""
_validation = {
"container_resource_id": {"required": True},
"create_time": {"readonly": True},
"status": {"required": True},
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"version": {"key": "version", "type": "str"},
"edition": {"key": "edition", "type": "str"},
"container_resource_id": {"key": "containerResourceId", "type": "str"},
"create_time": {"key": "createTime", "type": "str"},
"v_core": {"key": "vCore", "type": "str"},
"status": {"key": "status", "type": "str"},
"patch_level": {"key": "patchLevel", "type": "str"},
"collation": {"key": "collation", "type": "str"},
"current_version": {"key": "currentVersion", "type": "str"},
"instance_name": {"key": "instanceName", "type": "str"},
"tcp_dynamic_ports": {"key": "tcpDynamicPorts", "type": "str"},
"tcp_static_ports": {"key": "tcpStaticPorts", "type": "str"},
"product_id": {"key": "productId", "type": "str"},
"license_type": {"key": "licenseType", "type": "str"},
"azure_defender_status_last_updated": {"key": "azureDefenderStatusLastUpdated", "type": "iso-8601"},
"azure_defender_status": {"key": "azureDefenderStatus", "type": "str"},
"provisioning_state": {"key": "provisioningState", "type": "str"},
"host_type": {"key": "hostType", "type": "str"},
}
def __init__(
self,
*,
container_resource_id: str,
status: Union[str, "_models.ConnectionStatus"],
version: Optional[Union[str, "_models.SqlVersion"]] = None,
edition: Optional[Union[str, "_models.EditionType"]] = None,
v_core: Optional[str] = None,
patch_level: Optional[str] = None,
collation: Optional[str] = None,
current_version: Optional[str] = None,
instance_name: Optional[str] = None,
tcp_dynamic_ports: Optional[str] = None,
tcp_static_ports: Optional[str] = None,
product_id: Optional[str] = None,
license_type: Optional[Union[str, "_models.ArcSqlServerLicenseType"]] = None,
azure_defender_status_last_updated: Optional[datetime.datetime] = None,
azure_defender_status: Optional[Union[str, "_models.DefenderStatus"]] = None,
host_type: Optional[Union[str, "_models.HostType"]] = None,
**kwargs
):
"""
:keyword version: SQL Server version. Known values are: "SQL Server 2012", "SQL Server 2014",
"SQL Server 2016", "SQL Server 2017", "SQL Server 2019", "SQL Server 2022", and "Unknown".
:paramtype version: str or ~azure.mgmt.azurearcdata.models.SqlVersion
:keyword edition: SQL Server edition. Known values are: "Evaluation", "Enterprise", "Standard",
"Web", "Developer", and "Express".
:paramtype edition: str or ~azure.mgmt.azurearcdata.models.EditionType
:keyword container_resource_id: ARM Resource id of the container resource (Azure Arc for
Servers). Required.
:paramtype container_resource_id: str
:keyword v_core: The number of logical processors used by the SQL Server instance.
:paramtype v_core: str
:keyword status: The cloud connectivity status. Required. Known values are: "Connected",
"Disconnected", "Registered", and "Unknown".
:paramtype status: str or ~azure.mgmt.azurearcdata.models.ConnectionStatus
:keyword patch_level: SQL Server update level.
:paramtype patch_level: str
:keyword collation: SQL Server collation.
:paramtype collation: str
:keyword current_version: SQL Server current version.
:paramtype current_version: str
:keyword instance_name: SQL Server instance name.
:paramtype instance_name: str
:keyword tcp_dynamic_ports: Dynamic TCP ports used by SQL Server.
:paramtype tcp_dynamic_ports: str
:keyword tcp_static_ports: Static TCP ports used by SQL Server.
:paramtype tcp_static_ports: str
:keyword product_id: SQL Server product ID.
:paramtype product_id: str
:keyword license_type: SQL Server license type. Known values are: "Undefined", "Free", "HADR",
"ServerCAL", "LicenseOnly", "PAYG", and "Paid".
:paramtype license_type: str or ~azure.mgmt.azurearcdata.models.ArcSqlServerLicenseType
:keyword azure_defender_status_last_updated: Timestamp of last Azure Defender status update.
:paramtype azure_defender_status_last_updated: ~datetime.datetime
:keyword azure_defender_status: Status of Azure Defender. Known values are: "Protected",
"Unprotected", and "Unknown".
:paramtype azure_defender_status: str or ~azure.mgmt.azurearcdata.models.DefenderStatus
:keyword host_type: Type of host for Azure Arc SQL Server. Known values are: "Azure Virtual
Machine", "Azure VMWare Virtual Machine", "Azure Kubernetes Service", "AWS VMWare Virtual
Machine", "AWS Kubernetes Service", "GCP VMWare Virtual Machine", "GCP Kubernetes Service",
"Container", "Virtual Machine", "Physical Server", "AWS Virtual Machine", "GCP Virtual
Machine", and "Other".
:paramtype host_type: str or ~azure.mgmt.azurearcdata.models.HostType
"""
super().__init__(**kwargs)
self.version = version
self.edition = edition
self.container_resource_id = container_resource_id
self.create_time = None
self.v_core = v_core
self.status = status
self.patch_level = patch_level
self.collation = collation
self.current_version = current_version
self.instance_name = instance_name
self.tcp_dynamic_ports = tcp_dynamic_ports
self.tcp_static_ports = tcp_static_ports
self.product_id = product_id
self.license_type = license_type
self.azure_defender_status_last_updated = azure_defender_status_last_updated
self.azure_defender_status = azure_defender_status
self.provisioning_state = None
self.host_type = host_type
class SqlServerInstanceUpdate(_serialization.Model):
"""An update to a SQL Server Instance.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class SystemData(_serialization.Model):
"""Metadata pertaining to creation and last modification of the resource.
:ivar created_by: The identity that created the resource.
:vartype created_by: str
:ivar created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:vartype created_by_type: str or ~azure.mgmt.azurearcdata.models.CreatedByType
:ivar created_at: The timestamp of resource creation (UTC).
:vartype created_at: ~datetime.datetime
:ivar last_modified_by: The identity that last modified the resource.
:vartype last_modified_by: str
:ivar last_modified_by_type: The type of identity that last modified the resource. Known values
are: "User", "Application", "ManagedIdentity", and "Key".
:vartype last_modified_by_type: str or ~azure.mgmt.azurearcdata.models.CreatedByType
:ivar last_modified_at: The timestamp of resource last modification (UTC).
:vartype last_modified_at: ~datetime.datetime
"""
_attribute_map = {
"created_by": {"key": "createdBy", "type": "str"},
"created_by_type": {"key": "createdByType", "type": "str"},
"created_at": {"key": "createdAt", "type": "iso-8601"},
"last_modified_by": {"key": "lastModifiedBy", "type": "str"},
"last_modified_by_type": {"key": "lastModifiedByType", "type": "str"},
"last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"},
}
def __init__(
self,
*,
created_by: Optional[str] = None,
created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
created_at: Optional[datetime.datetime] = None,
last_modified_by: Optional[str] = None,
last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
last_modified_at: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword created_by: The identity that created the resource.
:paramtype created_by: str
:keyword created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:paramtype created_by_type: str or ~azure.mgmt.azurearcdata.models.CreatedByType
:keyword created_at: The timestamp of resource creation (UTC).
:paramtype created_at: ~datetime.datetime
:keyword last_modified_by: The identity that last modified the resource.
:paramtype last_modified_by: str
:keyword last_modified_by_type: The type of identity that last modified the resource. Known
values are: "User", "Application", "ManagedIdentity", and "Key".
:paramtype last_modified_by_type: str or ~azure.mgmt.azurearcdata.models.CreatedByType
:keyword last_modified_at: The timestamp of resource last modification (UTC).
:paramtype last_modified_at: ~datetime.datetime
"""
super().__init__(**kwargs)
self.created_by = created_by
self.created_by_type = created_by_type
self.created_at = created_at
self.last_modified_by = last_modified_by
self.last_modified_by_type = last_modified_by_type
self.last_modified_at = last_modified_at
class UploadServicePrincipal(_serialization.Model):
"""Service principal for uploading billing, metrics and logs.
:ivar client_id: Client ID of the service principal for uploading data.
:vartype client_id: str
:ivar tenant_id: Tenant ID of the service principal.
:vartype tenant_id: str
:ivar authority: Authority for the service principal. Example:
https://login.microsoftonline.com/.
:vartype authority: str
:ivar client_secret: Secret of the service principal.
:vartype client_secret: str
"""
_attribute_map = {
"client_id": {"key": "clientId", "type": "str"},
"tenant_id": {"key": "tenantId", "type": "str"},
"authority": {"key": "authority", "type": "str"},
"client_secret": {"key": "clientSecret", "type": "str"},
}
def __init__(
self,
*,
client_id: Optional[str] = None,
tenant_id: Optional[str] = None,
authority: Optional[str] = None,
client_secret: Optional[str] = None,
**kwargs
):
"""
:keyword client_id: Client ID of the service principal for uploading data.
:paramtype client_id: str
:keyword tenant_id: Tenant ID of the service principal.
:paramtype tenant_id: str
:keyword authority: Authority for the service principal. Example:
https://login.microsoftonline.com/.
:paramtype authority: str
:keyword client_secret: Secret of the service principal.
:paramtype client_secret: str
"""
super().__init__(**kwargs)
self.client_id = client_id
self.tenant_id = tenant_id
self.authority = authority
self.client_secret = client_secret
class UploadWatermark(_serialization.Model):
"""Properties on upload watermark. Mostly timestamp for each upload data type.
:ivar metrics: Last uploaded date for metrics from kubernetes cluster. Defaults to current date
time.
:vartype metrics: ~datetime.datetime
:ivar logs: Last uploaded date for logs from kubernetes cluster. Defaults to current date time.
:vartype logs: ~datetime.datetime
:ivar usages: Last uploaded date for usages from kubernetes cluster. Defaults to current date
time.
:vartype usages: ~datetime.datetime
"""
_attribute_map = {
"metrics": {"key": "metrics", "type": "iso-8601"},
"logs": {"key": "logs", "type": "iso-8601"},
"usages": {"key": "usages", "type": "iso-8601"},
}
def __init__(
self,
*,
metrics: Optional[datetime.datetime] = None,
logs: Optional[datetime.datetime] = None,
usages: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword metrics: Last uploaded date for metrics from kubernetes cluster. Defaults to current
date time.
:paramtype metrics: ~datetime.datetime
:keyword logs: Last uploaded date for logs from kubernetes cluster. Defaults to current date
time.
:paramtype logs: ~datetime.datetime
:keyword usages: Last uploaded date for usages from kubernetes cluster. Defaults to current
date time.
:paramtype usages: ~datetime.datetime
"""
super().__init__(**kwargs)
self.metrics = metrics
self.logs = logs
self.usages = usages
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/models/_models_py3.py
|
_models_py3.py
|
import datetime
import sys
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union
from .. import _serialization
if sys.version_info >= (3, 9):
from collections.abc import MutableMapping
else:
from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from .. import models as _models
JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object
class ActiveDirectoryConnectorDNSDetails(_serialization.Model):
"""DNS server details.
All required parameters must be populated in order to send to Azure.
:ivar domain_name: DNS domain name for which DNS lookups should be forwarded to the Active
Directory DNS servers.
:vartype domain_name: str
:ivar nameserver_ip_addresses: List of Active Directory DNS server IP addresses. Required.
:vartype nameserver_ip_addresses: list[str]
:ivar replicas: Replica count for DNS proxy service. Default value is 1.
:vartype replicas: int
:ivar prefer_k8_s_dns_for_ptr_lookups: Flag indicating whether to prefer Kubernetes DNS server
response over AD DNS server response for IP address lookups.
:vartype prefer_k8_s_dns_for_ptr_lookups: bool
"""
_validation = {
"nameserver_ip_addresses": {"required": True},
}
_attribute_map = {
"domain_name": {"key": "domainName", "type": "str"},
"nameserver_ip_addresses": {"key": "nameserverIPAddresses", "type": "[str]"},
"replicas": {"key": "replicas", "type": "int"},
"prefer_k8_s_dns_for_ptr_lookups": {"key": "preferK8sDnsForPtrLookups", "type": "bool"},
}
def __init__(
self,
*,
nameserver_ip_addresses: List[str],
domain_name: Optional[str] = None,
replicas: int = 1,
prefer_k8_s_dns_for_ptr_lookups: bool = True,
**kwargs
):
"""
:keyword domain_name: DNS domain name for which DNS lookups should be forwarded to the Active
Directory DNS servers.
:paramtype domain_name: str
:keyword nameserver_ip_addresses: List of Active Directory DNS server IP addresses. Required.
:paramtype nameserver_ip_addresses: list[str]
:keyword replicas: Replica count for DNS proxy service. Default value is 1.
:paramtype replicas: int
:keyword prefer_k8_s_dns_for_ptr_lookups: Flag indicating whether to prefer Kubernetes DNS
server response over AD DNS server response for IP address lookups.
:paramtype prefer_k8_s_dns_for_ptr_lookups: bool
"""
super().__init__(**kwargs)
self.domain_name = domain_name
self.nameserver_ip_addresses = nameserver_ip_addresses
self.replicas = replicas
self.prefer_k8_s_dns_for_ptr_lookups = prefer_k8_s_dns_for_ptr_lookups
class ActiveDirectoryConnectorDomainDetails(_serialization.Model):
"""Active Directory domain details.
All required parameters must be populated in order to send to Azure.
:ivar realm: Name (uppercase) of the Active Directory domain that this AD connector will be
associated with. Required.
:vartype realm: str
:ivar netbios_domain_name: NETBIOS name of the Active Directory domain.
:vartype netbios_domain_name: str
:ivar service_account_provisioning: The service account provisioning mode for this Active
Directory connector. Known values are: "automatic" and "manual".
:vartype service_account_provisioning: str or
~azure.mgmt.azurearcdata.models.AccountProvisioningMode
:ivar ou_distinguished_name: The distinguished name of the Active Directory Organizational
Unit.
:vartype ou_distinguished_name: str
:ivar domain_controllers: null. Required.
:vartype domain_controllers: ~azure.mgmt.azurearcdata.models.ActiveDirectoryDomainControllers
"""
_validation = {
"realm": {"required": True},
"domain_controllers": {"required": True},
}
_attribute_map = {
"realm": {"key": "realm", "type": "str"},
"netbios_domain_name": {"key": "netbiosDomainName", "type": "str"},
"service_account_provisioning": {"key": "serviceAccountProvisioning", "type": "str"},
"ou_distinguished_name": {"key": "ouDistinguishedName", "type": "str"},
"domain_controllers": {"key": "domainControllers", "type": "ActiveDirectoryDomainControllers"},
}
def __init__(
self,
*,
realm: str,
domain_controllers: "_models.ActiveDirectoryDomainControllers",
netbios_domain_name: Optional[str] = None,
service_account_provisioning: Union[str, "_models.AccountProvisioningMode"] = "manual",
ou_distinguished_name: Optional[str] = None,
**kwargs
):
"""
:keyword realm: Name (uppercase) of the Active Directory domain that this AD connector will be
associated with. Required.
:paramtype realm: str
:keyword netbios_domain_name: NETBIOS name of the Active Directory domain.
:paramtype netbios_domain_name: str
:keyword service_account_provisioning: The service account provisioning mode for this Active
Directory connector. Known values are: "automatic" and "manual".
:paramtype service_account_provisioning: str or
~azure.mgmt.azurearcdata.models.AccountProvisioningMode
:keyword ou_distinguished_name: The distinguished name of the Active Directory Organizational
Unit.
:paramtype ou_distinguished_name: str
:keyword domain_controllers: null. Required.
:paramtype domain_controllers: ~azure.mgmt.azurearcdata.models.ActiveDirectoryDomainControllers
"""
super().__init__(**kwargs)
self.realm = realm
self.netbios_domain_name = netbios_domain_name
self.service_account_provisioning = service_account_provisioning
self.ou_distinguished_name = ou_distinguished_name
self.domain_controllers = domain_controllers
class ActiveDirectoryConnectorListResult(_serialization.Model):
"""A list of active directory connectors.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: Array of results.
:vartype value: list[~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorResource]
:ivar next_link: Link to retrieve next page of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[ActiveDirectoryConnectorResource]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class ActiveDirectoryConnectorProperties(_serialization.Model):
"""The properties of an Active Directory connector resource.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar domain_service_account_login_information: Username and password for domain service
account authentication.
:vartype domain_service_account_login_information:
~azure.mgmt.azurearcdata.models.BasicLoginInformation
:ivar provisioning_state: The provisioning state of the Active Directory connector resource.
:vartype provisioning_state: str
:ivar spec: null. Required.
:vartype spec: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorSpec
:ivar status: null.
:vartype status: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorStatus
"""
_validation = {
"provisioning_state": {"readonly": True},
"spec": {"required": True},
}
_attribute_map = {
"domain_service_account_login_information": {
"key": "domainServiceAccountLoginInformation",
"type": "BasicLoginInformation",
},
"provisioning_state": {"key": "provisioningState", "type": "str"},
"spec": {"key": "spec", "type": "ActiveDirectoryConnectorSpec"},
"status": {"key": "status", "type": "ActiveDirectoryConnectorStatus"},
}
def __init__(
self,
*,
spec: "_models.ActiveDirectoryConnectorSpec",
domain_service_account_login_information: Optional["_models.BasicLoginInformation"] = None,
status: Optional["_models.ActiveDirectoryConnectorStatus"] = None,
**kwargs
):
"""
:keyword domain_service_account_login_information: Username and password for domain service
account authentication.
:paramtype domain_service_account_login_information:
~azure.mgmt.azurearcdata.models.BasicLoginInformation
:keyword spec: null. Required.
:paramtype spec: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorSpec
:keyword status: null.
:paramtype status: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorStatus
"""
super().__init__(**kwargs)
self.domain_service_account_login_information = domain_service_account_login_information
self.provisioning_state = None
self.spec = spec
self.status = status
class Resource(_serialization.Model):
"""Common fields that are returned in the response for all Azure Resource Manager resources.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.id = None
self.name = None
self.type = None
self.system_data = None
class ProxyResource(Resource):
"""The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
class ActiveDirectoryConnectorResource(ProxyResource):
"""Active directory connector resource.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
:ivar properties: null. Required.
:vartype properties: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorProperties
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"properties": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"properties": {"key": "properties", "type": "ActiveDirectoryConnectorProperties"},
}
def __init__(self, *, properties: "_models.ActiveDirectoryConnectorProperties", **kwargs):
"""
:keyword properties: null. Required.
:paramtype properties: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorProperties
"""
super().__init__(**kwargs)
self.properties = properties
class ActiveDirectoryConnectorSpec(_serialization.Model):
"""The specifications of the AD Kubernetes resource.
All required parameters must be populated in order to send to Azure.
:ivar active_directory: null. Required.
:vartype active_directory:
~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorDomainDetails
:ivar dns: null. Required.
:vartype dns: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorDNSDetails
"""
_validation = {
"active_directory": {"required": True},
"dns": {"required": True},
}
_attribute_map = {
"active_directory": {"key": "activeDirectory", "type": "ActiveDirectoryConnectorDomainDetails"},
"dns": {"key": "dns", "type": "ActiveDirectoryConnectorDNSDetails"},
}
def __init__(
self,
*,
active_directory: "_models.ActiveDirectoryConnectorDomainDetails",
dns: "_models.ActiveDirectoryConnectorDNSDetails",
**kwargs
):
"""
:keyword active_directory: null. Required.
:paramtype active_directory:
~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorDomainDetails
:keyword dns: null. Required.
:paramtype dns: ~azure.mgmt.azurearcdata.models.ActiveDirectoryConnectorDNSDetails
"""
super().__init__(**kwargs)
self.active_directory = active_directory
self.dns = dns
class ActiveDirectoryConnectorStatus(_serialization.Model):
"""The status of the Kubernetes custom resource.
:ivar additional_properties: Unmatched properties from the message are deserialized to this
collection.
:vartype additional_properties: dict[str, JSON]
:ivar last_update_time: The time that the custom resource was last updated.
:vartype last_update_time: str
:ivar observed_generation: The version of the replicaSet associated with the AD connector
custom resource.
:vartype observed_generation: int
:ivar state: The state of the AD connector custom resource.
:vartype state: str
"""
_attribute_map = {
"additional_properties": {"key": "", "type": "{object}"},
"last_update_time": {"key": "lastUpdateTime", "type": "str"},
"observed_generation": {"key": "observedGeneration", "type": "int"},
"state": {"key": "state", "type": "str"},
}
def __init__(
self,
*,
additional_properties: Optional[Dict[str, JSON]] = None,
last_update_time: Optional[str] = None,
observed_generation: Optional[int] = None,
state: Optional[str] = None,
**kwargs
):
"""
:keyword additional_properties: Unmatched properties from the message are deserialized to this
collection.
:paramtype additional_properties: dict[str, JSON]
:keyword last_update_time: The time that the custom resource was last updated.
:paramtype last_update_time: str
:keyword observed_generation: The version of the replicaSet associated with the AD connector
custom resource.
:paramtype observed_generation: int
:keyword state: The state of the AD connector custom resource.
:paramtype state: str
"""
super().__init__(**kwargs)
self.additional_properties = additional_properties
self.last_update_time = last_update_time
self.observed_generation = observed_generation
self.state = state
class ActiveDirectoryDomainController(_serialization.Model):
"""Information about a domain controller in the AD domain.
All required parameters must be populated in order to send to Azure.
:ivar hostname: Fully-qualified domain name of a domain controller in the AD domain. Required.
:vartype hostname: str
"""
_validation = {
"hostname": {"required": True},
}
_attribute_map = {
"hostname": {"key": "hostname", "type": "str"},
}
def __init__(self, *, hostname: str, **kwargs):
"""
:keyword hostname: Fully-qualified domain name of a domain controller in the AD domain.
Required.
:paramtype hostname: str
"""
super().__init__(**kwargs)
self.hostname = hostname
class ActiveDirectoryDomainControllers(_serialization.Model):
"""Details about the Active Directory domain controllers associated with this AD connector instance.
:ivar primary_domain_controller: Information about the Primary Domain Controller (PDC) in the
AD domain.
:vartype primary_domain_controller:
~azure.mgmt.azurearcdata.models.ActiveDirectoryDomainController
:ivar secondary_domain_controllers: null.
:vartype secondary_domain_controllers:
list[~azure.mgmt.azurearcdata.models.ActiveDirectoryDomainController]
"""
_attribute_map = {
"primary_domain_controller": {"key": "primaryDomainController", "type": "ActiveDirectoryDomainController"},
"secondary_domain_controllers": {
"key": "secondaryDomainControllers",
"type": "[ActiveDirectoryDomainController]",
},
}
def __init__(
self,
*,
primary_domain_controller: Optional["_models.ActiveDirectoryDomainController"] = None,
secondary_domain_controllers: Optional[List["_models.ActiveDirectoryDomainController"]] = None,
**kwargs
):
"""
:keyword primary_domain_controller: Information about the Primary Domain Controller (PDC) in
the AD domain.
:paramtype primary_domain_controller:
~azure.mgmt.azurearcdata.models.ActiveDirectoryDomainController
:keyword secondary_domain_controllers: null.
:paramtype secondary_domain_controllers:
list[~azure.mgmt.azurearcdata.models.ActiveDirectoryDomainController]
"""
super().__init__(**kwargs)
self.primary_domain_controller = primary_domain_controller
self.secondary_domain_controllers = secondary_domain_controllers
class ActiveDirectoryInformation(_serialization.Model):
"""Active Directory information that related to the resource.
:ivar keytab_information: Keytab information that is used for the Sql Managed Instance when
Active Directory authentication is used.
:vartype keytab_information: ~azure.mgmt.azurearcdata.models.KeytabInformation
"""
_attribute_map = {
"keytab_information": {"key": "keytabInformation", "type": "KeytabInformation"},
}
def __init__(self, *, keytab_information: Optional["_models.KeytabInformation"] = None, **kwargs):
"""
:keyword keytab_information: Keytab information that is used for the Sql Managed Instance when
Active Directory authentication is used.
:paramtype keytab_information: ~azure.mgmt.azurearcdata.models.KeytabInformation
"""
super().__init__(**kwargs)
self.keytab_information = keytab_information
class BasicLoginInformation(_serialization.Model):
"""Username and password for basic login authentication.
:ivar username: Login username.
:vartype username: str
:ivar password: Login password.
:vartype password: str
"""
_attribute_map = {
"username": {"key": "username", "type": "str"},
"password": {"key": "password", "type": "str"},
}
def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs):
"""
:keyword username: Login username.
:paramtype username: str
:keyword password: Login password.
:paramtype password: str
"""
super().__init__(**kwargs)
self.username = username
self.password = password
class CommonSku(_serialization.Model):
"""The resource model definition representing SKU for ARM resources.
All required parameters must be populated in order to send to Azure.
:ivar name: The name of the SKU. It is typically a letter+number code. Required.
:vartype name: str
:ivar dev: Whether dev/test is enabled. When the dev field is set to true, the resource is used
for dev/test purpose.
:vartype dev: bool
:ivar size: The SKU size. When the name field is the combination of tier and some other value,
this would be the standalone code.
:vartype size: str
:ivar family: If the service has different generations of hardware, for the same SKU, then that
can be captured here.
:vartype family: str
:ivar capacity: If the SKU supports scale out/in then the capacity integer should be included.
If scale out/in is not possible for the resource this may be omitted.
:vartype capacity: int
"""
_validation = {
"name": {"required": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"dev": {"key": "dev", "type": "bool"},
"size": {"key": "size", "type": "str"},
"family": {"key": "family", "type": "str"},
"capacity": {"key": "capacity", "type": "int"},
}
def __init__(
self,
*,
name: str,
dev: bool = True,
size: Optional[str] = None,
family: Optional[str] = None,
capacity: Optional[int] = None,
**kwargs
):
"""
:keyword name: The name of the SKU. It is typically a letter+number code. Required.
:paramtype name: str
:keyword dev: Whether dev/test is enabled. When the dev field is set to true, the resource is
used for dev/test purpose.
:paramtype dev: bool
:keyword size: The SKU size. When the name field is the combination of tier and some other
value, this would be the standalone code.
:paramtype size: str
:keyword family: If the service has different generations of hardware, for the same SKU, then
that can be captured here.
:paramtype family: str
:keyword capacity: If the SKU supports scale out/in then the capacity integer should be
included. If scale out/in is not possible for the resource this may be omitted.
:paramtype capacity: int
"""
super().__init__(**kwargs)
self.name = name
self.dev = dev
self.size = size
self.family = family
self.capacity = capacity
class DataControllerProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""The data controller properties.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar infrastructure: The infrastructure the data controller is running on. Known values are:
"azure", "gcp", "aws", "alibaba", "onpremises", and "other".
:vartype infrastructure: str or ~azure.mgmt.azurearcdata.models.Infrastructure
:ivar on_premise_property: Properties from the Kubernetes data controller.
:vartype on_premise_property: ~azure.mgmt.azurearcdata.models.OnPremiseProperty
:ivar k8_s_raw: The raw kubernetes information.
:vartype k8_s_raw: JSON
:ivar upload_watermark: Properties on upload watermark. Mostly timestamp for each upload data
type.
:vartype upload_watermark: ~azure.mgmt.azurearcdata.models.UploadWatermark
:ivar last_uploaded_date: Last uploaded date from Kubernetes cluster. Defaults to current date
time.
:vartype last_uploaded_date: ~datetime.datetime
:ivar basic_login_information: Deprecated. Azure Arc Data Services data controller no longer
expose any endpoint. All traffic are exposed through Kubernetes native API.
:vartype basic_login_information: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:ivar metrics_dashboard_credential: Login credential for metrics dashboard on the Kubernetes
cluster.
:vartype metrics_dashboard_credential: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:ivar logs_dashboard_credential: Login credential for logs dashboard on the Kubernetes cluster.
:vartype logs_dashboard_credential: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:ivar log_analytics_workspace_config: Log analytics workspace id and primary key.
:vartype log_analytics_workspace_config:
~azure.mgmt.azurearcdata.models.LogAnalyticsWorkspaceConfig
:ivar upload_service_principal: Deprecated. Service principal is deprecated in favor of Arc
Kubernetes service extension managed identity.
:vartype upload_service_principal: ~azure.mgmt.azurearcdata.models.UploadServicePrincipal
:ivar provisioning_state: The provisioning state of the Arc Data Controller resource.
:vartype provisioning_state: str
:ivar cluster_id: If a CustomLocation is provided, this contains the ARM id of the connected
cluster the custom location belongs to.
:vartype cluster_id: str
:ivar extension_id: If a CustomLocation is provided, this contains the ARM id of the extension
the custom location belongs to.
:vartype extension_id: str
"""
_validation = {
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"infrastructure": {"key": "infrastructure", "type": "str"},
"on_premise_property": {"key": "onPremiseProperty", "type": "OnPremiseProperty"},
"k8_s_raw": {"key": "k8sRaw", "type": "object"},
"upload_watermark": {"key": "uploadWatermark", "type": "UploadWatermark"},
"last_uploaded_date": {"key": "lastUploadedDate", "type": "iso-8601"},
"basic_login_information": {"key": "basicLoginInformation", "type": "BasicLoginInformation"},
"metrics_dashboard_credential": {"key": "metricsDashboardCredential", "type": "BasicLoginInformation"},
"logs_dashboard_credential": {"key": "logsDashboardCredential", "type": "BasicLoginInformation"},
"log_analytics_workspace_config": {"key": "logAnalyticsWorkspaceConfig", "type": "LogAnalyticsWorkspaceConfig"},
"upload_service_principal": {"key": "uploadServicePrincipal", "type": "UploadServicePrincipal"},
"provisioning_state": {"key": "provisioningState", "type": "str"},
"cluster_id": {"key": "clusterId", "type": "str"},
"extension_id": {"key": "extensionId", "type": "str"},
}
def __init__(
self,
*,
infrastructure: Union[str, "_models.Infrastructure"] = "other",
on_premise_property: Optional["_models.OnPremiseProperty"] = None,
k8_s_raw: Optional[JSON] = None,
upload_watermark: Optional["_models.UploadWatermark"] = None,
last_uploaded_date: Optional[datetime.datetime] = None,
basic_login_information: Optional["_models.BasicLoginInformation"] = None,
metrics_dashboard_credential: Optional["_models.BasicLoginInformation"] = None,
logs_dashboard_credential: Optional["_models.BasicLoginInformation"] = None,
log_analytics_workspace_config: Optional["_models.LogAnalyticsWorkspaceConfig"] = None,
upload_service_principal: Optional["_models.UploadServicePrincipal"] = None,
cluster_id: Optional[str] = None,
extension_id: Optional[str] = None,
**kwargs
):
"""
:keyword infrastructure: The infrastructure the data controller is running on. Known values
are: "azure", "gcp", "aws", "alibaba", "onpremises", and "other".
:paramtype infrastructure: str or ~azure.mgmt.azurearcdata.models.Infrastructure
:keyword on_premise_property: Properties from the Kubernetes data controller.
:paramtype on_premise_property: ~azure.mgmt.azurearcdata.models.OnPremiseProperty
:keyword k8_s_raw: The raw kubernetes information.
:paramtype k8_s_raw: JSON
:keyword upload_watermark: Properties on upload watermark. Mostly timestamp for each upload
data type.
:paramtype upload_watermark: ~azure.mgmt.azurearcdata.models.UploadWatermark
:keyword last_uploaded_date: Last uploaded date from Kubernetes cluster. Defaults to current
date time.
:paramtype last_uploaded_date: ~datetime.datetime
:keyword basic_login_information: Deprecated. Azure Arc Data Services data controller no longer
expose any endpoint. All traffic are exposed through Kubernetes native API.
:paramtype basic_login_information: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:keyword metrics_dashboard_credential: Login credential for metrics dashboard on the Kubernetes
cluster.
:paramtype metrics_dashboard_credential: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:keyword logs_dashboard_credential: Login credential for logs dashboard on the Kubernetes
cluster.
:paramtype logs_dashboard_credential: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:keyword log_analytics_workspace_config: Log analytics workspace id and primary key.
:paramtype log_analytics_workspace_config:
~azure.mgmt.azurearcdata.models.LogAnalyticsWorkspaceConfig
:keyword upload_service_principal: Deprecated. Service principal is deprecated in favor of Arc
Kubernetes service extension managed identity.
:paramtype upload_service_principal: ~azure.mgmt.azurearcdata.models.UploadServicePrincipal
:keyword cluster_id: If a CustomLocation is provided, this contains the ARM id of the connected
cluster the custom location belongs to.
:paramtype cluster_id: str
:keyword extension_id: If a CustomLocation is provided, this contains the ARM id of the
extension the custom location belongs to.
:paramtype extension_id: str
"""
super().__init__(**kwargs)
self.infrastructure = infrastructure
self.on_premise_property = on_premise_property
self.k8_s_raw = k8_s_raw
self.upload_watermark = upload_watermark
self.last_uploaded_date = last_uploaded_date
self.basic_login_information = basic_login_information
self.metrics_dashboard_credential = metrics_dashboard_credential
self.logs_dashboard_credential = logs_dashboard_credential
self.log_analytics_workspace_config = log_analytics_workspace_config
self.upload_service_principal = upload_service_principal
self.provisioning_state = None
self.cluster_id = cluster_id
self.extension_id = extension_id
class TrackedResource(Resource):
"""The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"location": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
}
def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
"""
super().__init__(**kwargs)
self.tags = tags
self.location = location
class DataControllerResource(TrackedResource):
"""Data controller resource.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurearcdata.models.ExtendedLocation
:ivar properties: The data controller's properties. Required.
:vartype properties: ~azure.mgmt.azurearcdata.models.DataControllerProperties
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"location": {"required": True},
"properties": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"properties": {"key": "properties", "type": "DataControllerProperties"},
}
def __init__(
self,
*,
location: str,
properties: "_models.DataControllerProperties",
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurearcdata.models.ExtendedLocation
:keyword properties: The data controller's properties. Required.
:paramtype properties: ~azure.mgmt.azurearcdata.models.DataControllerProperties
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.properties = properties
class DataControllerUpdate(_serialization.Model):
"""Used for updating a data controller resource.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar properties: The data controller's properties.
:vartype properties: ~azure.mgmt.azurearcdata.models.DataControllerProperties
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
"properties": {"key": "properties", "type": "DataControllerProperties"},
}
def __init__(
self,
*,
tags: Optional[Dict[str, str]] = None,
properties: Optional["_models.DataControllerProperties"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword properties: The data controller's properties.
:paramtype properties: ~azure.mgmt.azurearcdata.models.DataControllerProperties
"""
super().__init__(**kwargs)
self.tags = tags
self.properties = properties
class ErrorResponse(_serialization.Model):
"""An error response from the Azure Data on Azure Arc service.
:ivar error: null.
:vartype error: ~azure.mgmt.azurearcdata.models.ErrorResponseBody
"""
_attribute_map = {
"error": {"key": "error", "type": "ErrorResponseBody"},
}
def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs):
"""
:keyword error: null.
:paramtype error: ~azure.mgmt.azurearcdata.models.ErrorResponseBody
"""
super().__init__(**kwargs)
self.error = error
class ErrorResponseBody(_serialization.Model):
"""An error response from the Batch service.
:ivar code: An identifier for the error. Codes are invariant and are intended to be consumed
programmatically.
:vartype code: str
:ivar message: A message describing the error, intended to be suitable for display in a user
interface.
:vartype message: str
:ivar target: The target of the particular error. For example, the name of the property in
error.
:vartype target: str
:ivar details: A list of additional details about the error.
:vartype details: list[~azure.mgmt.azurearcdata.models.ErrorResponseBody]
"""
_attribute_map = {
"code": {"key": "code", "type": "str"},
"message": {"key": "message", "type": "str"},
"target": {"key": "target", "type": "str"},
"details": {"key": "details", "type": "[ErrorResponseBody]"},
}
def __init__(
self,
*,
code: Optional[str] = None,
message: Optional[str] = None,
target: Optional[str] = None,
details: Optional[List["_models.ErrorResponseBody"]] = None,
**kwargs
):
"""
:keyword code: An identifier for the error. Codes are invariant and are intended to be consumed
programmatically.
:paramtype code: str
:keyword message: A message describing the error, intended to be suitable for display in a user
interface.
:paramtype message: str
:keyword target: The target of the particular error. For example, the name of the property in
error.
:paramtype target: str
:keyword details: A list of additional details about the error.
:paramtype details: list[~azure.mgmt.azurearcdata.models.ErrorResponseBody]
"""
super().__init__(**kwargs)
self.code = code
self.message = message
self.target = target
self.details = details
class ExtendedLocation(_serialization.Model):
"""The complex type of the extended location.
:ivar name: The name of the extended location.
:vartype name: str
:ivar type: The type of the extended location. "CustomLocation"
:vartype type: str or ~azure.mgmt.azurearcdata.models.ExtendedLocationTypes
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
}
def __init__(
self,
*,
name: Optional[str] = None,
type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None,
**kwargs
):
"""
:keyword name: The name of the extended location.
:paramtype name: str
:keyword type: The type of the extended location. "CustomLocation"
:paramtype type: str or ~azure.mgmt.azurearcdata.models.ExtendedLocationTypes
"""
super().__init__(**kwargs)
self.name = name
self.type = type
class K8SResourceRequirements(_serialization.Model):
"""The kubernetes resource limits and requests used to restrict or reserve resource usage.
:ivar additional_properties: Unmatched properties from the message are deserialized to this
collection.
:vartype additional_properties: dict[str, JSON]
:ivar requests: Requests for a kubernetes resource type (e.g 'cpu', 'memory'). The 'cpu'
request must be less than or equal to 'cpu' limit. Default 'cpu' is 2, minimum is 1. Default
'memory' is '4Gi', minimum is '2Gi. If sku.tier is GeneralPurpose, maximum 'cpu' is 24 and
maximum 'memory' is '128Gi'.
:vartype requests: dict[str, str]
:ivar limits: Limits for a kubernetes resource type (e.g 'cpu', 'memory'). The 'cpu' request
must be less than or equal to 'cpu' limit. Default 'cpu' is 2, minimum is 1. Default 'memory'
is '4Gi', minimum is '2Gi. If sku.tier is GeneralPurpose, maximum 'cpu' is 24 and maximum
'memory' is '128Gi'.
:vartype limits: dict[str, str]
"""
_attribute_map = {
"additional_properties": {"key": "", "type": "{object}"},
"requests": {"key": "requests", "type": "{str}"},
"limits": {"key": "limits", "type": "{str}"},
}
def __init__(
self,
*,
additional_properties: Optional[Dict[str, JSON]] = None,
requests: Optional[Dict[str, str]] = None,
limits: Optional[Dict[str, str]] = None,
**kwargs
):
"""
:keyword additional_properties: Unmatched properties from the message are deserialized to this
collection.
:paramtype additional_properties: dict[str, JSON]
:keyword requests: Requests for a kubernetes resource type (e.g 'cpu', 'memory'). The 'cpu'
request must be less than or equal to 'cpu' limit. Default 'cpu' is 2, minimum is 1. Default
'memory' is '4Gi', minimum is '2Gi. If sku.tier is GeneralPurpose, maximum 'cpu' is 24 and
maximum 'memory' is '128Gi'.
:paramtype requests: dict[str, str]
:keyword limits: Limits for a kubernetes resource type (e.g 'cpu', 'memory'). The 'cpu' request
must be less than or equal to 'cpu' limit. Default 'cpu' is 2, minimum is 1. Default 'memory'
is '4Gi', minimum is '2Gi. If sku.tier is GeneralPurpose, maximum 'cpu' is 24 and maximum
'memory' is '128Gi'.
:paramtype limits: dict[str, str]
"""
super().__init__(**kwargs)
self.additional_properties = additional_properties
self.requests = requests
self.limits = limits
class K8SScheduling(_serialization.Model):
"""The kubernetes scheduling information.
:ivar additional_properties: Unmatched properties from the message are deserialized to this
collection.
:vartype additional_properties: dict[str, JSON]
:ivar default: The kubernetes scheduling options. It describes restrictions used to help
Kubernetes select appropriate nodes to host the database service.
:vartype default: ~azure.mgmt.azurearcdata.models.K8SSchedulingOptions
"""
_attribute_map = {
"additional_properties": {"key": "", "type": "{object}"},
"default": {"key": "default", "type": "K8SSchedulingOptions"},
}
def __init__(
self,
*,
additional_properties: Optional[Dict[str, JSON]] = None,
default: Optional["_models.K8SSchedulingOptions"] = None,
**kwargs
):
"""
:keyword additional_properties: Unmatched properties from the message are deserialized to this
collection.
:paramtype additional_properties: dict[str, JSON]
:keyword default: The kubernetes scheduling options. It describes restrictions used to help
Kubernetes select appropriate nodes to host the database service.
:paramtype default: ~azure.mgmt.azurearcdata.models.K8SSchedulingOptions
"""
super().__init__(**kwargs)
self.additional_properties = additional_properties
self.default = default
class K8SSchedulingOptions(_serialization.Model):
"""The kubernetes scheduling options. It describes restrictions used to help Kubernetes select appropriate nodes to host the database service.
:ivar additional_properties: Unmatched properties from the message are deserialized to this
collection.
:vartype additional_properties: dict[str, JSON]
:ivar resources: The kubernetes resource limits and requests used to restrict or reserve
resource usage.
:vartype resources: ~azure.mgmt.azurearcdata.models.K8SResourceRequirements
"""
_attribute_map = {
"additional_properties": {"key": "", "type": "{object}"},
"resources": {"key": "resources", "type": "K8SResourceRequirements"},
}
def __init__(
self,
*,
additional_properties: Optional[Dict[str, JSON]] = None,
resources: Optional["_models.K8SResourceRequirements"] = None,
**kwargs
):
"""
:keyword additional_properties: Unmatched properties from the message are deserialized to this
collection.
:paramtype additional_properties: dict[str, JSON]
:keyword resources: The kubernetes resource limits and requests used to restrict or reserve
resource usage.
:paramtype resources: ~azure.mgmt.azurearcdata.models.K8SResourceRequirements
"""
super().__init__(**kwargs)
self.additional_properties = additional_properties
self.resources = resources
class KeytabInformation(_serialization.Model):
"""Keytab used for authenticate with Active Directory.
:ivar keytab: A base64-encoded keytab.
:vartype keytab: str
"""
_attribute_map = {
"keytab": {"key": "keytab", "type": "str"},
}
def __init__(self, *, keytab: Optional[str] = None, **kwargs):
"""
:keyword keytab: A base64-encoded keytab.
:paramtype keytab: str
"""
super().__init__(**kwargs)
self.keytab = keytab
class LogAnalyticsWorkspaceConfig(_serialization.Model):
"""Log analytics workspace id and primary key.
:ivar workspace_id: Azure Log Analytics workspace ID.
:vartype workspace_id: str
:ivar primary_key: Primary key of the workspace.
:vartype primary_key: str
"""
_attribute_map = {
"workspace_id": {"key": "workspaceId", "type": "str"},
"primary_key": {"key": "primaryKey", "type": "str"},
}
def __init__(self, *, workspace_id: Optional[str] = None, primary_key: Optional[str] = None, **kwargs):
"""
:keyword workspace_id: Azure Log Analytics workspace ID.
:paramtype workspace_id: str
:keyword primary_key: Primary key of the workspace.
:paramtype primary_key: str
"""
super().__init__(**kwargs)
self.workspace_id = workspace_id
self.primary_key = primary_key
class OnPremiseProperty(_serialization.Model):
"""Properties from the Kubernetes data controller.
All required parameters must be populated in order to send to Azure.
:ivar id: A globally unique ID identifying the associated Kubernetes cluster. Required.
:vartype id: str
:ivar public_signing_key: Certificate that contains the Kubernetes cluster public key used to
verify signing. Required.
:vartype public_signing_key: str
:ivar signing_certificate_thumbprint: Unique thumbprint returned to customer to verify the
certificate being uploaded.
:vartype signing_certificate_thumbprint: str
"""
_validation = {
"id": {"required": True},
"public_signing_key": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"public_signing_key": {"key": "publicSigningKey", "type": "str"},
"signing_certificate_thumbprint": {"key": "signingCertificateThumbprint", "type": "str"},
}
def __init__(
self,
*,
id: str, # pylint: disable=redefined-builtin
public_signing_key: str,
signing_certificate_thumbprint: Optional[str] = None,
**kwargs
):
"""
:keyword id: A globally unique ID identifying the associated Kubernetes cluster. Required.
:paramtype id: str
:keyword public_signing_key: Certificate that contains the Kubernetes cluster public key used
to verify signing. Required.
:paramtype public_signing_key: str
:keyword signing_certificate_thumbprint: Unique thumbprint returned to customer to verify the
certificate being uploaded.
:paramtype signing_certificate_thumbprint: str
"""
super().__init__(**kwargs)
self.id = id
self.public_signing_key = public_signing_key
self.signing_certificate_thumbprint = signing_certificate_thumbprint
class Operation(_serialization.Model):
"""Azure Data Services on Azure Arc operation definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar name: The name of the operation being performed on this particular object. Required.
:vartype name: str
:ivar display: The localized display information for this particular operation / action.
Required.
:vartype display: ~azure.mgmt.azurearcdata.models.OperationDisplay
:ivar origin: The intended executor of the operation. Known values are: "user" and "system".
:vartype origin: str or ~azure.mgmt.azurearcdata.models.OperationOrigin
:ivar is_data_action: Indicates whether the operation is a data action. Required.
:vartype is_data_action: bool
:ivar properties: Additional descriptions for the operation.
:vartype properties: dict[str, JSON]
"""
_validation = {
"name": {"required": True},
"display": {"required": True},
"origin": {"readonly": True},
"is_data_action": {"required": True},
"properties": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"display": {"key": "display", "type": "OperationDisplay"},
"origin": {"key": "origin", "type": "str"},
"is_data_action": {"key": "isDataAction", "type": "bool"},
"properties": {"key": "properties", "type": "{object}"},
}
def __init__(self, *, name: str, display: "_models.OperationDisplay", is_data_action: bool, **kwargs):
"""
:keyword name: The name of the operation being performed on this particular object. Required.
:paramtype name: str
:keyword display: The localized display information for this particular operation / action.
Required.
:paramtype display: ~azure.mgmt.azurearcdata.models.OperationDisplay
:keyword is_data_action: Indicates whether the operation is a data action. Required.
:paramtype is_data_action: bool
"""
super().__init__(**kwargs)
self.name = name
self.display = display
self.origin = None
self.is_data_action = is_data_action
self.properties = None
class OperationDisplay(_serialization.Model):
"""Display metadata associated with the operation.
All required parameters must be populated in order to send to Azure.
:ivar provider: The localized friendly form of the resource provider name. Required.
:vartype provider: str
:ivar resource: The localized friendly form of the resource type related to this
action/operation. Required.
:vartype resource: str
:ivar operation: The localized friendly name for the operation. Required.
:vartype operation: str
:ivar description: The localized friendly description for the operation. Required.
:vartype description: str
"""
_validation = {
"provider": {"required": True},
"resource": {"required": True},
"operation": {"required": True},
"description": {"required": True},
}
_attribute_map = {
"provider": {"key": "provider", "type": "str"},
"resource": {"key": "resource", "type": "str"},
"operation": {"key": "operation", "type": "str"},
"description": {"key": "description", "type": "str"},
}
def __init__(self, *, provider: str, resource: str, operation: str, description: str, **kwargs):
"""
:keyword provider: The localized friendly form of the resource provider name. Required.
:paramtype provider: str
:keyword resource: The localized friendly form of the resource type related to this
action/operation. Required.
:paramtype resource: str
:keyword operation: The localized friendly name for the operation. Required.
:paramtype operation: str
:keyword description: The localized friendly description for the operation. Required.
:paramtype description: str
"""
super().__init__(**kwargs)
self.provider = provider
self.resource = resource
self.operation = operation
self.description = description
class OperationListResult(_serialization.Model):
"""Result of the request to list Azure Data Services on Azure Arc operations.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: Array of results.
:vartype value: list[~azure.mgmt.azurearcdata.models.Operation]
:ivar next_link: Link to retrieve next page of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[Operation]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class PageOfDataControllerResource(_serialization.Model):
"""A list of data controllers.
:ivar value: Array of results.
:vartype value: list[~azure.mgmt.azurearcdata.models.DataControllerResource]
:ivar next_link: Link to retrieve next page of results.
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[DataControllerResource]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self,
*,
value: Optional[List["_models.DataControllerResource"]] = None,
next_link: Optional[str] = None,
**kwargs
):
"""
:keyword value: Array of results.
:paramtype value: list[~azure.mgmt.azurearcdata.models.DataControllerResource]
:keyword next_link: Link to retrieve next page of results.
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class PostgresInstance(TrackedResource):
"""A Postgres Instance.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurearcdata.models.ExtendedLocation
:ivar properties: null. Required.
:vartype properties: ~azure.mgmt.azurearcdata.models.PostgresInstanceProperties
:ivar sku: Resource sku.
:vartype sku: ~azure.mgmt.azurearcdata.models.PostgresInstanceSku
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"location": {"required": True},
"properties": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"properties": {"key": "properties", "type": "PostgresInstanceProperties"},
"sku": {"key": "sku", "type": "PostgresInstanceSku"},
}
def __init__(
self,
*,
location: str,
properties: "_models.PostgresInstanceProperties",
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
sku: Optional["_models.PostgresInstanceSku"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurearcdata.models.ExtendedLocation
:keyword properties: null. Required.
:paramtype properties: ~azure.mgmt.azurearcdata.models.PostgresInstanceProperties
:keyword sku: Resource sku.
:paramtype sku: ~azure.mgmt.azurearcdata.models.PostgresInstanceSku
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.properties = properties
self.sku = sku
class PostgresInstanceListResult(_serialization.Model):
"""A list of PostgresInstance.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: Array of results.
:vartype value: list[~azure.mgmt.azurearcdata.models.PostgresInstance]
:ivar next_link: Link to retrieve next page of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[PostgresInstance]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class PostgresInstanceProperties(_serialization.Model):
"""Postgres Instance properties.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar data_controller_id: The data controller id.
:vartype data_controller_id: str
:ivar admin: The instance admin.
:vartype admin: str
:ivar basic_login_information: Username and password for basic authentication.
:vartype basic_login_information: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:ivar k8_s_raw: The raw kubernetes information.
:vartype k8_s_raw: JSON
:ivar last_uploaded_date: Last uploaded date from Kubernetes cluster. Defaults to current date
time.
:vartype last_uploaded_date: ~datetime.datetime
:ivar provisioning_state: The provisioning state of the Azure Arc-enabled PostgreSQL instance.
:vartype provisioning_state: str
"""
_validation = {
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"data_controller_id": {"key": "dataControllerId", "type": "str"},
"admin": {"key": "admin", "type": "str"},
"basic_login_information": {"key": "basicLoginInformation", "type": "BasicLoginInformation"},
"k8_s_raw": {"key": "k8sRaw", "type": "object"},
"last_uploaded_date": {"key": "lastUploadedDate", "type": "iso-8601"},
"provisioning_state": {"key": "provisioningState", "type": "str"},
}
def __init__(
self,
*,
data_controller_id: Optional[str] = None,
admin: Optional[str] = None,
basic_login_information: Optional["_models.BasicLoginInformation"] = None,
k8_s_raw: Optional[JSON] = None,
last_uploaded_date: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword data_controller_id: The data controller id.
:paramtype data_controller_id: str
:keyword admin: The instance admin.
:paramtype admin: str
:keyword basic_login_information: Username and password for basic authentication.
:paramtype basic_login_information: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:keyword k8_s_raw: The raw kubernetes information.
:paramtype k8_s_raw: JSON
:keyword last_uploaded_date: Last uploaded date from Kubernetes cluster. Defaults to current
date time.
:paramtype last_uploaded_date: ~datetime.datetime
"""
super().__init__(**kwargs)
self.data_controller_id = data_controller_id
self.admin = admin
self.basic_login_information = basic_login_information
self.k8_s_raw = k8_s_raw
self.last_uploaded_date = last_uploaded_date
self.provisioning_state = None
class PostgresInstanceSku(CommonSku):
"""The resource model definition representing SKU for Azure Database for PostgresSQL - Azure Arc.
All required parameters must be populated in order to send to Azure.
:ivar name: The name of the SKU. It is typically a letter+number code. Required.
:vartype name: str
:ivar dev: Whether dev/test is enabled. When the dev field is set to true, the resource is used
for dev/test purpose.
:vartype dev: bool
:ivar size: The SKU size. When the name field is the combination of tier and some other value,
this would be the standalone code.
:vartype size: str
:ivar family: If the service has different generations of hardware, for the same SKU, then that
can be captured here.
:vartype family: str
:ivar capacity: If the SKU supports scale out/in then the capacity integer should be included.
If scale out/in is not possible for the resource this may be omitted.
:vartype capacity: int
:ivar tier: This field is required to be implemented by the Resource Provider if the service
has more than one tier. Default value is "Hyperscale".
:vartype tier: str
"""
_validation = {
"name": {"required": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"dev": {"key": "dev", "type": "bool"},
"size": {"key": "size", "type": "str"},
"family": {"key": "family", "type": "str"},
"capacity": {"key": "capacity", "type": "int"},
"tier": {"key": "tier", "type": "str"},
}
def __init__(
self,
*,
name: str,
dev: bool = True,
size: Optional[str] = None,
family: Optional[str] = None,
capacity: Optional[int] = None,
tier: Literal["Hyperscale"] = "Hyperscale",
**kwargs
):
"""
:keyword name: The name of the SKU. It is typically a letter+number code. Required.
:paramtype name: str
:keyword dev: Whether dev/test is enabled. When the dev field is set to true, the resource is
used for dev/test purpose.
:paramtype dev: bool
:keyword size: The SKU size. When the name field is the combination of tier and some other
value, this would be the standalone code.
:paramtype size: str
:keyword family: If the service has different generations of hardware, for the same SKU, then
that can be captured here.
:paramtype family: str
:keyword capacity: If the SKU supports scale out/in then the capacity integer should be
included. If scale out/in is not possible for the resource this may be omitted.
:paramtype capacity: int
:keyword tier: This field is required to be implemented by the Resource Provider if the service
has more than one tier. Default value is "Hyperscale".
:paramtype tier: str
"""
super().__init__(name=name, dev=dev, size=size, family=family, capacity=capacity, **kwargs)
self.tier = tier
class PostgresInstanceUpdate(_serialization.Model):
"""An update to a Postgres Instance.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar properties: Postgres Instance properties.
:vartype properties: ~azure.mgmt.azurearcdata.models.PostgresInstanceProperties
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
"properties": {"key": "properties", "type": "PostgresInstanceProperties"},
}
def __init__(
self,
*,
tags: Optional[Dict[str, str]] = None,
properties: Optional["_models.PostgresInstanceProperties"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword properties: Postgres Instance properties.
:paramtype properties: ~azure.mgmt.azurearcdata.models.PostgresInstanceProperties
"""
super().__init__(**kwargs)
self.tags = tags
self.properties = properties
class SqlManagedInstance(TrackedResource):
"""A SqlManagedInstance.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar properties: null. Required.
:vartype properties: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceProperties
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurearcdata.models.ExtendedLocation
:ivar sku: Resource sku.
:vartype sku: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceSku
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"location": {"required": True},
"properties": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"properties": {"key": "properties", "type": "SqlManagedInstanceProperties"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"sku": {"key": "sku", "type": "SqlManagedInstanceSku"},
}
def __init__(
self,
*,
location: str,
properties: "_models.SqlManagedInstanceProperties",
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
sku: Optional["_models.SqlManagedInstanceSku"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword properties: null. Required.
:paramtype properties: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceProperties
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurearcdata.models.ExtendedLocation
:keyword sku: Resource sku.
:paramtype sku: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceSku
"""
super().__init__(tags=tags, location=location, **kwargs)
self.properties = properties
self.extended_location = extended_location
self.sku = sku
class SqlManagedInstanceK8SRaw(_serialization.Model):
"""The raw kubernetes information.
:ivar additional_properties: Unmatched properties from the message are deserialized to this
collection.
:vartype additional_properties: dict[str, JSON]
:ivar spec: The kubernetes spec information.
:vartype spec: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceK8SSpec
"""
_attribute_map = {
"additional_properties": {"key": "", "type": "{object}"},
"spec": {"key": "spec", "type": "SqlManagedInstanceK8SSpec"},
}
def __init__(
self,
*,
additional_properties: Optional[Dict[str, JSON]] = None,
spec: Optional["_models.SqlManagedInstanceK8SSpec"] = None,
**kwargs
):
"""
:keyword additional_properties: Unmatched properties from the message are deserialized to this
collection.
:paramtype additional_properties: dict[str, JSON]
:keyword spec: The kubernetes spec information.
:paramtype spec: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceK8SSpec
"""
super().__init__(**kwargs)
self.additional_properties = additional_properties
self.spec = spec
class SqlManagedInstanceK8SSpec(_serialization.Model):
"""The kubernetes spec information.
:ivar additional_properties: Unmatched properties from the message are deserialized to this
collection.
:vartype additional_properties: dict[str, JSON]
:ivar scheduling: The kubernetes scheduling information.
:vartype scheduling: ~azure.mgmt.azurearcdata.models.K8SScheduling
:ivar replicas: This option specifies the number of SQL Managed Instance replicas that will be
deployed in your Kubernetes cluster for high availability purposes. If sku.tier is
BusinessCritical, allowed values are '2' or '3' with default of '3'. If sku.tier is
GeneralPurpose, replicas must be '1'.
:vartype replicas: int
"""
_attribute_map = {
"additional_properties": {"key": "", "type": "{object}"},
"scheduling": {"key": "scheduling", "type": "K8SScheduling"},
"replicas": {"key": "replicas", "type": "int"},
}
def __init__(
self,
*,
additional_properties: Optional[Dict[str, JSON]] = None,
scheduling: Optional["_models.K8SScheduling"] = None,
replicas: Optional[int] = None,
**kwargs
):
"""
:keyword additional_properties: Unmatched properties from the message are deserialized to this
collection.
:paramtype additional_properties: dict[str, JSON]
:keyword scheduling: The kubernetes scheduling information.
:paramtype scheduling: ~azure.mgmt.azurearcdata.models.K8SScheduling
:keyword replicas: This option specifies the number of SQL Managed Instance replicas that will
be deployed in your Kubernetes cluster for high availability purposes. If sku.tier is
BusinessCritical, allowed values are '2' or '3' with default of '3'. If sku.tier is
GeneralPurpose, replicas must be '1'.
:paramtype replicas: int
"""
super().__init__(**kwargs)
self.additional_properties = additional_properties
self.scheduling = scheduling
self.replicas = replicas
class SqlManagedInstanceListResult(_serialization.Model):
"""A list of SqlManagedInstance.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: Array of results.
:vartype value: list[~azure.mgmt.azurearcdata.models.SqlManagedInstance]
:ivar next_link: Link to retrieve next page of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[SqlManagedInstance]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class SqlManagedInstanceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""Properties of sqlManagedInstance.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar data_controller_id: null.
:vartype data_controller_id: str
:ivar admin: The instance admin user.
:vartype admin: str
:ivar start_time: The instance start time.
:vartype start_time: str
:ivar end_time: The instance end time.
:vartype end_time: str
:ivar k8_s_raw: The raw kubernetes information.
:vartype k8_s_raw: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceK8SRaw
:ivar basic_login_information: Username and password for basic authentication.
:vartype basic_login_information: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:ivar last_uploaded_date: Last uploaded date from Kubernetes cluster. Defaults to current date
time.
:vartype last_uploaded_date: ~datetime.datetime
:ivar provisioning_state: The provisioning state of the Arc-enabled SQL Managed Instance
resource.
:vartype provisioning_state: str
:ivar active_directory_information: Active Directory information related to this SQL Managed
Instance.
:vartype active_directory_information:
~azure.mgmt.azurearcdata.models.ActiveDirectoryInformation
:ivar license_type: The license type to apply for this managed instance. Known values are:
"BasePrice", "LicenseIncluded", and "DisasterRecovery".
:vartype license_type: str or ~azure.mgmt.azurearcdata.models.ArcSqlManagedInstanceLicenseType
:ivar cluster_id: If a CustomLocation is provided, this contains the ARM id of the connected
cluster the custom location belongs to.
:vartype cluster_id: str
:ivar extension_id: If a CustomLocation is provided, this contains the ARM id of the extension
the custom location belongs to.
:vartype extension_id: str
"""
_validation = {
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"data_controller_id": {"key": "dataControllerId", "type": "str"},
"admin": {"key": "admin", "type": "str"},
"start_time": {"key": "startTime", "type": "str"},
"end_time": {"key": "endTime", "type": "str"},
"k8_s_raw": {"key": "k8sRaw", "type": "SqlManagedInstanceK8SRaw"},
"basic_login_information": {"key": "basicLoginInformation", "type": "BasicLoginInformation"},
"last_uploaded_date": {"key": "lastUploadedDate", "type": "iso-8601"},
"provisioning_state": {"key": "provisioningState", "type": "str"},
"active_directory_information": {"key": "activeDirectoryInformation", "type": "ActiveDirectoryInformation"},
"license_type": {"key": "licenseType", "type": "str"},
"cluster_id": {"key": "clusterId", "type": "str"},
"extension_id": {"key": "extensionId", "type": "str"},
}
def __init__(
self,
*,
data_controller_id: Optional[str] = None,
admin: Optional[str] = None,
start_time: Optional[str] = None,
end_time: Optional[str] = None,
k8_s_raw: Optional["_models.SqlManagedInstanceK8SRaw"] = None,
basic_login_information: Optional["_models.BasicLoginInformation"] = None,
last_uploaded_date: Optional[datetime.datetime] = None,
active_directory_information: Optional["_models.ActiveDirectoryInformation"] = None,
license_type: Union[str, "_models.ArcSqlManagedInstanceLicenseType"] = "BasePrice",
cluster_id: Optional[str] = None,
extension_id: Optional[str] = None,
**kwargs
):
"""
:keyword data_controller_id: null.
:paramtype data_controller_id: str
:keyword admin: The instance admin user.
:paramtype admin: str
:keyword start_time: The instance start time.
:paramtype start_time: str
:keyword end_time: The instance end time.
:paramtype end_time: str
:keyword k8_s_raw: The raw kubernetes information.
:paramtype k8_s_raw: ~azure.mgmt.azurearcdata.models.SqlManagedInstanceK8SRaw
:keyword basic_login_information: Username and password for basic authentication.
:paramtype basic_login_information: ~azure.mgmt.azurearcdata.models.BasicLoginInformation
:keyword last_uploaded_date: Last uploaded date from Kubernetes cluster. Defaults to current
date time.
:paramtype last_uploaded_date: ~datetime.datetime
:keyword active_directory_information: Active Directory information related to this SQL Managed
Instance.
:paramtype active_directory_information:
~azure.mgmt.azurearcdata.models.ActiveDirectoryInformation
:keyword license_type: The license type to apply for this managed instance. Known values are:
"BasePrice", "LicenseIncluded", and "DisasterRecovery".
:paramtype license_type: str or
~azure.mgmt.azurearcdata.models.ArcSqlManagedInstanceLicenseType
:keyword cluster_id: If a CustomLocation is provided, this contains the ARM id of the connected
cluster the custom location belongs to.
:paramtype cluster_id: str
:keyword extension_id: If a CustomLocation is provided, this contains the ARM id of the
extension the custom location belongs to.
:paramtype extension_id: str
"""
super().__init__(**kwargs)
self.data_controller_id = data_controller_id
self.admin = admin
self.start_time = start_time
self.end_time = end_time
self.k8_s_raw = k8_s_raw
self.basic_login_information = basic_login_information
self.last_uploaded_date = last_uploaded_date
self.provisioning_state = None
self.active_directory_information = active_directory_information
self.license_type = license_type
self.cluster_id = cluster_id
self.extension_id = extension_id
class SqlManagedInstanceSku(_serialization.Model):
"""The resource model definition representing SKU for Azure Managed Instance - Azure Arc.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar name: The name of the SKU. Required. Default value is "vCore".
:vartype name: str
:ivar tier: The pricing tier for the instance. Known values are: "GeneralPurpose" and
"BusinessCritical".
:vartype tier: str or ~azure.mgmt.azurearcdata.models.SqlManagedInstanceSkuTier
:ivar dev: Whether dev/test is enabled. When the dev field is set to true, the resource is used
for dev/test purpose.
:vartype dev: bool
:ivar size: The SKU size. When the name field is the combination of tier and some other value,
this would be the standalone code.
:vartype size: str
:ivar family: The SKU family.
:vartype family: str
:ivar capacity: The SKU capacity.
:vartype capacity: int
"""
_validation = {
"name": {"required": True, "constant": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"tier": {"key": "tier", "type": "str"},
"dev": {"key": "dev", "type": "bool"},
"size": {"key": "size", "type": "str"},
"family": {"key": "family", "type": "str"},
"capacity": {"key": "capacity", "type": "int"},
}
name = "vCore"
def __init__(
self,
*,
tier: Union[str, "_models.SqlManagedInstanceSkuTier"] = "GeneralPurpose",
dev: bool = True,
size: Optional[str] = None,
family: Optional[str] = None,
capacity: Optional[int] = None,
**kwargs
):
"""
:keyword tier: The pricing tier for the instance. Known values are: "GeneralPurpose" and
"BusinessCritical".
:paramtype tier: str or ~azure.mgmt.azurearcdata.models.SqlManagedInstanceSkuTier
:keyword dev: Whether dev/test is enabled. When the dev field is set to true, the resource is
used for dev/test purpose.
:paramtype dev: bool
:keyword size: The SKU size. When the name field is the combination of tier and some other
value, this would be the standalone code.
:paramtype size: str
:keyword family: The SKU family.
:paramtype family: str
:keyword capacity: The SKU capacity.
:paramtype capacity: int
"""
super().__init__(**kwargs)
self.tier = tier
self.dev = dev
self.size = size
self.family = family
self.capacity = capacity
class SqlManagedInstanceUpdate(_serialization.Model):
"""An update to a SQL Managed Instance.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class SqlServerInstance(TrackedResource):
"""A SqlServerInstance.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy
information.
:vartype system_data: ~azure.mgmt.azurearcdata.models.SystemData
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar properties: null.
:vartype properties: ~azure.mgmt.azurearcdata.models.SqlServerInstanceProperties
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"location": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"properties": {"key": "properties", "type": "SqlServerInstanceProperties"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
properties: Optional["_models.SqlServerInstanceProperties"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword properties: null.
:paramtype properties: ~azure.mgmt.azurearcdata.models.SqlServerInstanceProperties
"""
super().__init__(tags=tags, location=location, **kwargs)
self.properties = properties
class SqlServerInstanceListResult(_serialization.Model):
"""A list of SqlServerInstance.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: Array of results.
:vartype value: list[~azure.mgmt.azurearcdata.models.SqlServerInstance]
:ivar next_link: Link to retrieve next page of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[SqlServerInstance]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class SqlServerInstanceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""Properties of SqlServerInstance.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar version: SQL Server version. Known values are: "SQL Server 2012", "SQL Server 2014", "SQL
Server 2016", "SQL Server 2017", "SQL Server 2019", "SQL Server 2022", and "Unknown".
:vartype version: str or ~azure.mgmt.azurearcdata.models.SqlVersion
:ivar edition: SQL Server edition. Known values are: "Evaluation", "Enterprise", "Standard",
"Web", "Developer", and "Express".
:vartype edition: str or ~azure.mgmt.azurearcdata.models.EditionType
:ivar container_resource_id: ARM Resource id of the container resource (Azure Arc for Servers).
Required.
:vartype container_resource_id: str
:ivar create_time: The time when the resource was created.
:vartype create_time: str
:ivar v_core: The number of logical processors used by the SQL Server instance.
:vartype v_core: str
:ivar status: The cloud connectivity status. Required. Known values are: "Connected",
"Disconnected", "Registered", and "Unknown".
:vartype status: str or ~azure.mgmt.azurearcdata.models.ConnectionStatus
:ivar patch_level: SQL Server update level.
:vartype patch_level: str
:ivar collation: SQL Server collation.
:vartype collation: str
:ivar current_version: SQL Server current version.
:vartype current_version: str
:ivar instance_name: SQL Server instance name.
:vartype instance_name: str
:ivar tcp_dynamic_ports: Dynamic TCP ports used by SQL Server.
:vartype tcp_dynamic_ports: str
:ivar tcp_static_ports: Static TCP ports used by SQL Server.
:vartype tcp_static_ports: str
:ivar product_id: SQL Server product ID.
:vartype product_id: str
:ivar license_type: SQL Server license type. Known values are: "Undefined", "Free", "HADR",
"ServerCAL", "LicenseOnly", "PAYG", and "Paid".
:vartype license_type: str or ~azure.mgmt.azurearcdata.models.ArcSqlServerLicenseType
:ivar azure_defender_status_last_updated: Timestamp of last Azure Defender status update.
:vartype azure_defender_status_last_updated: ~datetime.datetime
:ivar azure_defender_status: Status of Azure Defender. Known values are: "Protected",
"Unprotected", and "Unknown".
:vartype azure_defender_status: str or ~azure.mgmt.azurearcdata.models.DefenderStatus
:ivar provisioning_state: The provisioning state of the Arc-enabled SQL Server resource.
:vartype provisioning_state: str
:ivar host_type: Type of host for Azure Arc SQL Server. Known values are: "Azure Virtual
Machine", "Azure VMWare Virtual Machine", "Azure Kubernetes Service", "AWS VMWare Virtual
Machine", "AWS Kubernetes Service", "GCP VMWare Virtual Machine", "GCP Kubernetes Service",
"Container", "Virtual Machine", "Physical Server", "AWS Virtual Machine", "GCP Virtual
Machine", and "Other".
:vartype host_type: str or ~azure.mgmt.azurearcdata.models.HostType
"""
_validation = {
"container_resource_id": {"required": True},
"create_time": {"readonly": True},
"status": {"required": True},
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"version": {"key": "version", "type": "str"},
"edition": {"key": "edition", "type": "str"},
"container_resource_id": {"key": "containerResourceId", "type": "str"},
"create_time": {"key": "createTime", "type": "str"},
"v_core": {"key": "vCore", "type": "str"},
"status": {"key": "status", "type": "str"},
"patch_level": {"key": "patchLevel", "type": "str"},
"collation": {"key": "collation", "type": "str"},
"current_version": {"key": "currentVersion", "type": "str"},
"instance_name": {"key": "instanceName", "type": "str"},
"tcp_dynamic_ports": {"key": "tcpDynamicPorts", "type": "str"},
"tcp_static_ports": {"key": "tcpStaticPorts", "type": "str"},
"product_id": {"key": "productId", "type": "str"},
"license_type": {"key": "licenseType", "type": "str"},
"azure_defender_status_last_updated": {"key": "azureDefenderStatusLastUpdated", "type": "iso-8601"},
"azure_defender_status": {"key": "azureDefenderStatus", "type": "str"},
"provisioning_state": {"key": "provisioningState", "type": "str"},
"host_type": {"key": "hostType", "type": "str"},
}
def __init__(
self,
*,
container_resource_id: str,
status: Union[str, "_models.ConnectionStatus"],
version: Optional[Union[str, "_models.SqlVersion"]] = None,
edition: Optional[Union[str, "_models.EditionType"]] = None,
v_core: Optional[str] = None,
patch_level: Optional[str] = None,
collation: Optional[str] = None,
current_version: Optional[str] = None,
instance_name: Optional[str] = None,
tcp_dynamic_ports: Optional[str] = None,
tcp_static_ports: Optional[str] = None,
product_id: Optional[str] = None,
license_type: Optional[Union[str, "_models.ArcSqlServerLicenseType"]] = None,
azure_defender_status_last_updated: Optional[datetime.datetime] = None,
azure_defender_status: Optional[Union[str, "_models.DefenderStatus"]] = None,
host_type: Optional[Union[str, "_models.HostType"]] = None,
**kwargs
):
"""
:keyword version: SQL Server version. Known values are: "SQL Server 2012", "SQL Server 2014",
"SQL Server 2016", "SQL Server 2017", "SQL Server 2019", "SQL Server 2022", and "Unknown".
:paramtype version: str or ~azure.mgmt.azurearcdata.models.SqlVersion
:keyword edition: SQL Server edition. Known values are: "Evaluation", "Enterprise", "Standard",
"Web", "Developer", and "Express".
:paramtype edition: str or ~azure.mgmt.azurearcdata.models.EditionType
:keyword container_resource_id: ARM Resource id of the container resource (Azure Arc for
Servers). Required.
:paramtype container_resource_id: str
:keyword v_core: The number of logical processors used by the SQL Server instance.
:paramtype v_core: str
:keyword status: The cloud connectivity status. Required. Known values are: "Connected",
"Disconnected", "Registered", and "Unknown".
:paramtype status: str or ~azure.mgmt.azurearcdata.models.ConnectionStatus
:keyword patch_level: SQL Server update level.
:paramtype patch_level: str
:keyword collation: SQL Server collation.
:paramtype collation: str
:keyword current_version: SQL Server current version.
:paramtype current_version: str
:keyword instance_name: SQL Server instance name.
:paramtype instance_name: str
:keyword tcp_dynamic_ports: Dynamic TCP ports used by SQL Server.
:paramtype tcp_dynamic_ports: str
:keyword tcp_static_ports: Static TCP ports used by SQL Server.
:paramtype tcp_static_ports: str
:keyword product_id: SQL Server product ID.
:paramtype product_id: str
:keyword license_type: SQL Server license type. Known values are: "Undefined", "Free", "HADR",
"ServerCAL", "LicenseOnly", "PAYG", and "Paid".
:paramtype license_type: str or ~azure.mgmt.azurearcdata.models.ArcSqlServerLicenseType
:keyword azure_defender_status_last_updated: Timestamp of last Azure Defender status update.
:paramtype azure_defender_status_last_updated: ~datetime.datetime
:keyword azure_defender_status: Status of Azure Defender. Known values are: "Protected",
"Unprotected", and "Unknown".
:paramtype azure_defender_status: str or ~azure.mgmt.azurearcdata.models.DefenderStatus
:keyword host_type: Type of host for Azure Arc SQL Server. Known values are: "Azure Virtual
Machine", "Azure VMWare Virtual Machine", "Azure Kubernetes Service", "AWS VMWare Virtual
Machine", "AWS Kubernetes Service", "GCP VMWare Virtual Machine", "GCP Kubernetes Service",
"Container", "Virtual Machine", "Physical Server", "AWS Virtual Machine", "GCP Virtual
Machine", and "Other".
:paramtype host_type: str or ~azure.mgmt.azurearcdata.models.HostType
"""
super().__init__(**kwargs)
self.version = version
self.edition = edition
self.container_resource_id = container_resource_id
self.create_time = None
self.v_core = v_core
self.status = status
self.patch_level = patch_level
self.collation = collation
self.current_version = current_version
self.instance_name = instance_name
self.tcp_dynamic_ports = tcp_dynamic_ports
self.tcp_static_ports = tcp_static_ports
self.product_id = product_id
self.license_type = license_type
self.azure_defender_status_last_updated = azure_defender_status_last_updated
self.azure_defender_status = azure_defender_status
self.provisioning_state = None
self.host_type = host_type
class SqlServerInstanceUpdate(_serialization.Model):
"""An update to a SQL Server Instance.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class SystemData(_serialization.Model):
"""Metadata pertaining to creation and last modification of the resource.
:ivar created_by: The identity that created the resource.
:vartype created_by: str
:ivar created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:vartype created_by_type: str or ~azure.mgmt.azurearcdata.models.CreatedByType
:ivar created_at: The timestamp of resource creation (UTC).
:vartype created_at: ~datetime.datetime
:ivar last_modified_by: The identity that last modified the resource.
:vartype last_modified_by: str
:ivar last_modified_by_type: The type of identity that last modified the resource. Known values
are: "User", "Application", "ManagedIdentity", and "Key".
:vartype last_modified_by_type: str or ~azure.mgmt.azurearcdata.models.CreatedByType
:ivar last_modified_at: The timestamp of resource last modification (UTC).
:vartype last_modified_at: ~datetime.datetime
"""
_attribute_map = {
"created_by": {"key": "createdBy", "type": "str"},
"created_by_type": {"key": "createdByType", "type": "str"},
"created_at": {"key": "createdAt", "type": "iso-8601"},
"last_modified_by": {"key": "lastModifiedBy", "type": "str"},
"last_modified_by_type": {"key": "lastModifiedByType", "type": "str"},
"last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"},
}
def __init__(
self,
*,
created_by: Optional[str] = None,
created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
created_at: Optional[datetime.datetime] = None,
last_modified_by: Optional[str] = None,
last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
last_modified_at: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword created_by: The identity that created the resource.
:paramtype created_by: str
:keyword created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:paramtype created_by_type: str or ~azure.mgmt.azurearcdata.models.CreatedByType
:keyword created_at: The timestamp of resource creation (UTC).
:paramtype created_at: ~datetime.datetime
:keyword last_modified_by: The identity that last modified the resource.
:paramtype last_modified_by: str
:keyword last_modified_by_type: The type of identity that last modified the resource. Known
values are: "User", "Application", "ManagedIdentity", and "Key".
:paramtype last_modified_by_type: str or ~azure.mgmt.azurearcdata.models.CreatedByType
:keyword last_modified_at: The timestamp of resource last modification (UTC).
:paramtype last_modified_at: ~datetime.datetime
"""
super().__init__(**kwargs)
self.created_by = created_by
self.created_by_type = created_by_type
self.created_at = created_at
self.last_modified_by = last_modified_by
self.last_modified_by_type = last_modified_by_type
self.last_modified_at = last_modified_at
class UploadServicePrincipal(_serialization.Model):
"""Service principal for uploading billing, metrics and logs.
:ivar client_id: Client ID of the service principal for uploading data.
:vartype client_id: str
:ivar tenant_id: Tenant ID of the service principal.
:vartype tenant_id: str
:ivar authority: Authority for the service principal. Example:
https://login.microsoftonline.com/.
:vartype authority: str
:ivar client_secret: Secret of the service principal.
:vartype client_secret: str
"""
_attribute_map = {
"client_id": {"key": "clientId", "type": "str"},
"tenant_id": {"key": "tenantId", "type": "str"},
"authority": {"key": "authority", "type": "str"},
"client_secret": {"key": "clientSecret", "type": "str"},
}
def __init__(
self,
*,
client_id: Optional[str] = None,
tenant_id: Optional[str] = None,
authority: Optional[str] = None,
client_secret: Optional[str] = None,
**kwargs
):
"""
:keyword client_id: Client ID of the service principal for uploading data.
:paramtype client_id: str
:keyword tenant_id: Tenant ID of the service principal.
:paramtype tenant_id: str
:keyword authority: Authority for the service principal. Example:
https://login.microsoftonline.com/.
:paramtype authority: str
:keyword client_secret: Secret of the service principal.
:paramtype client_secret: str
"""
super().__init__(**kwargs)
self.client_id = client_id
self.tenant_id = tenant_id
self.authority = authority
self.client_secret = client_secret
class UploadWatermark(_serialization.Model):
"""Properties on upload watermark. Mostly timestamp for each upload data type.
:ivar metrics: Last uploaded date for metrics from kubernetes cluster. Defaults to current date
time.
:vartype metrics: ~datetime.datetime
:ivar logs: Last uploaded date for logs from kubernetes cluster. Defaults to current date time.
:vartype logs: ~datetime.datetime
:ivar usages: Last uploaded date for usages from kubernetes cluster. Defaults to current date
time.
:vartype usages: ~datetime.datetime
"""
_attribute_map = {
"metrics": {"key": "metrics", "type": "iso-8601"},
"logs": {"key": "logs", "type": "iso-8601"},
"usages": {"key": "usages", "type": "iso-8601"},
}
def __init__(
self,
*,
metrics: Optional[datetime.datetime] = None,
logs: Optional[datetime.datetime] = None,
usages: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword metrics: Last uploaded date for metrics from kubernetes cluster. Defaults to current
date time.
:paramtype metrics: ~datetime.datetime
:keyword logs: Last uploaded date for logs from kubernetes cluster. Defaults to current date
time.
:paramtype logs: ~datetime.datetime
:keyword usages: Last uploaded date for usages from kubernetes cluster. Defaults to current
date time.
:paramtype usages: ~datetime.datetime
"""
super().__init__(**kwargs)
self.metrics = metrics
self.logs = logs
self.usages = usages
| 0.684264 | 0.218982 |
from ._models_py3 import ActiveDirectoryConnectorDNSDetails
from ._models_py3 import ActiveDirectoryConnectorDomainDetails
from ._models_py3 import ActiveDirectoryConnectorListResult
from ._models_py3 import ActiveDirectoryConnectorProperties
from ._models_py3 import ActiveDirectoryConnectorResource
from ._models_py3 import ActiveDirectoryConnectorSpec
from ._models_py3 import ActiveDirectoryConnectorStatus
from ._models_py3 import ActiveDirectoryDomainController
from ._models_py3 import ActiveDirectoryDomainControllers
from ._models_py3 import ActiveDirectoryInformation
from ._models_py3 import BasicLoginInformation
from ._models_py3 import CommonSku
from ._models_py3 import DataControllerProperties
from ._models_py3 import DataControllerResource
from ._models_py3 import DataControllerUpdate
from ._models_py3 import ErrorResponse
from ._models_py3 import ErrorResponseBody
from ._models_py3 import ExtendedLocation
from ._models_py3 import K8SResourceRequirements
from ._models_py3 import K8SScheduling
from ._models_py3 import K8SSchedulingOptions
from ._models_py3 import KeytabInformation
from ._models_py3 import LogAnalyticsWorkspaceConfig
from ._models_py3 import OnPremiseProperty
from ._models_py3 import Operation
from ._models_py3 import OperationDisplay
from ._models_py3 import OperationListResult
from ._models_py3 import PageOfDataControllerResource
from ._models_py3 import PostgresInstance
from ._models_py3 import PostgresInstanceListResult
from ._models_py3 import PostgresInstanceProperties
from ._models_py3 import PostgresInstanceSku
from ._models_py3 import PostgresInstanceUpdate
from ._models_py3 import ProxyResource
from ._models_py3 import Resource
from ._models_py3 import SqlManagedInstance
from ._models_py3 import SqlManagedInstanceK8SRaw
from ._models_py3 import SqlManagedInstanceK8SSpec
from ._models_py3 import SqlManagedInstanceListResult
from ._models_py3 import SqlManagedInstanceProperties
from ._models_py3 import SqlManagedInstanceSku
from ._models_py3 import SqlManagedInstanceUpdate
from ._models_py3 import SqlServerInstance
from ._models_py3 import SqlServerInstanceListResult
from ._models_py3 import SqlServerInstanceProperties
from ._models_py3 import SqlServerInstanceUpdate
from ._models_py3 import SystemData
from ._models_py3 import TrackedResource
from ._models_py3 import UploadServicePrincipal
from ._models_py3 import UploadWatermark
from ._azure_arc_data_management_client_enums import AccountProvisioningMode
from ._azure_arc_data_management_client_enums import ArcSqlManagedInstanceLicenseType
from ._azure_arc_data_management_client_enums import ArcSqlServerLicenseType
from ._azure_arc_data_management_client_enums import ConnectionStatus
from ._azure_arc_data_management_client_enums import CreatedByType
from ._azure_arc_data_management_client_enums import DefenderStatus
from ._azure_arc_data_management_client_enums import EditionType
from ._azure_arc_data_management_client_enums import ExtendedLocationTypes
from ._azure_arc_data_management_client_enums import HostType
from ._azure_arc_data_management_client_enums import Infrastructure
from ._azure_arc_data_management_client_enums import OperationOrigin
from ._azure_arc_data_management_client_enums import SqlManagedInstanceSkuTier
from ._azure_arc_data_management_client_enums import SqlVersion
from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
from ._patch import patch_sdk as _patch_sdk
__all__ = [
"ActiveDirectoryConnectorDNSDetails",
"ActiveDirectoryConnectorDomainDetails",
"ActiveDirectoryConnectorListResult",
"ActiveDirectoryConnectorProperties",
"ActiveDirectoryConnectorResource",
"ActiveDirectoryConnectorSpec",
"ActiveDirectoryConnectorStatus",
"ActiveDirectoryDomainController",
"ActiveDirectoryDomainControllers",
"ActiveDirectoryInformation",
"BasicLoginInformation",
"CommonSku",
"DataControllerProperties",
"DataControllerResource",
"DataControllerUpdate",
"ErrorResponse",
"ErrorResponseBody",
"ExtendedLocation",
"K8SResourceRequirements",
"K8SScheduling",
"K8SSchedulingOptions",
"KeytabInformation",
"LogAnalyticsWorkspaceConfig",
"OnPremiseProperty",
"Operation",
"OperationDisplay",
"OperationListResult",
"PageOfDataControllerResource",
"PostgresInstance",
"PostgresInstanceListResult",
"PostgresInstanceProperties",
"PostgresInstanceSku",
"PostgresInstanceUpdate",
"ProxyResource",
"Resource",
"SqlManagedInstance",
"SqlManagedInstanceK8SRaw",
"SqlManagedInstanceK8SSpec",
"SqlManagedInstanceListResult",
"SqlManagedInstanceProperties",
"SqlManagedInstanceSku",
"SqlManagedInstanceUpdate",
"SqlServerInstance",
"SqlServerInstanceListResult",
"SqlServerInstanceProperties",
"SqlServerInstanceUpdate",
"SystemData",
"TrackedResource",
"UploadServicePrincipal",
"UploadWatermark",
"AccountProvisioningMode",
"ArcSqlManagedInstanceLicenseType",
"ArcSqlServerLicenseType",
"ConnectionStatus",
"CreatedByType",
"DefenderStatus",
"EditionType",
"ExtendedLocationTypes",
"HostType",
"Infrastructure",
"OperationOrigin",
"SqlManagedInstanceSkuTier",
"SqlVersion",
]
__all__.extend([p for p in _patch_all if p not in __all__])
_patch_sdk()
|
azure-mgmt-azurearcdata
|
/azure-mgmt-azurearcdata-2.0.0b1.zip/azure-mgmt-azurearcdata-2.0.0b1/azure/mgmt/azurearcdata/models/__init__.py
|
__init__.py
|
from ._models_py3 import ActiveDirectoryConnectorDNSDetails
from ._models_py3 import ActiveDirectoryConnectorDomainDetails
from ._models_py3 import ActiveDirectoryConnectorListResult
from ._models_py3 import ActiveDirectoryConnectorProperties
from ._models_py3 import ActiveDirectoryConnectorResource
from ._models_py3 import ActiveDirectoryConnectorSpec
from ._models_py3 import ActiveDirectoryConnectorStatus
from ._models_py3 import ActiveDirectoryDomainController
from ._models_py3 import ActiveDirectoryDomainControllers
from ._models_py3 import ActiveDirectoryInformation
from ._models_py3 import BasicLoginInformation
from ._models_py3 import CommonSku
from ._models_py3 import DataControllerProperties
from ._models_py3 import DataControllerResource
from ._models_py3 import DataControllerUpdate
from ._models_py3 import ErrorResponse
from ._models_py3 import ErrorResponseBody
from ._models_py3 import ExtendedLocation
from ._models_py3 import K8SResourceRequirements
from ._models_py3 import K8SScheduling
from ._models_py3 import K8SSchedulingOptions
from ._models_py3 import KeytabInformation
from ._models_py3 import LogAnalyticsWorkspaceConfig
from ._models_py3 import OnPremiseProperty
from ._models_py3 import Operation
from ._models_py3 import OperationDisplay
from ._models_py3 import OperationListResult
from ._models_py3 import PageOfDataControllerResource
from ._models_py3 import PostgresInstance
from ._models_py3 import PostgresInstanceListResult
from ._models_py3 import PostgresInstanceProperties
from ._models_py3 import PostgresInstanceSku
from ._models_py3 import PostgresInstanceUpdate
from ._models_py3 import ProxyResource
from ._models_py3 import Resource
from ._models_py3 import SqlManagedInstance
from ._models_py3 import SqlManagedInstanceK8SRaw
from ._models_py3 import SqlManagedInstanceK8SSpec
from ._models_py3 import SqlManagedInstanceListResult
from ._models_py3 import SqlManagedInstanceProperties
from ._models_py3 import SqlManagedInstanceSku
from ._models_py3 import SqlManagedInstanceUpdate
from ._models_py3 import SqlServerInstance
from ._models_py3 import SqlServerInstanceListResult
from ._models_py3 import SqlServerInstanceProperties
from ._models_py3 import SqlServerInstanceUpdate
from ._models_py3 import SystemData
from ._models_py3 import TrackedResource
from ._models_py3 import UploadServicePrincipal
from ._models_py3 import UploadWatermark
from ._azure_arc_data_management_client_enums import AccountProvisioningMode
from ._azure_arc_data_management_client_enums import ArcSqlManagedInstanceLicenseType
from ._azure_arc_data_management_client_enums import ArcSqlServerLicenseType
from ._azure_arc_data_management_client_enums import ConnectionStatus
from ._azure_arc_data_management_client_enums import CreatedByType
from ._azure_arc_data_management_client_enums import DefenderStatus
from ._azure_arc_data_management_client_enums import EditionType
from ._azure_arc_data_management_client_enums import ExtendedLocationTypes
from ._azure_arc_data_management_client_enums import HostType
from ._azure_arc_data_management_client_enums import Infrastructure
from ._azure_arc_data_management_client_enums import OperationOrigin
from ._azure_arc_data_management_client_enums import SqlManagedInstanceSkuTier
from ._azure_arc_data_management_client_enums import SqlVersion
from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
from ._patch import patch_sdk as _patch_sdk
__all__ = [
"ActiveDirectoryConnectorDNSDetails",
"ActiveDirectoryConnectorDomainDetails",
"ActiveDirectoryConnectorListResult",
"ActiveDirectoryConnectorProperties",
"ActiveDirectoryConnectorResource",
"ActiveDirectoryConnectorSpec",
"ActiveDirectoryConnectorStatus",
"ActiveDirectoryDomainController",
"ActiveDirectoryDomainControllers",
"ActiveDirectoryInformation",
"BasicLoginInformation",
"CommonSku",
"DataControllerProperties",
"DataControllerResource",
"DataControllerUpdate",
"ErrorResponse",
"ErrorResponseBody",
"ExtendedLocation",
"K8SResourceRequirements",
"K8SScheduling",
"K8SSchedulingOptions",
"KeytabInformation",
"LogAnalyticsWorkspaceConfig",
"OnPremiseProperty",
"Operation",
"OperationDisplay",
"OperationListResult",
"PageOfDataControllerResource",
"PostgresInstance",
"PostgresInstanceListResult",
"PostgresInstanceProperties",
"PostgresInstanceSku",
"PostgresInstanceUpdate",
"ProxyResource",
"Resource",
"SqlManagedInstance",
"SqlManagedInstanceK8SRaw",
"SqlManagedInstanceK8SSpec",
"SqlManagedInstanceListResult",
"SqlManagedInstanceProperties",
"SqlManagedInstanceSku",
"SqlManagedInstanceUpdate",
"SqlServerInstance",
"SqlServerInstanceListResult",
"SqlServerInstanceProperties",
"SqlServerInstanceUpdate",
"SystemData",
"TrackedResource",
"UploadServicePrincipal",
"UploadWatermark",
"AccountProvisioningMode",
"ArcSqlManagedInstanceLicenseType",
"ArcSqlServerLicenseType",
"ConnectionStatus",
"CreatedByType",
"DefenderStatus",
"EditionType",
"ExtendedLocationTypes",
"HostType",
"Infrastructure",
"OperationOrigin",
"SqlManagedInstanceSkuTier",
"SqlVersion",
]
__all__.extend([p for p in _patch_all if p not in __all__])
_patch_sdk()
| 0.450118 | 0.059483 |
# Microsoft Azure SDK for Python
This is the Microsoft Azure Azure Stack Management Client Library.
This package has been tested with Python 3.7+.
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).
## _Disclaimer_
_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_
# Usage
To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt)
For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/)
Code samples for this package can be found at [Azure Stack Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com.
Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
# Provide Feedback
If you encounter any bugs or have suggestions, please file an issue in the
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
section of the project.

|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/README.md
|
README.md
|
# Microsoft Azure SDK for Python
This is the Microsoft Azure Azure Stack Management Client Library.
This package has been tested with Python 3.7+.
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).
## _Disclaimer_
_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_
# Usage
To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt)
For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/)
Code samples for this package can be found at [Azure Stack Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com.
Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
# Provide Feedback
If you encounter any bugs or have suggestions, please file an issue in the
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
section of the project.

| 0.784897 | 0.611672 |
# Release History
## 2.0.0b1 (2022-11-17)
### Features Added
- Added operation ProductsOperations.list_products
- Added operation RegistrationsOperations.list_by_subscription
- Added operation group DeploymentLicenseOperations
### Breaking Changes
- Model CustomerSubscription no longer has parameter system_data
- Model Product no longer has parameter system_data
- Model Registration no longer has parameter kind
- Model Registration no longer has parameter system_data
- Model TrackedResource no longer has parameter kind
- Model TrackedResource no longer has parameter system_data
- Removed operation group LinkedSubscriptionsOperations
## 1.0.0 (2021-04-08)
**Features**
- Model Registration has a new parameter system_data
- Model Registration has a new parameter kind
- Model TrackedResource has a new parameter system_data
- Model TrackedResource has a new parameter kind
- Model CustomerSubscription has a new parameter system_data
- Model Product has a new parameter system_data
- Added operation RegistrationsOperations.enable_remote_management
- Added operation group LinkedSubscriptionsOperations
**Breaking changes**
- Operation ProductsOperations.get_products has a new signature
## 1.0.0b1 (2020-12-03)
This is beta preview version.
This version uses a next-generation code generator that introduces important breaking changes, but also important new features (like unified authentication and async programming).
**General breaking changes**
- Credential system has been completly revamped:
- `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported, use the `azure-identity` classes instead: https://pypi.org/project/azure-identity/
- `credentials` parameter has been renamed `credential`
- The `config` attribute no longer exists on a client, configuration should be passed as kwarg. Example: `MyClient(credential, subscription_id, enable_logging=True)`. For a complete set of
supported options, see the [parameters accept in init documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies)
- You can't import a `version` module anymore, use `__version__` instead
- Operations that used to return a `msrest.polling.LROPoller` now returns a `azure.core.polling.LROPoller` and are prefixed with `begin_`.
- Exceptions tree have been simplified and most exceptions are now `azure.core.exceptions.HttpResponseError` (`CloudError` has been removed).
- Most of the operation kwarg have changed. Some of the most noticeable:
- `raw` has been removed. Equivalent feature can be found using `cls`, a callback that will give access to internal HTTP response for advanced user
- For a complete set of
supported options, see the [parameters accept in Request documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies)
**General new features**
- Type annotations support using `typing`. SDKs are mypy ready.
- This client has now stable and official support for async. Check the `aio` namespace of your package to find the async client.
- This client now support natively tracing library like OpenCensus or OpenTelemetry. See this [tracing quickstart](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/core/azure-core-tracing-opentelemetry) for an overview.
## 0.1.0 (2020-01-15)
- Initial Release
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/CHANGELOG.md
|
CHANGELOG.md
|
# Release History
## 2.0.0b1 (2022-11-17)
### Features Added
- Added operation ProductsOperations.list_products
- Added operation RegistrationsOperations.list_by_subscription
- Added operation group DeploymentLicenseOperations
### Breaking Changes
- Model CustomerSubscription no longer has parameter system_data
- Model Product no longer has parameter system_data
- Model Registration no longer has parameter kind
- Model Registration no longer has parameter system_data
- Model TrackedResource no longer has parameter kind
- Model TrackedResource no longer has parameter system_data
- Removed operation group LinkedSubscriptionsOperations
## 1.0.0 (2021-04-08)
**Features**
- Model Registration has a new parameter system_data
- Model Registration has a new parameter kind
- Model TrackedResource has a new parameter system_data
- Model TrackedResource has a new parameter kind
- Model CustomerSubscription has a new parameter system_data
- Model Product has a new parameter system_data
- Added operation RegistrationsOperations.enable_remote_management
- Added operation group LinkedSubscriptionsOperations
**Breaking changes**
- Operation ProductsOperations.get_products has a new signature
## 1.0.0b1 (2020-12-03)
This is beta preview version.
This version uses a next-generation code generator that introduces important breaking changes, but also important new features (like unified authentication and async programming).
**General breaking changes**
- Credential system has been completly revamped:
- `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported, use the `azure-identity` classes instead: https://pypi.org/project/azure-identity/
- `credentials` parameter has been renamed `credential`
- The `config` attribute no longer exists on a client, configuration should be passed as kwarg. Example: `MyClient(credential, subscription_id, enable_logging=True)`. For a complete set of
supported options, see the [parameters accept in init documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies)
- You can't import a `version` module anymore, use `__version__` instead
- Operations that used to return a `msrest.polling.LROPoller` now returns a `azure.core.polling.LROPoller` and are prefixed with `begin_`.
- Exceptions tree have been simplified and most exceptions are now `azure.core.exceptions.HttpResponseError` (`CloudError` has been removed).
- Most of the operation kwarg have changed. Some of the most noticeable:
- `raw` has been removed. Equivalent feature can be found using `cls`, a callback that will give access to internal HTTP response for advanced user
- For a complete set of
supported options, see the [parameters accept in Request documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies)
**General new features**
- Type annotations support using `typing`. SDKs are mypy ready.
- This client has now stable and official support for async. Check the `aio` namespace of your package to find the async client.
- This client now support natively tracing library like OpenCensus or OpenTelemetry. See this [tracing quickstart](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/core/azure-core-tracing-opentelemetry) for an overview.
## 0.1.0 (2020-01-15)
- Initial Release
| 0.821474 | 0.249596 |
from copy import deepcopy
from typing import Any, TYPE_CHECKING
from azure.core.rest import HttpRequest, HttpResponse
from azure.mgmt.core import ARMPipelineClient
from . import models as _models
from ._configuration import AzureStackManagementClientConfiguration
from ._serialization import Deserializer, Serializer
from .operations import (
CloudManifestFileOperations,
CustomerSubscriptionsOperations,
DeploymentLicenseOperations,
Operations,
ProductsOperations,
RegistrationsOperations,
)
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class AzureStackManagementClient: # pylint: disable=client-accepts-api-version-keyword
"""Azure Stack.
:ivar operations: Operations operations
:vartype operations: azure.mgmt.azurestack.operations.Operations
:ivar cloud_manifest_file: CloudManifestFileOperations operations
:vartype cloud_manifest_file: azure.mgmt.azurestack.operations.CloudManifestFileOperations
:ivar deployment_license: DeploymentLicenseOperations operations
:vartype deployment_license: azure.mgmt.azurestack.operations.DeploymentLicenseOperations
:ivar customer_subscriptions: CustomerSubscriptionsOperations operations
:vartype customer_subscriptions:
azure.mgmt.azurestack.operations.CustomerSubscriptionsOperations
:ivar products: ProductsOperations operations
:vartype products: azure.mgmt.azurestack.operations.ProductsOperations
:ivar registrations: RegistrationsOperations operations
:vartype registrations: azure.mgmt.azurestack.operations.RegistrationsOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: Subscription credentials that uniquely identify Microsoft Azure
subscription. The subscription ID forms part of the URI for every service call. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = AzureStackManagementClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.cloud_manifest_file = CloudManifestFileOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.deployment_license = DeploymentLicenseOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.customer_subscriptions = CustomerSubscriptionsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.products = ProductsOperations(self._client, self._config, self._serialize, self._deserialize)
self.registrations = RegistrationsOperations(self._client, self._config, self._serialize, self._deserialize)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.HttpResponse
"""
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) -> None:
self._client.close()
def __enter__(self) -> "AzureStackManagementClient":
self._client.__enter__()
return self
def __exit__(self, *exc_details) -> None:
self._client.__exit__(*exc_details)
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/_azure_stack_management_client.py
|
_azure_stack_management_client.py
|
from copy import deepcopy
from typing import Any, TYPE_CHECKING
from azure.core.rest import HttpRequest, HttpResponse
from azure.mgmt.core import ARMPipelineClient
from . import models as _models
from ._configuration import AzureStackManagementClientConfiguration
from ._serialization import Deserializer, Serializer
from .operations import (
CloudManifestFileOperations,
CustomerSubscriptionsOperations,
DeploymentLicenseOperations,
Operations,
ProductsOperations,
RegistrationsOperations,
)
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class AzureStackManagementClient: # pylint: disable=client-accepts-api-version-keyword
"""Azure Stack.
:ivar operations: Operations operations
:vartype operations: azure.mgmt.azurestack.operations.Operations
:ivar cloud_manifest_file: CloudManifestFileOperations operations
:vartype cloud_manifest_file: azure.mgmt.azurestack.operations.CloudManifestFileOperations
:ivar deployment_license: DeploymentLicenseOperations operations
:vartype deployment_license: azure.mgmt.azurestack.operations.DeploymentLicenseOperations
:ivar customer_subscriptions: CustomerSubscriptionsOperations operations
:vartype customer_subscriptions:
azure.mgmt.azurestack.operations.CustomerSubscriptionsOperations
:ivar products: ProductsOperations operations
:vartype products: azure.mgmt.azurestack.operations.ProductsOperations
:ivar registrations: RegistrationsOperations operations
:vartype registrations: azure.mgmt.azurestack.operations.RegistrationsOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: Subscription credentials that uniquely identify Microsoft Azure
subscription. The subscription ID forms part of the URI for every service call. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = AzureStackManagementClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.cloud_manifest_file = CloudManifestFileOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.deployment_license = DeploymentLicenseOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.customer_subscriptions = CustomerSubscriptionsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.products = ProductsOperations(self._client, self._config, self._serialize, self._deserialize)
self.registrations = RegistrationsOperations(self._client, self._config, self._serialize, self._deserialize)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.HttpResponse
"""
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) -> None:
self._client.close()
def __enter__(self) -> "AzureStackManagementClient":
self._client.__enter__()
return self
def __exit__(self, *exc_details) -> None:
self._client.__exit__(*exc_details)
| 0.827166 | 0.096068 |
import sys
from typing import Any, TYPE_CHECKING
from azure.core.configuration import Configuration
from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
from ._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class AzureStackManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureStackManagementClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: Subscription credentials that uniquely identify Microsoft Azure
subscription. The subscription ID forms part of the URI for every service call. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(AzureStackManagementClientConfiguration, self).__init__(**kwargs)
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", "2022-06-01")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-azurestack/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = ARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/_configuration.py
|
_configuration.py
|
import sys
from typing import Any, TYPE_CHECKING
from azure.core.configuration import Configuration
from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
from ._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class AzureStackManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureStackManagementClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: Subscription credentials that uniquely identify Microsoft Azure
subscription. The subscription ID forms part of the URI for every service call. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(AzureStackManagementClientConfiguration, self).__init__(**kwargs)
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", "2022-06-01")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-azurestack/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = ARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
| 0.55254 | 0.0771 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group: str, registration_name: str, product_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"productName": _SERIALIZER.url("product_name", product_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_details_request(
resource_group: str, registration_name: str, product_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listDetails",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"productName": _SERIALIZER.url("product_name", product_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_products_request(
resource_group: str, registration_name: str, product_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listProducts",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"productName": _SERIALIZER.url("product_name", product_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_products_request(
resource_group: str, registration_name: str, product_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProducts",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"productName": _SERIALIZER.url("product_name", product_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_product_request(
resource_group: str, registration_name: str, product_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProduct",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"productName": _SERIALIZER.url("product_name", product_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_upload_log_request(
resource_group: str, registration_name: str, product_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/uploadProductLog",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"productName": _SERIALIZER.url("product_name", product_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
class ProductsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.AzureStackManagementClient`'s
:attr:`products` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, resource_group: str, registration_name: str, **kwargs: Any) -> Iterable["_models.Product"]:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Product or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestack.models.Product]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ProductList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ProductList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products"
}
@distributed_trace
def get(self, resource_group: str, registration_name: str, product_name: str, **kwargs: Any) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Product] = kwargs.pop("cls", None)
request = build_get_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Product", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}"
}
@distributed_trace
def list_details(
self, resource_group: str, registration_name: str, product_name: str, **kwargs: Any
) -> _models.ExtendedProduct:
"""Returns the extended properties of a product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ExtendedProduct or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ExtendedProduct
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ExtendedProduct] = kwargs.pop("cls", None)
request = build_list_details_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_details.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ExtendedProduct", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list_details.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listDetails"
}
@overload
def list_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[_models.DeviceConfiguration] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def list_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def list_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[Union[_models.DeviceConfiguration, IO]] = None,
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Is either a model type or a IO type. Default
value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ProductList] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(device_configuration, (IO, bytes)):
_content = device_configuration
else:
if device_configuration is not None:
_json = self._serialize.body(device_configuration, "DeviceConfiguration")
else:
_json = None
request = build_list_products_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.list_products.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ProductList", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list_products.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listProducts"
}
@overload
def get_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[_models.DeviceConfiguration] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def get_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def get_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[Union[_models.DeviceConfiguration, IO]] = None,
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Is either a model type or a IO type. Default
value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ProductList] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(device_configuration, (IO, bytes)):
_content = device_configuration
else:
if device_configuration is not None:
_json = self._serialize.body(device_configuration, "DeviceConfiguration")
else:
_json = None
request = build_get_products_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.get_products.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ProductList", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_products.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProducts"
}
@overload
def get_product(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[_models.DeviceConfiguration] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def get_product(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def get_product(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[Union[_models.DeviceConfiguration, IO]] = None,
**kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Is either a model type or a IO type. Default
value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Product] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(device_configuration, (IO, bytes)):
_content = device_configuration
else:
if device_configuration is not None:
_json = self._serialize.body(device_configuration, "DeviceConfiguration")
else:
_json = None
request = build_get_product_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.get_product.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Product", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_product.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProduct"
}
@overload
def upload_log(
self,
resource_group: str,
registration_name: str,
product_name: str,
marketplace_product_log_update: Optional[_models.MarketplaceProductLogUpdate] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductLog:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param marketplace_product_log_update: Update details for product log. Default value is None.
:type marketplace_product_log_update: ~azure.mgmt.azurestack.models.MarketplaceProductLogUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductLog or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductLog
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def upload_log(
self,
resource_group: str,
registration_name: str,
product_name: str,
marketplace_product_log_update: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductLog:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param marketplace_product_log_update: Update details for product log. Default value is None.
:type marketplace_product_log_update: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductLog or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductLog
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def upload_log(
self,
resource_group: str,
registration_name: str,
product_name: str,
marketplace_product_log_update: Optional[Union[_models.MarketplaceProductLogUpdate, IO]] = None,
**kwargs: Any
) -> _models.ProductLog:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param marketplace_product_log_update: Update details for product log. Is either a model type
or a IO type. Default value is None.
:type marketplace_product_log_update: ~azure.mgmt.azurestack.models.MarketplaceProductLogUpdate
or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductLog or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductLog
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ProductLog] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(marketplace_product_log_update, (IO, bytes)):
_content = marketplace_product_log_update
else:
if marketplace_product_log_update is not None:
_json = self._serialize.body(marketplace_product_log_update, "MarketplaceProductLogUpdate")
else:
_json = None
request = build_upload_log_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.upload_log.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ProductLog", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
upload_log.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/uploadProductLog"
}
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/operations/_products_operations.py
|
_products_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group: str, registration_name: str, product_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"productName": _SERIALIZER.url("product_name", product_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_details_request(
resource_group: str, registration_name: str, product_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listDetails",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"productName": _SERIALIZER.url("product_name", product_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_products_request(
resource_group: str, registration_name: str, product_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listProducts",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"productName": _SERIALIZER.url("product_name", product_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_products_request(
resource_group: str, registration_name: str, product_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProducts",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"productName": _SERIALIZER.url("product_name", product_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_product_request(
resource_group: str, registration_name: str, product_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProduct",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"productName": _SERIALIZER.url("product_name", product_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_upload_log_request(
resource_group: str, registration_name: str, product_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/uploadProductLog",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"productName": _SERIALIZER.url("product_name", product_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
class ProductsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.AzureStackManagementClient`'s
:attr:`products` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, resource_group: str, registration_name: str, **kwargs: Any) -> Iterable["_models.Product"]:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Product or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestack.models.Product]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ProductList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ProductList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products"
}
@distributed_trace
def get(self, resource_group: str, registration_name: str, product_name: str, **kwargs: Any) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Product] = kwargs.pop("cls", None)
request = build_get_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Product", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}"
}
@distributed_trace
def list_details(
self, resource_group: str, registration_name: str, product_name: str, **kwargs: Any
) -> _models.ExtendedProduct:
"""Returns the extended properties of a product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ExtendedProduct or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ExtendedProduct
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ExtendedProduct] = kwargs.pop("cls", None)
request = build_list_details_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_details.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ExtendedProduct", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list_details.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listDetails"
}
@overload
def list_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[_models.DeviceConfiguration] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def list_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def list_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[Union[_models.DeviceConfiguration, IO]] = None,
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Is either a model type or a IO type. Default
value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ProductList] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(device_configuration, (IO, bytes)):
_content = device_configuration
else:
if device_configuration is not None:
_json = self._serialize.body(device_configuration, "DeviceConfiguration")
else:
_json = None
request = build_list_products_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.list_products.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ProductList", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list_products.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listProducts"
}
@overload
def get_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[_models.DeviceConfiguration] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def get_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def get_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[Union[_models.DeviceConfiguration, IO]] = None,
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Is either a model type or a IO type. Default
value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ProductList] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(device_configuration, (IO, bytes)):
_content = device_configuration
else:
if device_configuration is not None:
_json = self._serialize.body(device_configuration, "DeviceConfiguration")
else:
_json = None
request = build_get_products_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.get_products.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ProductList", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_products.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProducts"
}
@overload
def get_product(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[_models.DeviceConfiguration] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def get_product(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def get_product(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[Union[_models.DeviceConfiguration, IO]] = None,
**kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Is either a model type or a IO type. Default
value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Product] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(device_configuration, (IO, bytes)):
_content = device_configuration
else:
if device_configuration is not None:
_json = self._serialize.body(device_configuration, "DeviceConfiguration")
else:
_json = None
request = build_get_product_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.get_product.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Product", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_product.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProduct"
}
@overload
def upload_log(
self,
resource_group: str,
registration_name: str,
product_name: str,
marketplace_product_log_update: Optional[_models.MarketplaceProductLogUpdate] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductLog:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param marketplace_product_log_update: Update details for product log. Default value is None.
:type marketplace_product_log_update: ~azure.mgmt.azurestack.models.MarketplaceProductLogUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductLog or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductLog
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def upload_log(
self,
resource_group: str,
registration_name: str,
product_name: str,
marketplace_product_log_update: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductLog:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param marketplace_product_log_update: Update details for product log. Default value is None.
:type marketplace_product_log_update: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductLog or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductLog
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def upload_log(
self,
resource_group: str,
registration_name: str,
product_name: str,
marketplace_product_log_update: Optional[Union[_models.MarketplaceProductLogUpdate, IO]] = None,
**kwargs: Any
) -> _models.ProductLog:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param marketplace_product_log_update: Update details for product log. Is either a model type
or a IO type. Default value is None.
:type marketplace_product_log_update: ~azure.mgmt.azurestack.models.MarketplaceProductLogUpdate
or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductLog or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductLog
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ProductLog] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(marketplace_product_log_update, (IO, bytes)):
_content = marketplace_product_log_update
else:
if marketplace_product_log_update is not None:
_json = self._serialize.body(marketplace_product_log_update, "MarketplaceProductLogUpdate")
else:
_json = None
request = build_upload_log_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.upload_log.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ProductLog", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
upload_log.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/uploadProductLog"
}
| 0.571049 | 0.066721 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group: str, registration_name: str, customer_subscription_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"customerSubscriptionName": _SERIALIZER.url("customer_subscription_name", customer_subscription_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group: str, registration_name: str, customer_subscription_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"customerSubscriptionName": _SERIALIZER.url("customer_subscription_name", customer_subscription_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group: str, registration_name: str, customer_subscription_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"customerSubscriptionName": _SERIALIZER.url("customer_subscription_name", customer_subscription_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
class CustomerSubscriptionsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.AzureStackManagementClient`'s
:attr:`customer_subscriptions` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(
self, resource_group: str, registration_name: str, **kwargs: Any
) -> Iterable["_models.CustomerSubscription"]:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either CustomerSubscription or the result of
cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestack.models.CustomerSubscription]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CustomerSubscriptionList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("CustomerSubscriptionList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions"
}
@distributed_trace
def get(
self, resource_group: str, registration_name: str, customer_subscription_name: str, **kwargs: Any
) -> _models.CustomerSubscription:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CustomerSubscription] = kwargs.pop("cls", None)
request = build_get_request(
resource_group=resource_group,
registration_name=registration_name,
customer_subscription_name=customer_subscription_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CustomerSubscription", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group: str, registration_name: str, customer_subscription_name: str, **kwargs: Any
) -> None:
"""Deletes a customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group=resource_group,
registration_name=registration_name,
customer_subscription_name=customer_subscription_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}"
}
@overload
def create(
self,
resource_group: str,
registration_name: str,
customer_subscription_name: str,
customer_creation_parameters: _models.CustomerSubscription,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.CustomerSubscription:
"""Creates a new customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:param customer_creation_parameters: Parameters use to create a customer subscription.
Required.
:type customer_creation_parameters: ~azure.mgmt.azurestack.models.CustomerSubscription
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def create(
self,
resource_group: str,
registration_name: str,
customer_subscription_name: str,
customer_creation_parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.CustomerSubscription:
"""Creates a new customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:param customer_creation_parameters: Parameters use to create a customer subscription.
Required.
:type customer_creation_parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def create(
self,
resource_group: str,
registration_name: str,
customer_subscription_name: str,
customer_creation_parameters: Union[_models.CustomerSubscription, IO],
**kwargs: Any
) -> _models.CustomerSubscription:
"""Creates a new customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:param customer_creation_parameters: Parameters use to create a customer subscription. Is
either a model type or a IO type. Required.
:type customer_creation_parameters: ~azure.mgmt.azurestack.models.CustomerSubscription or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.CustomerSubscription] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(customer_creation_parameters, (IO, bytes)):
_content = customer_creation_parameters
else:
_json = self._serialize.body(customer_creation_parameters, "CustomerSubscription")
request = build_create_request(
resource_group=resource_group,
registration_name=registration_name,
customer_subscription_name=customer_subscription_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CustomerSubscription", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}"
}
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/operations/_customer_subscriptions_operations.py
|
_customer_subscriptions_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group: str, registration_name: str, customer_subscription_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"customerSubscriptionName": _SERIALIZER.url("customer_subscription_name", customer_subscription_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group: str, registration_name: str, customer_subscription_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"customerSubscriptionName": _SERIALIZER.url("customer_subscription_name", customer_subscription_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group: str, registration_name: str, customer_subscription_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
"customerSubscriptionName": _SERIALIZER.url("customer_subscription_name", customer_subscription_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
class CustomerSubscriptionsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.AzureStackManagementClient`'s
:attr:`customer_subscriptions` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(
self, resource_group: str, registration_name: str, **kwargs: Any
) -> Iterable["_models.CustomerSubscription"]:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either CustomerSubscription or the result of
cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestack.models.CustomerSubscription]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CustomerSubscriptionList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("CustomerSubscriptionList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions"
}
@distributed_trace
def get(
self, resource_group: str, registration_name: str, customer_subscription_name: str, **kwargs: Any
) -> _models.CustomerSubscription:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CustomerSubscription] = kwargs.pop("cls", None)
request = build_get_request(
resource_group=resource_group,
registration_name=registration_name,
customer_subscription_name=customer_subscription_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CustomerSubscription", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group: str, registration_name: str, customer_subscription_name: str, **kwargs: Any
) -> None:
"""Deletes a customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group=resource_group,
registration_name=registration_name,
customer_subscription_name=customer_subscription_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}"
}
@overload
def create(
self,
resource_group: str,
registration_name: str,
customer_subscription_name: str,
customer_creation_parameters: _models.CustomerSubscription,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.CustomerSubscription:
"""Creates a new customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:param customer_creation_parameters: Parameters use to create a customer subscription.
Required.
:type customer_creation_parameters: ~azure.mgmt.azurestack.models.CustomerSubscription
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def create(
self,
resource_group: str,
registration_name: str,
customer_subscription_name: str,
customer_creation_parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.CustomerSubscription:
"""Creates a new customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:param customer_creation_parameters: Parameters use to create a customer subscription.
Required.
:type customer_creation_parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def create(
self,
resource_group: str,
registration_name: str,
customer_subscription_name: str,
customer_creation_parameters: Union[_models.CustomerSubscription, IO],
**kwargs: Any
) -> _models.CustomerSubscription:
"""Creates a new customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:param customer_creation_parameters: Parameters use to create a customer subscription. Is
either a model type or a IO type. Required.
:type customer_creation_parameters: ~azure.mgmt.azurestack.models.CustomerSubscription or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.CustomerSubscription] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(customer_creation_parameters, (IO, bytes)):
_content = customer_creation_parameters
else:
_json = self._serialize.body(customer_creation_parameters, "CustomerSubscription")
request = build_create_request(
resource_group=resource_group,
registration_name=registration_name,
customer_subscription_name=customer_subscription_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CustomerSubscription", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}"
}
| 0.573678 | 0.074198 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(resource_group: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/registrations")
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_activation_key_request(
resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/getactivationkey",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_enable_remote_management_request(
resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/enableRemoteManagement",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs)
class RegistrationsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.AzureStackManagementClient`'s
:attr:`registrations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, resource_group: str, **kwargs: Any) -> Iterable["_models.Registration"]:
"""Returns a list of all registrations.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Registration or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestack.models.Registration]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.RegistrationList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group=resource_group,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("RegistrationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Registration"]:
"""Returns a list of all registrations under current subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Registration or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestack.models.Registration]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.RegistrationList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("RegistrationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/registrations"
}
@distributed_trace
def get(self, resource_group: str, registration_name: str, **kwargs: Any) -> _models.Registration:
"""Returns the properties of an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Registration] = kwargs.pop("cls", None)
request = build_get_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Registration", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group: str, registration_name: str, **kwargs: Any
) -> None:
"""Delete the requested Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@overload
def create_or_update(
self,
resource_group: str,
registration_name: str,
token: _models.RegistrationParameter,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Create or update an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def create_or_update(
self,
resource_group: str,
registration_name: str,
token: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Create or update an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def create_or_update(
self,
resource_group: str,
registration_name: str,
token: Union[_models.RegistrationParameter, IO],
**kwargs: Any
) -> _models.Registration:
"""Create or update an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Is either a model type or a IO type. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Registration] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(token, (IO, bytes)):
_content = token
else:
_json = self._serialize.body(token, "RegistrationParameter")
request = build_create_or_update_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create_or_update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Registration", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Registration", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@overload
def update(
self,
resource_group: str,
registration_name: str,
token: _models.RegistrationParameter,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Patch an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group: str,
registration_name: str,
token: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Patch an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group: str,
registration_name: str,
token: Union[_models.RegistrationParameter, IO],
**kwargs: Any
) -> _models.Registration:
"""Patch an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Is either a model type or a IO type. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Registration] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(token, (IO, bytes)):
_content = token
else:
_json = self._serialize.body(token, "RegistrationParameter")
request = build_update_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Registration", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@distributed_trace
def get_activation_key(
self, resource_group: str, registration_name: str, **kwargs: Any
) -> _models.ActivationKeyResult:
"""Returns Azure Stack Activation Key.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ActivationKeyResult or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ActivationKeyResult
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ActivationKeyResult] = kwargs.pop("cls", None)
request = build_get_activation_key_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get_activation_key.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ActivationKeyResult", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_activation_key.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/getactivationkey"
}
@distributed_trace
def enable_remote_management( # pylint: disable=inconsistent-return-statements
self, resource_group: str, registration_name: str, **kwargs: Any
) -> None:
"""Enables remote management for device under the Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = kwargs.pop("params", {}) or {}
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_enable_remote_management_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
template_url=self.enable_remote_management.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
enable_remote_management.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/enableRemoteManagement"
}
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/operations/_registrations_operations.py
|
_registrations_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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(resource_group: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/registrations")
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_activation_key_request(
resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/getactivationkey",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_enable_remote_management_request(
resource_group: str, registration_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/enableRemoteManagement",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroup": _SERIALIZER.url("resource_group", resource_group, "str"),
"registrationName": _SERIALIZER.url("registration_name", registration_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs)
class RegistrationsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.AzureStackManagementClient`'s
:attr:`registrations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, resource_group: str, **kwargs: Any) -> Iterable["_models.Registration"]:
"""Returns a list of all registrations.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Registration or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestack.models.Registration]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.RegistrationList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group=resource_group,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("RegistrationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Registration"]:
"""Returns a list of all registrations under current subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Registration or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestack.models.Registration]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.RegistrationList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("RegistrationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/registrations"
}
@distributed_trace
def get(self, resource_group: str, registration_name: str, **kwargs: Any) -> _models.Registration:
"""Returns the properties of an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Registration] = kwargs.pop("cls", None)
request = build_get_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Registration", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group: str, registration_name: str, **kwargs: Any
) -> None:
"""Delete the requested Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@overload
def create_or_update(
self,
resource_group: str,
registration_name: str,
token: _models.RegistrationParameter,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Create or update an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def create_or_update(
self,
resource_group: str,
registration_name: str,
token: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Create or update an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def create_or_update(
self,
resource_group: str,
registration_name: str,
token: Union[_models.RegistrationParameter, IO],
**kwargs: Any
) -> _models.Registration:
"""Create or update an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Is either a model type or a IO type. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Registration] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(token, (IO, bytes)):
_content = token
else:
_json = self._serialize.body(token, "RegistrationParameter")
request = build_create_or_update_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create_or_update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Registration", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Registration", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@overload
def update(
self,
resource_group: str,
registration_name: str,
token: _models.RegistrationParameter,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Patch an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group: str,
registration_name: str,
token: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Patch an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group: str,
registration_name: str,
token: Union[_models.RegistrationParameter, IO],
**kwargs: Any
) -> _models.Registration:
"""Patch an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Is either a model type or a IO type. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Registration] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(token, (IO, bytes)):
_content = token
else:
_json = self._serialize.body(token, "RegistrationParameter")
request = build_update_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Registration", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@distributed_trace
def get_activation_key(
self, resource_group: str, registration_name: str, **kwargs: Any
) -> _models.ActivationKeyResult:
"""Returns Azure Stack Activation Key.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ActivationKeyResult or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ActivationKeyResult
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ActivationKeyResult] = kwargs.pop("cls", None)
request = build_get_activation_key_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get_activation_key.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ActivationKeyResult", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_activation_key.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/getactivationkey"
}
@distributed_trace
def enable_remote_management( # pylint: disable=inconsistent-return-statements
self, resource_group: str, registration_name: str, **kwargs: Any
) -> None:
"""Enables remote management for device under the Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = kwargs.pop("params", {}) or {}
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_enable_remote_management_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
template_url=self.enable_remote_management.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
enable_remote_management.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/enableRemoteManagement"
}
| 0.588534 | 0.089893 |
import sys
from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_create_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/generateDeploymentLicense"
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
class DeploymentLicenseOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.AzureStackManagementClient`'s
:attr:`deployment_license` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@overload
def create(
self,
deployment_license_request: _models.DeploymentLicenseRequest,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.DeploymentLicenseResponse:
"""Creates a license that can be used to deploy an Azure Stack device.
:param deployment_license_request: Request body for creating a deployment license. Required.
:type deployment_license_request: ~azure.mgmt.azurestack.models.DeploymentLicenseRequest
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DeploymentLicenseResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.DeploymentLicenseResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def create(
self, deployment_license_request: IO, *, content_type: str = "application/json", **kwargs: Any
) -> _models.DeploymentLicenseResponse:
"""Creates a license that can be used to deploy an Azure Stack device.
:param deployment_license_request: Request body for creating a deployment license. Required.
:type deployment_license_request: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DeploymentLicenseResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.DeploymentLicenseResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def create(
self, deployment_license_request: Union[_models.DeploymentLicenseRequest, IO], **kwargs: Any
) -> _models.DeploymentLicenseResponse:
"""Creates a license that can be used to deploy an Azure Stack device.
:param deployment_license_request: Request body for creating a deployment license. Is either a
model type or a IO type. Required.
:type deployment_license_request: ~azure.mgmt.azurestack.models.DeploymentLicenseRequest or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DeploymentLicenseResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.DeploymentLicenseResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DeploymentLicenseResponse] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(deployment_license_request, (IO, bytes)):
_content = deployment_license_request
else:
_json = self._serialize.body(deployment_license_request, "DeploymentLicenseRequest")
request = build_create_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("DeploymentLicenseResponse", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/generateDeploymentLicense"
}
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/operations/_deployment_license_operations.py
|
_deployment_license_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_create_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/generateDeploymentLicense"
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
class DeploymentLicenseOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.AzureStackManagementClient`'s
:attr:`deployment_license` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@overload
def create(
self,
deployment_license_request: _models.DeploymentLicenseRequest,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.DeploymentLicenseResponse:
"""Creates a license that can be used to deploy an Azure Stack device.
:param deployment_license_request: Request body for creating a deployment license. Required.
:type deployment_license_request: ~azure.mgmt.azurestack.models.DeploymentLicenseRequest
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DeploymentLicenseResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.DeploymentLicenseResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def create(
self, deployment_license_request: IO, *, content_type: str = "application/json", **kwargs: Any
) -> _models.DeploymentLicenseResponse:
"""Creates a license that can be used to deploy an Azure Stack device.
:param deployment_license_request: Request body for creating a deployment license. Required.
:type deployment_license_request: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DeploymentLicenseResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.DeploymentLicenseResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def create(
self, deployment_license_request: Union[_models.DeploymentLicenseRequest, IO], **kwargs: Any
) -> _models.DeploymentLicenseResponse:
"""Creates a license that can be used to deploy an Azure Stack device.
:param deployment_license_request: Request body for creating a deployment license. Is either a
model type or a IO type. Required.
:type deployment_license_request: ~azure.mgmt.azurestack.models.DeploymentLicenseRequest or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DeploymentLicenseResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.DeploymentLicenseResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DeploymentLicenseResponse] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(deployment_license_request, (IO, bytes)):
_content = deployment_license_request
else:
_json = self._serialize.body(deployment_license_request, "DeploymentLicenseRequest")
request = build_create_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("DeploymentLicenseResponse", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/generateDeploymentLicense"
}
| 0.661595 | 0.079496 |
import sys
from typing import Any, Callable, Dict, Optional, TypeVar
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/providers/Microsoft.AzureStack/cloudManifestFiles")
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
verification_version: str, *, version_creation_date: Optional[str] = None, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/providers/Microsoft.AzureStack/cloudManifestFiles/{verificationVersion}")
path_format_arguments = {
"verificationVersion": _SERIALIZER.url("verification_version", verification_version, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
if version_creation_date is not None:
_params["versionCreationDate"] = _SERIALIZER.query("version_creation_date", version_creation_date, "str")
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class CloudManifestFileOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.AzureStackManagementClient`'s
:attr:`cloud_manifest_file` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> _models.CloudManifestFileResponse:
"""Returns a cloud specific manifest JSON file with latest version.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CloudManifestFileResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CloudManifestFileResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CloudManifestFileResponse] = kwargs.pop("cls", None)
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CloudManifestFileResponse", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list.metadata = {"url": "/providers/Microsoft.AzureStack/cloudManifestFiles"}
@distributed_trace
def get(
self, verification_version: str, version_creation_date: Optional[str] = None, **kwargs: Any
) -> _models.CloudManifestFileResponse:
"""Returns a cloud specific manifest JSON file.
:param verification_version: Signing verification key version. Required.
:type verification_version: str
:param version_creation_date: Signing verification key version creation date. Default value is
None.
:type version_creation_date: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CloudManifestFileResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CloudManifestFileResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CloudManifestFileResponse] = kwargs.pop("cls", None)
request = build_get_request(
verification_version=verification_version,
version_creation_date=version_creation_date,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CloudManifestFileResponse", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {"url": "/providers/Microsoft.AzureStack/cloudManifestFiles/{verificationVersion}"}
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/operations/_cloud_manifest_file_operations.py
|
_cloud_manifest_file_operations.py
|
import sys
from typing import Any, Callable, Dict, Optional, TypeVar
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/providers/Microsoft.AzureStack/cloudManifestFiles")
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
verification_version: str, *, version_creation_date: Optional[str] = None, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/providers/Microsoft.AzureStack/cloudManifestFiles/{verificationVersion}")
path_format_arguments = {
"verificationVersion": _SERIALIZER.url("verification_version", verification_version, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
if version_creation_date is not None:
_params["versionCreationDate"] = _SERIALIZER.query("version_creation_date", version_creation_date, "str")
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class CloudManifestFileOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.AzureStackManagementClient`'s
:attr:`cloud_manifest_file` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> _models.CloudManifestFileResponse:
"""Returns a cloud specific manifest JSON file with latest version.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CloudManifestFileResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CloudManifestFileResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CloudManifestFileResponse] = kwargs.pop("cls", None)
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CloudManifestFileResponse", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list.metadata = {"url": "/providers/Microsoft.AzureStack/cloudManifestFiles"}
@distributed_trace
def get(
self, verification_version: str, version_creation_date: Optional[str] = None, **kwargs: Any
) -> _models.CloudManifestFileResponse:
"""Returns a cloud specific manifest JSON file.
:param verification_version: Signing verification key version. Required.
:type verification_version: str
:param version_creation_date: Signing verification key version creation date. Default value is
None.
:type version_creation_date: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CloudManifestFileResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CloudManifestFileResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CloudManifestFileResponse] = kwargs.pop("cls", None)
request = build_get_request(
verification_version=verification_version,
version_creation_date=version_creation_date,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CloudManifestFileResponse", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {"url": "/providers/Microsoft.AzureStack/cloudManifestFiles/{verificationVersion}"}
| 0.675872 | 0.067516 |
import sys
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/providers/Microsoft.AzureStack/operations")
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.AzureStackManagementClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> Iterable["_models.Operation"]:
"""Returns the list of supported REST operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Operation or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestack.models.Operation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.OperationList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("OperationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {"url": "/providers/Microsoft.AzureStack/operations"}
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/operations/_operations.py
|
_operations.py
|
import sys
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01"))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/providers/Microsoft.AzureStack/operations")
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.AzureStackManagementClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> Iterable["_models.Operation"]:
"""Returns the list of supported REST operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Operation or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestack.models.Operation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.OperationList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("OperationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {"url": "/providers/Microsoft.AzureStack/operations"}
| 0.634996 | 0.076373 |
from copy import deepcopy
from typing import Any, Awaitable, TYPE_CHECKING
from azure.core.rest import AsyncHttpResponse, HttpRequest
from azure.mgmt.core import AsyncARMPipelineClient
from .. import models as _models
from .._serialization import Deserializer, Serializer
from ._configuration import AzureStackManagementClientConfiguration
from .operations import (
CloudManifestFileOperations,
CustomerSubscriptionsOperations,
DeploymentLicenseOperations,
Operations,
ProductsOperations,
RegistrationsOperations,
)
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class AzureStackManagementClient: # pylint: disable=client-accepts-api-version-keyword
"""Azure Stack.
:ivar operations: Operations operations
:vartype operations: azure.mgmt.azurestack.aio.operations.Operations
:ivar cloud_manifest_file: CloudManifestFileOperations operations
:vartype cloud_manifest_file: azure.mgmt.azurestack.aio.operations.CloudManifestFileOperations
:ivar deployment_license: DeploymentLicenseOperations operations
:vartype deployment_license: azure.mgmt.azurestack.aio.operations.DeploymentLicenseOperations
:ivar customer_subscriptions: CustomerSubscriptionsOperations operations
:vartype customer_subscriptions:
azure.mgmt.azurestack.aio.operations.CustomerSubscriptionsOperations
:ivar products: ProductsOperations operations
:vartype products: azure.mgmt.azurestack.aio.operations.ProductsOperations
:ivar registrations: RegistrationsOperations operations
:vartype registrations: azure.mgmt.azurestack.aio.operations.RegistrationsOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: Subscription credentials that uniquely identify Microsoft Azure
subscription. The subscription ID forms part of the URI for every service call. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = AzureStackManagementClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.cloud_manifest_file = CloudManifestFileOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.deployment_license = DeploymentLicenseOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.customer_subscriptions = CustomerSubscriptionsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.products = ProductsOperations(self._client, self._config, self._serialize, self._deserialize)
self.registrations = RegistrationsOperations(self._client, self._config, self._serialize, self._deserialize)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client._send_request(request)
<AsyncHttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.AsyncHttpResponse
"""
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()
async def __aenter__(self) -> "AzureStackManagementClient":
await self._client.__aenter__()
return self
async def __aexit__(self, *exc_details) -> None:
await self._client.__aexit__(*exc_details)
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/aio/_azure_stack_management_client.py
|
_azure_stack_management_client.py
|
from copy import deepcopy
from typing import Any, Awaitable, TYPE_CHECKING
from azure.core.rest import AsyncHttpResponse, HttpRequest
from azure.mgmt.core import AsyncARMPipelineClient
from .. import models as _models
from .._serialization import Deserializer, Serializer
from ._configuration import AzureStackManagementClientConfiguration
from .operations import (
CloudManifestFileOperations,
CustomerSubscriptionsOperations,
DeploymentLicenseOperations,
Operations,
ProductsOperations,
RegistrationsOperations,
)
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class AzureStackManagementClient: # pylint: disable=client-accepts-api-version-keyword
"""Azure Stack.
:ivar operations: Operations operations
:vartype operations: azure.mgmt.azurestack.aio.operations.Operations
:ivar cloud_manifest_file: CloudManifestFileOperations operations
:vartype cloud_manifest_file: azure.mgmt.azurestack.aio.operations.CloudManifestFileOperations
:ivar deployment_license: DeploymentLicenseOperations operations
:vartype deployment_license: azure.mgmt.azurestack.aio.operations.DeploymentLicenseOperations
:ivar customer_subscriptions: CustomerSubscriptionsOperations operations
:vartype customer_subscriptions:
azure.mgmt.azurestack.aio.operations.CustomerSubscriptionsOperations
:ivar products: ProductsOperations operations
:vartype products: azure.mgmt.azurestack.aio.operations.ProductsOperations
:ivar registrations: RegistrationsOperations operations
:vartype registrations: azure.mgmt.azurestack.aio.operations.RegistrationsOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: Subscription credentials that uniquely identify Microsoft Azure
subscription. The subscription ID forms part of the URI for every service call. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = AzureStackManagementClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.cloud_manifest_file = CloudManifestFileOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.deployment_license = DeploymentLicenseOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.customer_subscriptions = CustomerSubscriptionsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.products = ProductsOperations(self._client, self._config, self._serialize, self._deserialize)
self.registrations = RegistrationsOperations(self._client, self._config, self._serialize, self._deserialize)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client._send_request(request)
<AsyncHttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.AsyncHttpResponse
"""
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()
async def __aenter__(self) -> "AzureStackManagementClient":
await self._client.__aenter__()
return self
async def __aexit__(self, *exc_details) -> None:
await self._client.__aexit__(*exc_details)
| 0.814385 | 0.101634 |
import sys
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, AsyncARMChallengeAuthenticationPolicy
from .._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class AzureStackManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureStackManagementClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: Subscription credentials that uniquely identify Microsoft Azure
subscription. The subscription ID forms part of the URI for every service call. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(AzureStackManagementClientConfiguration, self).__init__(**kwargs)
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", "2022-06-01")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-azurestack/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/aio/_configuration.py
|
_configuration.py
|
import sys
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, AsyncARMChallengeAuthenticationPolicy
from .._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class AzureStackManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureStackManagementClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: Subscription credentials that uniquely identify Microsoft Azure
subscription. The subscription ID forms part of the URI for every service call. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2022-06-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(AzureStackManagementClientConfiguration, self).__init__(**kwargs)
api_version: Literal["2022-06-01"] = kwargs.pop("api_version", "2022-06-01")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-azurestack/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
| 0.560734 | 0.078536 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._products_operations import (
build_get_product_request,
build_get_products_request,
build_get_request,
build_list_details_request,
build_list_products_request,
build_list_request,
build_upload_log_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class ProductsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.aio.AzureStackManagementClient`'s
:attr:`products` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, resource_group: str, registration_name: str, **kwargs: Any) -> AsyncIterable["_models.Product"]:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Product or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestack.models.Product]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ProductList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ProductList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products"
}
@distributed_trace_async
async def get(
self, resource_group: str, registration_name: str, product_name: str, **kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Product] = kwargs.pop("cls", None)
request = build_get_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Product", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}"
}
@distributed_trace_async
async def list_details(
self, resource_group: str, registration_name: str, product_name: str, **kwargs: Any
) -> _models.ExtendedProduct:
"""Returns the extended properties of a product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ExtendedProduct or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ExtendedProduct
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ExtendedProduct] = kwargs.pop("cls", None)
request = build_list_details_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_details.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ExtendedProduct", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list_details.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listDetails"
}
@overload
async def list_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[_models.DeviceConfiguration] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def list_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def list_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[Union[_models.DeviceConfiguration, IO]] = None,
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Is either a model type or a IO type. Default
value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ProductList] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(device_configuration, (IO, bytes)):
_content = device_configuration
else:
if device_configuration is not None:
_json = self._serialize.body(device_configuration, "DeviceConfiguration")
else:
_json = None
request = build_list_products_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.list_products.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ProductList", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list_products.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listProducts"
}
@overload
async def get_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[_models.DeviceConfiguration] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def get_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def get_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[Union[_models.DeviceConfiguration, IO]] = None,
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Is either a model type or a IO type. Default
value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ProductList] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(device_configuration, (IO, bytes)):
_content = device_configuration
else:
if device_configuration is not None:
_json = self._serialize.body(device_configuration, "DeviceConfiguration")
else:
_json = None
request = build_get_products_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.get_products.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ProductList", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_products.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProducts"
}
@overload
async def get_product(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[_models.DeviceConfiguration] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def get_product(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def get_product(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[Union[_models.DeviceConfiguration, IO]] = None,
**kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Is either a model type or a IO type. Default
value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Product] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(device_configuration, (IO, bytes)):
_content = device_configuration
else:
if device_configuration is not None:
_json = self._serialize.body(device_configuration, "DeviceConfiguration")
else:
_json = None
request = build_get_product_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.get_product.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Product", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_product.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProduct"
}
@overload
async def upload_log(
self,
resource_group: str,
registration_name: str,
product_name: str,
marketplace_product_log_update: Optional[_models.MarketplaceProductLogUpdate] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductLog:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param marketplace_product_log_update: Update details for product log. Default value is None.
:type marketplace_product_log_update: ~azure.mgmt.azurestack.models.MarketplaceProductLogUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductLog or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductLog
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def upload_log(
self,
resource_group: str,
registration_name: str,
product_name: str,
marketplace_product_log_update: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductLog:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param marketplace_product_log_update: Update details for product log. Default value is None.
:type marketplace_product_log_update: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductLog or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductLog
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def upload_log(
self,
resource_group: str,
registration_name: str,
product_name: str,
marketplace_product_log_update: Optional[Union[_models.MarketplaceProductLogUpdate, IO]] = None,
**kwargs: Any
) -> _models.ProductLog:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param marketplace_product_log_update: Update details for product log. Is either a model type
or a IO type. Default value is None.
:type marketplace_product_log_update: ~azure.mgmt.azurestack.models.MarketplaceProductLogUpdate
or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductLog or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductLog
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ProductLog] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(marketplace_product_log_update, (IO, bytes)):
_content = marketplace_product_log_update
else:
if marketplace_product_log_update is not None:
_json = self._serialize.body(marketplace_product_log_update, "MarketplaceProductLogUpdate")
else:
_json = None
request = build_upload_log_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.upload_log.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ProductLog", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
upload_log.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/uploadProductLog"
}
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/aio/operations/_products_operations.py
|
_products_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._products_operations import (
build_get_product_request,
build_get_products_request,
build_get_request,
build_list_details_request,
build_list_products_request,
build_list_request,
build_upload_log_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class ProductsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.aio.AzureStackManagementClient`'s
:attr:`products` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, resource_group: str, registration_name: str, **kwargs: Any) -> AsyncIterable["_models.Product"]:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Product or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestack.models.Product]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ProductList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ProductList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products"
}
@distributed_trace_async
async def get(
self, resource_group: str, registration_name: str, product_name: str, **kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Product] = kwargs.pop("cls", None)
request = build_get_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Product", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}"
}
@distributed_trace_async
async def list_details(
self, resource_group: str, registration_name: str, product_name: str, **kwargs: Any
) -> _models.ExtendedProduct:
"""Returns the extended properties of a product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ExtendedProduct or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ExtendedProduct
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ExtendedProduct] = kwargs.pop("cls", None)
request = build_list_details_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_details.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ExtendedProduct", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list_details.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listDetails"
}
@overload
async def list_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[_models.DeviceConfiguration] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def list_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def list_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[Union[_models.DeviceConfiguration, IO]] = None,
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Is either a model type or a IO type. Default
value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ProductList] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(device_configuration, (IO, bytes)):
_content = device_configuration
else:
if device_configuration is not None:
_json = self._serialize.body(device_configuration, "DeviceConfiguration")
else:
_json = None
request = build_list_products_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.list_products.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ProductList", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list_products.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listProducts"
}
@overload
async def get_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[_models.DeviceConfiguration] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def get_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def get_products(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[Union[_models.DeviceConfiguration, IO]] = None,
**kwargs: Any
) -> _models.ProductList:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Is either a model type or a IO type. Default
value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductList or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductList
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ProductList] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(device_configuration, (IO, bytes)):
_content = device_configuration
else:
if device_configuration is not None:
_json = self._serialize.body(device_configuration, "DeviceConfiguration")
else:
_json = None
request = build_get_products_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.get_products.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ProductList", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_products.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProducts"
}
@overload
async def get_product(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[_models.DeviceConfiguration] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def get_product(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Default value is None.
:type device_configuration: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def get_product(
self,
resource_group: str,
registration_name: str,
product_name: str,
device_configuration: Optional[Union[_models.DeviceConfiguration, IO]] = None,
**kwargs: Any
) -> _models.Product:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param device_configuration: Device configuration. Is either a model type or a IO type. Default
value is None.
:type device_configuration: ~azure.mgmt.azurestack.models.DeviceConfiguration or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Product or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Product
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Product] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(device_configuration, (IO, bytes)):
_content = device_configuration
else:
if device_configuration is not None:
_json = self._serialize.body(device_configuration, "DeviceConfiguration")
else:
_json = None
request = build_get_product_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.get_product.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Product", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_product.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProduct"
}
@overload
async def upload_log(
self,
resource_group: str,
registration_name: str,
product_name: str,
marketplace_product_log_update: Optional[_models.MarketplaceProductLogUpdate] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductLog:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param marketplace_product_log_update: Update details for product log. Default value is None.
:type marketplace_product_log_update: ~azure.mgmt.azurestack.models.MarketplaceProductLogUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductLog or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductLog
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def upload_log(
self,
resource_group: str,
registration_name: str,
product_name: str,
marketplace_product_log_update: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ProductLog:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param marketplace_product_log_update: Update details for product log. Default value is None.
:type marketplace_product_log_update: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductLog or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductLog
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def upload_log(
self,
resource_group: str,
registration_name: str,
product_name: str,
marketplace_product_log_update: Optional[Union[_models.MarketplaceProductLogUpdate, IO]] = None,
**kwargs: Any
) -> _models.ProductLog:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param product_name: Name of the product. Required.
:type product_name: str
:param marketplace_product_log_update: Update details for product log. Is either a model type
or a IO type. Default value is None.
:type marketplace_product_log_update: ~azure.mgmt.azurestack.models.MarketplaceProductLogUpdate
or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ProductLog or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ProductLog
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ProductLog] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(marketplace_product_log_update, (IO, bytes)):
_content = marketplace_product_log_update
else:
if marketplace_product_log_update is not None:
_json = self._serialize.body(marketplace_product_log_update, "MarketplaceProductLogUpdate")
else:
_json = None
request = build_upload_log_request(
resource_group=resource_group,
registration_name=registration_name,
product_name=product_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.upload_log.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ProductLog", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
upload_log.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/uploadProductLog"
}
| 0.673621 | 0.074265 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._customer_subscriptions_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class CustomerSubscriptionsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.aio.AzureStackManagementClient`'s
:attr:`customer_subscriptions` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(
self, resource_group: str, registration_name: str, **kwargs: Any
) -> AsyncIterable["_models.CustomerSubscription"]:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either CustomerSubscription or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestack.models.CustomerSubscription]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CustomerSubscriptionList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("CustomerSubscriptionList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions"
}
@distributed_trace_async
async def get(
self, resource_group: str, registration_name: str, customer_subscription_name: str, **kwargs: Any
) -> _models.CustomerSubscription:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CustomerSubscription] = kwargs.pop("cls", None)
request = build_get_request(
resource_group=resource_group,
registration_name=registration_name,
customer_subscription_name=customer_subscription_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CustomerSubscription", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group: str, registration_name: str, customer_subscription_name: str, **kwargs: Any
) -> None:
"""Deletes a customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group=resource_group,
registration_name=registration_name,
customer_subscription_name=customer_subscription_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}"
}
@overload
async def create(
self,
resource_group: str,
registration_name: str,
customer_subscription_name: str,
customer_creation_parameters: _models.CustomerSubscription,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.CustomerSubscription:
"""Creates a new customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:param customer_creation_parameters: Parameters use to create a customer subscription.
Required.
:type customer_creation_parameters: ~azure.mgmt.azurestack.models.CustomerSubscription
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def create(
self,
resource_group: str,
registration_name: str,
customer_subscription_name: str,
customer_creation_parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.CustomerSubscription:
"""Creates a new customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:param customer_creation_parameters: Parameters use to create a customer subscription.
Required.
:type customer_creation_parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def create(
self,
resource_group: str,
registration_name: str,
customer_subscription_name: str,
customer_creation_parameters: Union[_models.CustomerSubscription, IO],
**kwargs: Any
) -> _models.CustomerSubscription:
"""Creates a new customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:param customer_creation_parameters: Parameters use to create a customer subscription. Is
either a model type or a IO type. Required.
:type customer_creation_parameters: ~azure.mgmt.azurestack.models.CustomerSubscription or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.CustomerSubscription] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(customer_creation_parameters, (IO, bytes)):
_content = customer_creation_parameters
else:
_json = self._serialize.body(customer_creation_parameters, "CustomerSubscription")
request = build_create_request(
resource_group=resource_group,
registration_name=registration_name,
customer_subscription_name=customer_subscription_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CustomerSubscription", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}"
}
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/aio/operations/_customer_subscriptions_operations.py
|
_customer_subscriptions_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._customer_subscriptions_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class CustomerSubscriptionsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.aio.AzureStackManagementClient`'s
:attr:`customer_subscriptions` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(
self, resource_group: str, registration_name: str, **kwargs: Any
) -> AsyncIterable["_models.CustomerSubscription"]:
"""Returns a list of products.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either CustomerSubscription or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestack.models.CustomerSubscription]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CustomerSubscriptionList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("CustomerSubscriptionList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions"
}
@distributed_trace_async
async def get(
self, resource_group: str, registration_name: str, customer_subscription_name: str, **kwargs: Any
) -> _models.CustomerSubscription:
"""Returns the specified product.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CustomerSubscription] = kwargs.pop("cls", None)
request = build_get_request(
resource_group=resource_group,
registration_name=registration_name,
customer_subscription_name=customer_subscription_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CustomerSubscription", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group: str, registration_name: str, customer_subscription_name: str, **kwargs: Any
) -> None:
"""Deletes a customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group=resource_group,
registration_name=registration_name,
customer_subscription_name=customer_subscription_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}"
}
@overload
async def create(
self,
resource_group: str,
registration_name: str,
customer_subscription_name: str,
customer_creation_parameters: _models.CustomerSubscription,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.CustomerSubscription:
"""Creates a new customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:param customer_creation_parameters: Parameters use to create a customer subscription.
Required.
:type customer_creation_parameters: ~azure.mgmt.azurestack.models.CustomerSubscription
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def create(
self,
resource_group: str,
registration_name: str,
customer_subscription_name: str,
customer_creation_parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.CustomerSubscription:
"""Creates a new customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:param customer_creation_parameters: Parameters use to create a customer subscription.
Required.
:type customer_creation_parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def create(
self,
resource_group: str,
registration_name: str,
customer_subscription_name: str,
customer_creation_parameters: Union[_models.CustomerSubscription, IO],
**kwargs: Any
) -> _models.CustomerSubscription:
"""Creates a new customer subscription under a registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param customer_subscription_name: Name of the product. Required.
:type customer_subscription_name: str
:param customer_creation_parameters: Parameters use to create a customer subscription. Is
either a model type or a IO type. Required.
:type customer_creation_parameters: ~azure.mgmt.azurestack.models.CustomerSubscription or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CustomerSubscription or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CustomerSubscription
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.CustomerSubscription] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(customer_creation_parameters, (IO, bytes)):
_content = customer_creation_parameters
else:
_json = self._serialize.body(customer_creation_parameters, "CustomerSubscription")
request = build_create_request(
resource_group=resource_group,
registration_name=registration_name,
customer_subscription_name=customer_subscription_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CustomerSubscription", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}"
}
| 0.71123 | 0.082771 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._registrations_operations import (
build_create_or_update_request,
build_delete_request,
build_enable_remote_management_request,
build_get_activation_key_request,
build_get_request,
build_list_by_subscription_request,
build_list_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class RegistrationsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.aio.AzureStackManagementClient`'s
:attr:`registrations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, resource_group: str, **kwargs: Any) -> AsyncIterable["_models.Registration"]:
"""Returns a list of all registrations.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Registration or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestack.models.Registration]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.RegistrationList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group=resource_group,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("RegistrationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Registration"]:
"""Returns a list of all registrations under current subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Registration or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestack.models.Registration]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.RegistrationList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("RegistrationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/registrations"
}
@distributed_trace_async
async def get(self, resource_group: str, registration_name: str, **kwargs: Any) -> _models.Registration:
"""Returns the properties of an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Registration] = kwargs.pop("cls", None)
request = build_get_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Registration", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group: str, registration_name: str, **kwargs: Any
) -> None:
"""Delete the requested Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@overload
async def create_or_update(
self,
resource_group: str,
registration_name: str,
token: _models.RegistrationParameter,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Create or update an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def create_or_update(
self,
resource_group: str,
registration_name: str,
token: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Create or update an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def create_or_update(
self,
resource_group: str,
registration_name: str,
token: Union[_models.RegistrationParameter, IO],
**kwargs: Any
) -> _models.Registration:
"""Create or update an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Is either a model type or a IO type. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Registration] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(token, (IO, bytes)):
_content = token
else:
_json = self._serialize.body(token, "RegistrationParameter")
request = build_create_or_update_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create_or_update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Registration", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Registration", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@overload
async def update(
self,
resource_group: str,
registration_name: str,
token: _models.RegistrationParameter,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Patch an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group: str,
registration_name: str,
token: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Patch an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group: str,
registration_name: str,
token: Union[_models.RegistrationParameter, IO],
**kwargs: Any
) -> _models.Registration:
"""Patch an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Is either a model type or a IO type. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Registration] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(token, (IO, bytes)):
_content = token
else:
_json = self._serialize.body(token, "RegistrationParameter")
request = build_update_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Registration", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@distributed_trace_async
async def get_activation_key(
self, resource_group: str, registration_name: str, **kwargs: Any
) -> _models.ActivationKeyResult:
"""Returns Azure Stack Activation Key.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ActivationKeyResult or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ActivationKeyResult
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ActivationKeyResult] = kwargs.pop("cls", None)
request = build_get_activation_key_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get_activation_key.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ActivationKeyResult", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_activation_key.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/getactivationkey"
}
@distributed_trace_async
async def enable_remote_management( # pylint: disable=inconsistent-return-statements
self, resource_group: str, registration_name: str, **kwargs: Any
) -> None:
"""Enables remote management for device under the Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = kwargs.pop("params", {}) or {}
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_enable_remote_management_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
template_url=self.enable_remote_management.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
enable_remote_management.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/enableRemoteManagement"
}
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/aio/operations/_registrations_operations.py
|
_registrations_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._registrations_operations import (
build_create_or_update_request,
build_delete_request,
build_enable_remote_management_request,
build_get_activation_key_request,
build_get_request,
build_list_by_subscription_request,
build_list_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class RegistrationsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.aio.AzureStackManagementClient`'s
:attr:`registrations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, resource_group: str, **kwargs: Any) -> AsyncIterable["_models.Registration"]:
"""Returns a list of all registrations.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Registration or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestack.models.Registration]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.RegistrationList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
resource_group=resource_group,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("RegistrationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Registration"]:
"""Returns a list of all registrations under current subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Registration or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestack.models.Registration]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.RegistrationList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("RegistrationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/registrations"
}
@distributed_trace_async
async def get(self, resource_group: str, registration_name: str, **kwargs: Any) -> _models.Registration:
"""Returns the properties of an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Registration] = kwargs.pop("cls", None)
request = build_get_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Registration", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group: str, registration_name: str, **kwargs: Any
) -> None:
"""Delete the requested Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@overload
async def create_or_update(
self,
resource_group: str,
registration_name: str,
token: _models.RegistrationParameter,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Create or update an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def create_or_update(
self,
resource_group: str,
registration_name: str,
token: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Create or update an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def create_or_update(
self,
resource_group: str,
registration_name: str,
token: Union[_models.RegistrationParameter, IO],
**kwargs: Any
) -> _models.Registration:
"""Create or update an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Is either a model type or a IO type. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Registration] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(token, (IO, bytes)):
_content = token
else:
_json = self._serialize.body(token, "RegistrationParameter")
request = build_create_or_update_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create_or_update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Registration", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Registration", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@overload
async def update(
self,
resource_group: str,
registration_name: str,
token: _models.RegistrationParameter,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Patch an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group: str,
registration_name: str,
token: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Registration:
"""Patch an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Required.
:type token: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group: str,
registration_name: str,
token: Union[_models.RegistrationParameter, IO],
**kwargs: Any
) -> _models.Registration:
"""Patch an Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:param token: Registration token. Is either a model type or a IO type. Required.
:type token: ~azure.mgmt.azurestack.models.RegistrationParameter or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Registration or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.Registration
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Registration] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(token, (IO, bytes)):
_content = token
else:
_json = self._serialize.body(token, "RegistrationParameter")
request = build_update_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Registration", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}"
}
@distributed_trace_async
async def get_activation_key(
self, resource_group: str, registration_name: str, **kwargs: Any
) -> _models.ActivationKeyResult:
"""Returns Azure Stack Activation Key.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ActivationKeyResult or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.ActivationKeyResult
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ActivationKeyResult] = kwargs.pop("cls", None)
request = build_get_activation_key_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get_activation_key.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ActivationKeyResult", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get_activation_key.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/getactivationkey"
}
@distributed_trace_async
async def enable_remote_management( # pylint: disable=inconsistent-return-statements
self, resource_group: str, registration_name: str, **kwargs: Any
) -> None:
"""Enables remote management for device under the Azure Stack registration.
:param resource_group: Name of the resource group. Required.
:type resource_group: str
:param registration_name: Name of the Azure Stack registration. Required.
:type registration_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = kwargs.pop("params", {}) or {}
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_enable_remote_management_request(
resource_group=resource_group,
registration_name=registration_name,
subscription_id=self._config.subscription_id,
template_url=self.enable_remote_management.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
enable_remote_management.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/enableRemoteManagement"
}
| 0.691185 | 0.07703 |
import sys
from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._deployment_license_operations import build_create_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class DeploymentLicenseOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.aio.AzureStackManagementClient`'s
:attr:`deployment_license` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@overload
async def create(
self,
deployment_license_request: _models.DeploymentLicenseRequest,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.DeploymentLicenseResponse:
"""Creates a license that can be used to deploy an Azure Stack device.
:param deployment_license_request: Request body for creating a deployment license. Required.
:type deployment_license_request: ~azure.mgmt.azurestack.models.DeploymentLicenseRequest
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DeploymentLicenseResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.DeploymentLicenseResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def create(
self, deployment_license_request: IO, *, content_type: str = "application/json", **kwargs: Any
) -> _models.DeploymentLicenseResponse:
"""Creates a license that can be used to deploy an Azure Stack device.
:param deployment_license_request: Request body for creating a deployment license. Required.
:type deployment_license_request: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DeploymentLicenseResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.DeploymentLicenseResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def create(
self, deployment_license_request: Union[_models.DeploymentLicenseRequest, IO], **kwargs: Any
) -> _models.DeploymentLicenseResponse:
"""Creates a license that can be used to deploy an Azure Stack device.
:param deployment_license_request: Request body for creating a deployment license. Is either a
model type or a IO type. Required.
:type deployment_license_request: ~azure.mgmt.azurestack.models.DeploymentLicenseRequest or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DeploymentLicenseResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.DeploymentLicenseResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DeploymentLicenseResponse] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(deployment_license_request, (IO, bytes)):
_content = deployment_license_request
else:
_json = self._serialize.body(deployment_license_request, "DeploymentLicenseRequest")
request = build_create_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("DeploymentLicenseResponse", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/generateDeploymentLicense"
}
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/aio/operations/_deployment_license_operations.py
|
_deployment_license_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._deployment_license_operations import build_create_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class DeploymentLicenseOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.aio.AzureStackManagementClient`'s
:attr:`deployment_license` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@overload
async def create(
self,
deployment_license_request: _models.DeploymentLicenseRequest,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.DeploymentLicenseResponse:
"""Creates a license that can be used to deploy an Azure Stack device.
:param deployment_license_request: Request body for creating a deployment license. Required.
:type deployment_license_request: ~azure.mgmt.azurestack.models.DeploymentLicenseRequest
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DeploymentLicenseResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.DeploymentLicenseResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def create(
self, deployment_license_request: IO, *, content_type: str = "application/json", **kwargs: Any
) -> _models.DeploymentLicenseResponse:
"""Creates a license that can be used to deploy an Azure Stack device.
:param deployment_license_request: Request body for creating a deployment license. Required.
:type deployment_license_request: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DeploymentLicenseResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.DeploymentLicenseResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def create(
self, deployment_license_request: Union[_models.DeploymentLicenseRequest, IO], **kwargs: Any
) -> _models.DeploymentLicenseResponse:
"""Creates a license that can be used to deploy an Azure Stack device.
:param deployment_license_request: Request body for creating a deployment license. Is either a
model type or a IO type. Required.
:type deployment_license_request: ~azure.mgmt.azurestack.models.DeploymentLicenseRequest or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: DeploymentLicenseResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.DeploymentLicenseResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.DeploymentLicenseResponse] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(deployment_license_request, (IO, bytes)):
_content = deployment_license_request
else:
_json = self._serialize.body(deployment_license_request, "DeploymentLicenseRequest")
request = build_create_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("DeploymentLicenseResponse", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/generateDeploymentLicense"
}
| 0.684053 | 0.093264 |
import sys
from typing import Any, Callable, Dict, Optional, TypeVar
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._cloud_manifest_file_operations import build_get_request, build_list_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class CloudManifestFileOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.aio.AzureStackManagementClient`'s
:attr:`cloud_manifest_file` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def list(self, **kwargs: Any) -> _models.CloudManifestFileResponse:
"""Returns a cloud specific manifest JSON file with latest version.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CloudManifestFileResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CloudManifestFileResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CloudManifestFileResponse] = kwargs.pop("cls", None)
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CloudManifestFileResponse", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list.metadata = {"url": "/providers/Microsoft.AzureStack/cloudManifestFiles"}
@distributed_trace_async
async def get(
self, verification_version: str, version_creation_date: Optional[str] = None, **kwargs: Any
) -> _models.CloudManifestFileResponse:
"""Returns a cloud specific manifest JSON file.
:param verification_version: Signing verification key version. Required.
:type verification_version: str
:param version_creation_date: Signing verification key version creation date. Default value is
None.
:type version_creation_date: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CloudManifestFileResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CloudManifestFileResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CloudManifestFileResponse] = kwargs.pop("cls", None)
request = build_get_request(
verification_version=verification_version,
version_creation_date=version_creation_date,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CloudManifestFileResponse", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {"url": "/providers/Microsoft.AzureStack/cloudManifestFiles/{verificationVersion}"}
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/aio/operations/_cloud_manifest_file_operations.py
|
_cloud_manifest_file_operations.py
|
import sys
from typing import Any, Callable, Dict, Optional, TypeVar
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._cloud_manifest_file_operations import build_get_request, build_list_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class CloudManifestFileOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.aio.AzureStackManagementClient`'s
:attr:`cloud_manifest_file` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def list(self, **kwargs: Any) -> _models.CloudManifestFileResponse:
"""Returns a cloud specific manifest JSON file with latest version.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CloudManifestFileResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CloudManifestFileResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CloudManifestFileResponse] = kwargs.pop("cls", None)
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CloudManifestFileResponse", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list.metadata = {"url": "/providers/Microsoft.AzureStack/cloudManifestFiles"}
@distributed_trace_async
async def get(
self, verification_version: str, version_creation_date: Optional[str] = None, **kwargs: Any
) -> _models.CloudManifestFileResponse:
"""Returns a cloud specific manifest JSON file.
:param verification_version: Signing verification key version. Required.
:type verification_version: str
:param version_creation_date: Signing verification key version creation date. Default value is
None.
:type version_creation_date: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: CloudManifestFileResponse or the result of cls(response)
:rtype: ~azure.mgmt.azurestack.models.CloudManifestFileResponse
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.CloudManifestFileResponse] = kwargs.pop("cls", None)
request = build_get_request(
verification_version=verification_version,
version_creation_date=version_creation_date,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("CloudManifestFileResponse", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {"url": "/providers/Microsoft.AzureStack/cloudManifestFiles/{verificationVersion}"}
| 0.663342 | 0.07658 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._operations import build_list_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.aio.AzureStackManagementClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]:
"""Returns the list of supported REST operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Operation or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestack.models.Operation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.OperationList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("OperationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {"url": "/providers/Microsoft.AzureStack/operations"}
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/aio/operations/_operations.py
|
_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._operations import build_list_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestack.aio.AzureStackManagementClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]:
"""Returns the list of supported REST operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Operation or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestack.models.Operation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2022-06-01"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.OperationList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("OperationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {"url": "/providers/Microsoft.AzureStack/operations"}
| 0.619011 | 0.086593 |
from typing import Dict, List, Optional, TYPE_CHECKING, Union
from .. import _serialization
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from .. import models as _models
class ActivationKeyResult(_serialization.Model):
"""The resource containing the Azure Stack activation key.
:ivar activation_key: Azure Stack activation key.
:vartype activation_key: str
"""
_attribute_map = {
"activation_key": {"key": "activationKey", "type": "str"},
}
def __init__(self, *, activation_key: Optional[str] = None, **kwargs):
"""
:keyword activation_key: Azure Stack activation key.
:paramtype activation_key: str
"""
super().__init__(**kwargs)
self.activation_key = activation_key
class CloudManifestFileDeploymentData(_serialization.Model):
"""Cloud specific manifest data for AzureStack deployment.
:ivar external_dsms_certificates: Dsms external certificates.
:vartype external_dsms_certificates: str
:ivar custom_cloud_verification_key: Signing verification public key.
:vartype custom_cloud_verification_key: str
:ivar custom_cloud_arm_endpoint: ARM endpoint.
:vartype custom_cloud_arm_endpoint: str
:ivar external_dsms_endpoint: Dsms endpoint.
:vartype external_dsms_endpoint: str
"""
_attribute_map = {
"external_dsms_certificates": {"key": "externalDsmsCertificates", "type": "str"},
"custom_cloud_verification_key": {"key": "customCloudVerificationKey", "type": "str"},
"custom_cloud_arm_endpoint": {"key": "customEnvironmentEndpoints.customCloudArmEndpoint", "type": "str"},
"external_dsms_endpoint": {"key": "customEnvironmentEndpoints.externalDsmsEndpoint", "type": "str"},
}
def __init__(
self,
*,
external_dsms_certificates: Optional[str] = None,
custom_cloud_verification_key: Optional[str] = None,
custom_cloud_arm_endpoint: Optional[str] = None,
external_dsms_endpoint: Optional[str] = None,
**kwargs
):
"""
:keyword external_dsms_certificates: Dsms external certificates.
:paramtype external_dsms_certificates: str
:keyword custom_cloud_verification_key: Signing verification public key.
:paramtype custom_cloud_verification_key: str
:keyword custom_cloud_arm_endpoint: ARM endpoint.
:paramtype custom_cloud_arm_endpoint: str
:keyword external_dsms_endpoint: Dsms endpoint.
:paramtype external_dsms_endpoint: str
"""
super().__init__(**kwargs)
self.external_dsms_certificates = external_dsms_certificates
self.custom_cloud_verification_key = custom_cloud_verification_key
self.custom_cloud_arm_endpoint = custom_cloud_arm_endpoint
self.external_dsms_endpoint = external_dsms_endpoint
class CloudManifestFileProperties(_serialization.Model):
"""Cloud specific manifest JSON properties.
:ivar deployment_data: Cloud specific manifest data.
:vartype deployment_data: ~azure.mgmt.azurestack.models.CloudManifestFileDeploymentData
:ivar signature: Signature of the cloud specific manifest data.
:vartype signature: str
"""
_attribute_map = {
"deployment_data": {"key": "deploymentData", "type": "CloudManifestFileDeploymentData"},
"signature": {"key": "signature", "type": "str"},
}
def __init__(
self,
*,
deployment_data: Optional["_models.CloudManifestFileDeploymentData"] = None,
signature: Optional[str] = None,
**kwargs
):
"""
:keyword deployment_data: Cloud specific manifest data.
:paramtype deployment_data: ~azure.mgmt.azurestack.models.CloudManifestFileDeploymentData
:keyword signature: Signature of the cloud specific manifest data.
:paramtype signature: str
"""
super().__init__(**kwargs)
self.deployment_data = deployment_data
self.signature = signature
class Resource(_serialization.Model):
"""Base resource object.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: ID of the resource.
:vartype id: str
:ivar name: Name of the resource.
:vartype name: str
:ivar type: Type of Resource.
:vartype type: str
:ivar etag: The entity tag used for optimistic concurrency when modifying the resource.
:vartype etag: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"etag": {"key": "etag", "type": "str"},
}
def __init__(self, *, etag: Optional[str] = None, **kwargs):
"""
:keyword etag: The entity tag used for optimistic concurrency when modifying the resource.
:paramtype etag: str
"""
super().__init__(**kwargs)
self.id = None
self.name = None
self.type = None
self.etag = etag
class CloudManifestFileResponse(Resource):
"""Cloud specific manifest GET response.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: ID of the resource.
:vartype id: str
:ivar name: Name of the resource.
:vartype name: str
:ivar type: Type of Resource.
:vartype type: str
:ivar etag: The entity tag used for optimistic concurrency when modifying the resource.
:vartype etag: str
:ivar properties: Cloud specific manifest data.
:vartype properties: ~azure.mgmt.azurestack.models.CloudManifestFileProperties
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"etag": {"key": "etag", "type": "str"},
"properties": {"key": "properties", "type": "CloudManifestFileProperties"},
}
def __init__(
self,
*,
etag: Optional[str] = None,
properties: Optional["_models.CloudManifestFileProperties"] = None,
**kwargs
):
"""
:keyword etag: The entity tag used for optimistic concurrency when modifying the resource.
:paramtype etag: str
:keyword properties: Cloud specific manifest data.
:paramtype properties: ~azure.mgmt.azurestack.models.CloudManifestFileProperties
"""
super().__init__(etag=etag, **kwargs)
self.properties = properties
class Compatibility(_serialization.Model):
"""Product compatibility.
:ivar is_compatible: Tells if product is compatible with current device.
:vartype is_compatible: bool
:ivar message: Short error message if any compatibility issues are found.
:vartype message: str
:ivar description: Full error message if any compatibility issues are found.
:vartype description: str
:ivar issues: List of all issues found.
:vartype issues: list[str or ~azure.mgmt.azurestack.models.CompatibilityIssue]
"""
_attribute_map = {
"is_compatible": {"key": "isCompatible", "type": "bool"},
"message": {"key": "message", "type": "str"},
"description": {"key": "description", "type": "str"},
"issues": {"key": "issues", "type": "[str]"},
}
def __init__(
self,
*,
is_compatible: Optional[bool] = None,
message: Optional[str] = None,
description: Optional[str] = None,
issues: Optional[List[Union[str, "_models.CompatibilityIssue"]]] = None,
**kwargs
):
"""
:keyword is_compatible: Tells if product is compatible with current device.
:paramtype is_compatible: bool
:keyword message: Short error message if any compatibility issues are found.
:paramtype message: str
:keyword description: Full error message if any compatibility issues are found.
:paramtype description: str
:keyword issues: List of all issues found.
:paramtype issues: list[str or ~azure.mgmt.azurestack.models.CompatibilityIssue]
"""
super().__init__(**kwargs)
self.is_compatible = is_compatible
self.message = message
self.description = description
self.issues = issues
class CustomerSubscription(Resource):
"""Customer subscription.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: ID of the resource.
:vartype id: str
:ivar name: Name of the resource.
:vartype name: str
:ivar type: Type of Resource.
:vartype type: str
:ivar etag: The entity tag used for optimistic concurrency when modifying the resource.
:vartype etag: str
:ivar tenant_id: Tenant Id.
:vartype tenant_id: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"etag": {"key": "etag", "type": "str"},
"tenant_id": {"key": "properties.tenantId", "type": "str"},
}
def __init__(self, *, etag: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs):
"""
:keyword etag: The entity tag used for optimistic concurrency when modifying the resource.
:paramtype etag: str
:keyword tenant_id: Tenant Id.
:paramtype tenant_id: str
"""
super().__init__(etag=etag, **kwargs)
self.tenant_id = tenant_id
class CustomerSubscriptionList(_serialization.Model):
"""Pageable list of customer subscriptions.
:ivar next_link: URI to the next page.
:vartype next_link: str
:ivar value: List of customer subscriptions.
:vartype value: list[~azure.mgmt.azurestack.models.CustomerSubscription]
"""
_attribute_map = {
"next_link": {"key": "nextLink", "type": "str"},
"value": {"key": "value", "type": "[CustomerSubscription]"},
}
def __init__(
self, *, next_link: Optional[str] = None, value: Optional[List["_models.CustomerSubscription"]] = None, **kwargs
):
"""
:keyword next_link: URI to the next page.
:paramtype next_link: str
:keyword value: List of customer subscriptions.
:paramtype value: list[~azure.mgmt.azurestack.models.CustomerSubscription]
"""
super().__init__(**kwargs)
self.next_link = next_link
self.value = value
class DataDiskImage(_serialization.Model):
"""Data disk image.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar lun: The LUN.
:vartype lun: int
:ivar source_blob_sas_uri: SAS key for source blob.
:vartype source_blob_sas_uri: str
"""
_validation = {
"lun": {"readonly": True},
"source_blob_sas_uri": {"readonly": True},
}
_attribute_map = {
"lun": {"key": "lun", "type": "int"},
"source_blob_sas_uri": {"key": "sourceBlobSasUri", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.lun = None
self.source_blob_sas_uri = None
class DeploymentLicenseRequest(_serialization.Model):
"""Request details for generating a deployment license.
:ivar verification_version: Signing verification public key version.
:vartype verification_version: str
"""
_attribute_map = {
"verification_version": {"key": "verificationVersion", "type": "str"},
}
def __init__(self, *, verification_version: Optional[str] = None, **kwargs):
"""
:keyword verification_version: Signing verification public key version.
:paramtype verification_version: str
"""
super().__init__(**kwargs)
self.verification_version = verification_version
class DeploymentLicenseResponse(_serialization.Model):
"""A license that can be used to deploy an Azure Stack device.
:ivar temporary_license_chain: A license chain that can be used to temporarily activate an
Azure Stack device.
:vartype temporary_license_chain: list[str]
:ivar signature: Signature of the license chain.
:vartype signature: str
"""
_attribute_map = {
"temporary_license_chain": {"key": "temporaryLicenseChain", "type": "[str]"},
"signature": {"key": "signature", "type": "str"},
}
def __init__(
self, *, temporary_license_chain: Optional[List[str]] = None, signature: Optional[str] = None, **kwargs
):
"""
:keyword temporary_license_chain: A license chain that can be used to temporarily activate an
Azure Stack device.
:paramtype temporary_license_chain: list[str]
:keyword signature: Signature of the license chain.
:paramtype signature: str
"""
super().__init__(**kwargs)
self.temporary_license_chain = temporary_license_chain
self.signature = signature
class DeviceConfiguration(_serialization.Model):
"""Device Configuration.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar device_version: Version of the device.
:vartype device_version: str
:ivar identity_system: Identity system of the device. Known values are: "AzureAD" and "ADFS".
:vartype identity_system: str or ~azure.mgmt.azurestack.models.Category
"""
_validation = {
"device_version": {"readonly": True},
"identity_system": {"readonly": True},
}
_attribute_map = {
"device_version": {"key": "deviceVersion", "type": "str"},
"identity_system": {"key": "identitySystem", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.device_version = None
self.identity_system = None
class Display(_serialization.Model):
"""Contains the localized display information for this particular operation or action.
:ivar provider: The localized, friendly version of the resource provider name.
:vartype provider: str
:ivar resource: The localized, friendly version of the resource type related to this action or
operation; the resource type should match the public documentation for the resource provider.
:vartype resource: str
:ivar operation: The localized, friendly name for the operation. Use the name as it will
displayed to the user.
:vartype operation: str
:ivar description: The localized, friendly description for the operation. The description will
be displayed to the user. It should be thorough and concise for used in both tooltips and
detailed views.
:vartype 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,
*,
provider: Optional[str] = None,
resource: Optional[str] = None,
operation: Optional[str] = None,
description: Optional[str] = None,
**kwargs
):
"""
:keyword provider: The localized, friendly version of the resource provider name.
:paramtype provider: str
:keyword resource: The localized, friendly version of the resource type related to this action
or operation; the resource type should match the public documentation for the resource
provider.
:paramtype resource: str
:keyword operation: The localized, friendly name for the operation. Use the name as it will
displayed to the user.
:paramtype operation: str
:keyword description: The localized, friendly description for the operation. The description
will be displayed to the user. It should be thorough and concise for used in both tooltips and
detailed views.
:paramtype description: str
"""
super().__init__(**kwargs)
self.provider = provider
self.resource = resource
self.operation = operation
self.description = description
class ErrorDetails(_serialization.Model):
"""The details of the error.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: Error code.
:vartype code: str
:ivar message: Error message indicating why the operation failed.
:vartype message: str
:ivar target: The target of the particular error.
:vartype target: str
"""
_validation = {
"code": {"readonly": True},
"message": {"readonly": True},
"target": {"readonly": True},
}
_attribute_map = {
"code": {"key": "code", "type": "str"},
"message": {"key": "message", "type": "str"},
"target": {"key": "target", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.code = None
self.message = None
self.target = None
class ErrorResponse(_serialization.Model):
"""Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message.
:ivar error: The details of the error.
:vartype error: ~azure.mgmt.azurestack.models.ErrorDetails
"""
_attribute_map = {
"error": {"key": "error", "type": "ErrorDetails"},
}
def __init__(self, *, error: Optional["_models.ErrorDetails"] = None, **kwargs):
"""
:keyword error: The details of the error.
:paramtype error: ~azure.mgmt.azurestack.models.ErrorDetails
"""
super().__init__(**kwargs)
self.error = error
class ExtendedProduct(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""Extended description about the product required for installing it into Azure Stack.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar gallery_package_blob_sas_uri: The URI to the .azpkg file that provides information
required for showing product in the gallery.
:vartype gallery_package_blob_sas_uri: str
:ivar product_kind: Specifies the kind of the product (virtualMachine or
virtualMachineExtension).
:vartype product_kind: str
:ivar compute_role: Specifies kind of compute role included in the package. Known values are:
"None", "IaaS", and "PaaS".
:vartype compute_role: str or ~azure.mgmt.azurestack.models.ComputeRole
:ivar is_system_extension: Specifies if product is a Virtual Machine Extension.
:vartype is_system_extension: bool
:ivar support_multiple_extensions: Indicates if specified product supports multiple extensions.
:vartype support_multiple_extensions: bool
:ivar version_properties_version: Specifies product version.
:vartype version_properties_version: str
:ivar vm_os_type: Specifies operating system used by the product. Known values are: "None",
"Windows", and "Linux".
:vartype vm_os_type: str or ~azure.mgmt.azurestack.models.OperatingSystem
:ivar vm_scale_set_enabled: Indicates if virtual machine Scale Set is enabled in the specified
product.
:vartype vm_scale_set_enabled: bool
:ivar uri: The URI.
:vartype uri: str
:ivar version: Specifies product version.
:vartype version: str
:ivar os_disk_image: OS disk image used by product.
:vartype os_disk_image: ~azure.mgmt.azurestack.models.OsDiskImage
:ivar data_disk_images: List of attached data disks.
:vartype data_disk_images: list[~azure.mgmt.azurestack.models.DataDiskImage]
"""
_validation = {
"gallery_package_blob_sas_uri": {"readonly": True},
"product_kind": {"readonly": True},
"compute_role": {"readonly": True},
"is_system_extension": {"readonly": True},
"support_multiple_extensions": {"readonly": True},
"version_properties_version": {"readonly": True},
"vm_os_type": {"readonly": True},
"vm_scale_set_enabled": {"readonly": True},
"uri": {"readonly": True},
"version": {"readonly": True},
"os_disk_image": {"readonly": True},
"data_disk_images": {"readonly": True},
}
_attribute_map = {
"gallery_package_blob_sas_uri": {"key": "galleryPackageBlobSasUri", "type": "str"},
"product_kind": {"key": "productKind", "type": "str"},
"compute_role": {"key": "properties.computeRole", "type": "str"},
"is_system_extension": {"key": "properties.isSystemExtension", "type": "bool"},
"support_multiple_extensions": {"key": "properties.supportMultipleExtensions", "type": "bool"},
"version_properties_version": {"key": "properties.version", "type": "str"},
"vm_os_type": {"key": "properties.vmOsType", "type": "str"},
"vm_scale_set_enabled": {"key": "properties.vmScaleSetEnabled", "type": "bool"},
"uri": {"key": "properties.sourceBlob.uri", "type": "str"},
"version": {"key": "properties.version", "type": "str"},
"os_disk_image": {"key": "properties.osDiskImage", "type": "OsDiskImage"},
"data_disk_images": {"key": "properties.dataDiskImages", "type": "[DataDiskImage]"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.gallery_package_blob_sas_uri = None
self.product_kind = None
self.compute_role = None
self.is_system_extension = None
self.support_multiple_extensions = None
self.version_properties_version = None
self.vm_os_type = None
self.vm_scale_set_enabled = None
self.uri = None
self.version = None
self.os_disk_image = None
self.data_disk_images = None
class VirtualMachineProductProperties(_serialization.Model):
"""Product information.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar version: Specifies product version.
:vartype version: str
:ivar os_disk_image: OS disk image used by product.
:vartype os_disk_image: ~azure.mgmt.azurestack.models.OsDiskImage
:ivar data_disk_images: List of attached data disks.
:vartype data_disk_images: list[~azure.mgmt.azurestack.models.DataDiskImage]
"""
_validation = {
"version": {"readonly": True},
"os_disk_image": {"readonly": True},
"data_disk_images": {"readonly": True},
}
_attribute_map = {
"version": {"key": "version", "type": "str"},
"os_disk_image": {"key": "osDiskImage", "type": "OsDiskImage"},
"data_disk_images": {"key": "dataDiskImages", "type": "[DataDiskImage]"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.version = None
self.os_disk_image = None
self.data_disk_images = None
class VirtualMachineExtensionProductProperties(_serialization.Model):
"""Product information.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar compute_role: Specifies kind of compute role included in the package. Known values are:
"None", "IaaS", and "PaaS".
:vartype compute_role: str or ~azure.mgmt.azurestack.models.ComputeRole
:ivar is_system_extension: Specifies if product is a Virtual Machine Extension.
:vartype is_system_extension: bool
:ivar support_multiple_extensions: Indicates if specified product supports multiple extensions.
:vartype support_multiple_extensions: bool
:ivar version: Specifies product version.
:vartype version: str
:ivar vm_os_type: Specifies operating system used by the product. Known values are: "None",
"Windows", and "Linux".
:vartype vm_os_type: str or ~azure.mgmt.azurestack.models.OperatingSystem
:ivar vm_scale_set_enabled: Indicates if virtual machine Scale Set is enabled in the specified
product.
:vartype vm_scale_set_enabled: bool
:ivar uri: The URI.
:vartype uri: str
"""
_validation = {
"compute_role": {"readonly": True},
"is_system_extension": {"readonly": True},
"support_multiple_extensions": {"readonly": True},
"version": {"readonly": True},
"vm_os_type": {"readonly": True},
"vm_scale_set_enabled": {"readonly": True},
"uri": {"readonly": True},
}
_attribute_map = {
"compute_role": {"key": "computeRole", "type": "str"},
"is_system_extension": {"key": "isSystemExtension", "type": "bool"},
"support_multiple_extensions": {"key": "supportMultipleExtensions", "type": "bool"},
"version": {"key": "version", "type": "str"},
"vm_os_type": {"key": "vmOsType", "type": "str"},
"vm_scale_set_enabled": {"key": "vmScaleSetEnabled", "type": "bool"},
"uri": {"key": "sourceBlob.uri", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.compute_role = None
self.is_system_extension = None
self.support_multiple_extensions = None
self.version = None
self.vm_os_type = None
self.vm_scale_set_enabled = None
self.uri = None
class ExtendedProductProperties(VirtualMachineExtensionProductProperties, VirtualMachineProductProperties):
"""Product information.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar os_disk_image: OS disk image used by product.
:vartype os_disk_image: ~azure.mgmt.azurestack.models.OsDiskImage
:ivar data_disk_images: List of attached data disks.
:vartype data_disk_images: list[~azure.mgmt.azurestack.models.DataDiskImage]
:ivar compute_role: Specifies kind of compute role included in the package. Known values are:
"None", "IaaS", and "PaaS".
:vartype compute_role: str or ~azure.mgmt.azurestack.models.ComputeRole
:ivar is_system_extension: Specifies if product is a Virtual Machine Extension.
:vartype is_system_extension: bool
:ivar support_multiple_extensions: Indicates if specified product supports multiple extensions.
:vartype support_multiple_extensions: bool
:ivar version: Specifies product version.
:vartype version: str
:ivar vm_os_type: Specifies operating system used by the product. Known values are: "None",
"Windows", and "Linux".
:vartype vm_os_type: str or ~azure.mgmt.azurestack.models.OperatingSystem
:ivar vm_scale_set_enabled: Indicates if virtual machine Scale Set is enabled in the specified
product.
:vartype vm_scale_set_enabled: bool
:ivar uri: The URI.
:vartype uri: str
"""
_validation = {
"os_disk_image": {"readonly": True},
"data_disk_images": {"readonly": True},
"compute_role": {"readonly": True},
"is_system_extension": {"readonly": True},
"support_multiple_extensions": {"readonly": True},
"version": {"readonly": True},
"vm_os_type": {"readonly": True},
"vm_scale_set_enabled": {"readonly": True},
"uri": {"readonly": True},
}
_attribute_map = {
"os_disk_image": {"key": "osDiskImage", "type": "OsDiskImage"},
"data_disk_images": {"key": "dataDiskImages", "type": "[DataDiskImage]"},
"compute_role": {"key": "computeRole", "type": "str"},
"is_system_extension": {"key": "isSystemExtension", "type": "bool"},
"support_multiple_extensions": {"key": "supportMultipleExtensions", "type": "bool"},
"version": {"key": "version", "type": "str"},
"vm_os_type": {"key": "vmOsType", "type": "str"},
"vm_scale_set_enabled": {"key": "vmScaleSetEnabled", "type": "bool"},
"uri": {"key": "sourceBlob.uri", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.os_disk_image = None
self.data_disk_images = None
self.compute_role = None
self.is_system_extension = None
self.support_multiple_extensions = None
self.version = None
self.vm_os_type = None
self.vm_scale_set_enabled = None
self.uri = None
class IconUris(_serialization.Model):
"""Links to product icons.
:ivar large: URI to large icon.
:vartype large: str
:ivar wide: URI to wide icon.
:vartype wide: str
:ivar medium: URI to medium icon.
:vartype medium: str
:ivar small: URI to small icon.
:vartype small: str
:ivar hero: URI to hero icon.
:vartype hero: str
"""
_attribute_map = {
"large": {"key": "large", "type": "str"},
"wide": {"key": "wide", "type": "str"},
"medium": {"key": "medium", "type": "str"},
"small": {"key": "small", "type": "str"},
"hero": {"key": "hero", "type": "str"},
}
def __init__(
self,
*,
large: Optional[str] = None,
wide: Optional[str] = None,
medium: Optional[str] = None,
small: Optional[str] = None,
hero: Optional[str] = None,
**kwargs
):
"""
:keyword large: URI to large icon.
:paramtype large: str
:keyword wide: URI to wide icon.
:paramtype wide: str
:keyword medium: URI to medium icon.
:paramtype medium: str
:keyword small: URI to small icon.
:paramtype small: str
:keyword hero: URI to hero icon.
:paramtype hero: str
"""
super().__init__(**kwargs)
self.large = large
self.wide = wide
self.medium = medium
self.small = small
self.hero = hero
class MarketplaceProductLogUpdate(_serialization.Model):
"""Update details for product log.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar operation: Operation to log.
:vartype operation: str
:ivar status: Operation status to log.
:vartype status: str
:ivar error: Error related to the operation.
:vartype error: str
:ivar details: Error details related to operation.
:vartype details: str
"""
_validation = {
"operation": {"readonly": True},
"status": {"readonly": True},
"error": {"readonly": True},
"details": {"readonly": True},
}
_attribute_map = {
"operation": {"key": "operation", "type": "str"},
"status": {"key": "status", "type": "str"},
"error": {"key": "error", "type": "str"},
"details": {"key": "details", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.operation = None
self.status = None
self.error = None
self.details = None
class Operation(_serialization.Model):
"""Describes the supported REST operation.
:ivar name: The name of the operation being performed on this particular object.
:vartype name: str
:ivar display: Contains the localized display information for this particular operation or
action.
:vartype display: ~azure.mgmt.azurestack.models.Display
:ivar origin: The intended executor of the operation.
:vartype origin: str
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"display": {"key": "display", "type": "Display"},
"origin": {"key": "origin", "type": "str"},
}
def __init__(
self,
*,
name: Optional[str] = None,
display: Optional["_models.Display"] = None,
origin: Optional[str] = None,
**kwargs
):
"""
:keyword name: The name of the operation being performed on this particular object.
:paramtype name: str
:keyword display: Contains the localized display information for this particular operation or
action.
:paramtype display: ~azure.mgmt.azurestack.models.Display
:keyword origin: The intended executor of the operation.
:paramtype origin: str
"""
super().__init__(**kwargs)
self.name = name
self.display = display
self.origin = origin
class OperationList(_serialization.Model):
"""List of Operations.
:ivar value: Array of operations.
:vartype value: list[~azure.mgmt.azurestack.models.Operation]
:ivar next_link: URI to the next page of operations.
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[Operation]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs):
"""
:keyword value: Array of operations.
:paramtype value: list[~azure.mgmt.azurestack.models.Operation]
:keyword next_link: URI to the next page of operations.
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class OsDiskImage(_serialization.Model):
"""OS disk image.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar operating_system: OS operating system type. Known values are: "None", "Windows", and
"Linux".
:vartype operating_system: str or ~azure.mgmt.azurestack.models.OperatingSystem
:ivar source_blob_sas_uri: SAS key for source blob.
:vartype source_blob_sas_uri: str
"""
_validation = {
"operating_system": {"readonly": True},
"source_blob_sas_uri": {"readonly": True},
}
_attribute_map = {
"operating_system": {"key": "operatingSystem", "type": "str"},
"source_blob_sas_uri": {"key": "sourceBlobSasUri", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.operating_system = None
self.source_blob_sas_uri = None
class Product(Resource): # pylint: disable=too-many-instance-attributes
"""Product information.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: ID of the resource.
:vartype id: str
:ivar name: Name of the resource.
:vartype name: str
:ivar type: Type of Resource.
:vartype type: str
:ivar etag: The entity tag used for optimistic concurrency when modifying the resource.
:vartype etag: str
:ivar display_name: The display name of the product.
:vartype display_name: str
:ivar description: The description of the product.
:vartype description: str
:ivar publisher_display_name: The user-friendly name of the product publisher.
:vartype publisher_display_name: str
:ivar publisher_identifier: Publisher identifier.
:vartype publisher_identifier: str
:ivar offer: The offer representing the product.
:vartype offer: str
:ivar offer_version: The version of the product offer.
:vartype offer_version: str
:ivar sku: The product SKU.
:vartype sku: str
:ivar billing_part_number: The part number used for billing purposes.
:vartype billing_part_number: str
:ivar vm_extension_type: The type of the Virtual Machine Extension.
:vartype vm_extension_type: str
:ivar gallery_item_identity: The identifier of the gallery item corresponding to the product.
:vartype gallery_item_identity: str
:ivar icon_uris: Additional links available for this product.
:vartype icon_uris: ~azure.mgmt.azurestack.models.IconUris
:ivar links: Additional links available for this product.
:vartype links: list[~azure.mgmt.azurestack.models.ProductLink]
:ivar legal_terms: The legal terms.
:vartype legal_terms: str
:ivar privacy_policy: The privacy policy.
:vartype privacy_policy: str
:ivar payload_length: The length of product content.
:vartype payload_length: int
:ivar product_kind: The kind of the product (virtualMachine or virtualMachineExtension).
:vartype product_kind: str
:ivar product_properties: Additional properties for the product.
:vartype product_properties: ~azure.mgmt.azurestack.models.ProductProperties
:ivar compatibility: Product compatibility with current device.
:vartype compatibility: ~azure.mgmt.azurestack.models.Compatibility
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"etag": {"key": "etag", "type": "str"},
"display_name": {"key": "properties.displayName", "type": "str"},
"description": {"key": "properties.description", "type": "str"},
"publisher_display_name": {"key": "properties.publisherDisplayName", "type": "str"},
"publisher_identifier": {"key": "properties.publisherIdentifier", "type": "str"},
"offer": {"key": "properties.offer", "type": "str"},
"offer_version": {"key": "properties.offerVersion", "type": "str"},
"sku": {"key": "properties.sku", "type": "str"},
"billing_part_number": {"key": "properties.billingPartNumber", "type": "str"},
"vm_extension_type": {"key": "properties.vmExtensionType", "type": "str"},
"gallery_item_identity": {"key": "properties.galleryItemIdentity", "type": "str"},
"icon_uris": {"key": "properties.iconUris", "type": "IconUris"},
"links": {"key": "properties.links", "type": "[ProductLink]"},
"legal_terms": {"key": "properties.legalTerms", "type": "str"},
"privacy_policy": {"key": "properties.privacyPolicy", "type": "str"},
"payload_length": {"key": "properties.payloadLength", "type": "int"},
"product_kind": {"key": "properties.productKind", "type": "str"},
"product_properties": {"key": "properties.productProperties", "type": "ProductProperties"},
"compatibility": {"key": "properties.compatibility", "type": "Compatibility"},
}
def __init__(
self,
*,
etag: Optional[str] = None,
display_name: Optional[str] = None,
description: Optional[str] = None,
publisher_display_name: Optional[str] = None,
publisher_identifier: Optional[str] = None,
offer: Optional[str] = None,
offer_version: Optional[str] = None,
sku: Optional[str] = None,
billing_part_number: Optional[str] = None,
vm_extension_type: Optional[str] = None,
gallery_item_identity: Optional[str] = None,
icon_uris: Optional["_models.IconUris"] = None,
links: Optional[List["_models.ProductLink"]] = None,
legal_terms: Optional[str] = None,
privacy_policy: Optional[str] = None,
payload_length: Optional[int] = None,
product_kind: Optional[str] = None,
product_properties: Optional["_models.ProductProperties"] = None,
compatibility: Optional["_models.Compatibility"] = None,
**kwargs
):
"""
:keyword etag: The entity tag used for optimistic concurrency when modifying the resource.
:paramtype etag: str
:keyword display_name: The display name of the product.
:paramtype display_name: str
:keyword description: The description of the product.
:paramtype description: str
:keyword publisher_display_name: The user-friendly name of the product publisher.
:paramtype publisher_display_name: str
:keyword publisher_identifier: Publisher identifier.
:paramtype publisher_identifier: str
:keyword offer: The offer representing the product.
:paramtype offer: str
:keyword offer_version: The version of the product offer.
:paramtype offer_version: str
:keyword sku: The product SKU.
:paramtype sku: str
:keyword billing_part_number: The part number used for billing purposes.
:paramtype billing_part_number: str
:keyword vm_extension_type: The type of the Virtual Machine Extension.
:paramtype vm_extension_type: str
:keyword gallery_item_identity: The identifier of the gallery item corresponding to the
product.
:paramtype gallery_item_identity: str
:keyword icon_uris: Additional links available for this product.
:paramtype icon_uris: ~azure.mgmt.azurestack.models.IconUris
:keyword links: Additional links available for this product.
:paramtype links: list[~azure.mgmt.azurestack.models.ProductLink]
:keyword legal_terms: The legal terms.
:paramtype legal_terms: str
:keyword privacy_policy: The privacy policy.
:paramtype privacy_policy: str
:keyword payload_length: The length of product content.
:paramtype payload_length: int
:keyword product_kind: The kind of the product (virtualMachine or virtualMachineExtension).
:paramtype product_kind: str
:keyword product_properties: Additional properties for the product.
:paramtype product_properties: ~azure.mgmt.azurestack.models.ProductProperties
:keyword compatibility: Product compatibility with current device.
:paramtype compatibility: ~azure.mgmt.azurestack.models.Compatibility
"""
super().__init__(etag=etag, **kwargs)
self.display_name = display_name
self.description = description
self.publisher_display_name = publisher_display_name
self.publisher_identifier = publisher_identifier
self.offer = offer
self.offer_version = offer_version
self.sku = sku
self.billing_part_number = billing_part_number
self.vm_extension_type = vm_extension_type
self.gallery_item_identity = gallery_item_identity
self.icon_uris = icon_uris
self.links = links
self.legal_terms = legal_terms
self.privacy_policy = privacy_policy
self.payload_length = payload_length
self.product_kind = product_kind
self.product_properties = product_properties
self.compatibility = compatibility
class ProductLink(_serialization.Model):
"""Link with additional information about a product.
:ivar display_name: The description of the link.
:vartype display_name: str
:ivar uri: The URI corresponding to the link.
:vartype uri: str
"""
_attribute_map = {
"display_name": {"key": "displayName", "type": "str"},
"uri": {"key": "uri", "type": "str"},
}
def __init__(self, *, display_name: Optional[str] = None, uri: Optional[str] = None, **kwargs):
"""
:keyword display_name: The description of the link.
:paramtype display_name: str
:keyword uri: The URI corresponding to the link.
:paramtype uri: str
"""
super().__init__(**kwargs)
self.display_name = display_name
self.uri = uri
class ProductList(_serialization.Model):
"""Pageable list of products.
:ivar next_link: URI to the next page.
:vartype next_link: str
:ivar value: List of products.
:vartype value: list[~azure.mgmt.azurestack.models.Product]
"""
_attribute_map = {
"next_link": {"key": "nextLink", "type": "str"},
"value": {"key": "value", "type": "[Product]"},
}
def __init__(self, *, next_link: Optional[str] = None, value: Optional[List["_models.Product"]] = None, **kwargs):
"""
:keyword next_link: URI to the next page.
:paramtype next_link: str
:keyword value: List of products.
:paramtype value: list[~azure.mgmt.azurestack.models.Product]
"""
super().__init__(**kwargs)
self.next_link = next_link
self.value = value
class ProductLog(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""Product action log.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Log ID.
:vartype id: str
:ivar product_id: Logged product ID.
:vartype product_id: str
:ivar subscription_id: Logged subscription ID.
:vartype subscription_id: str
:ivar registration_name: Logged registration name.
:vartype registration_name: str
:ivar resource_group_name: Logged resource group name.
:vartype resource_group_name: str
:ivar operation: Logged operation.
:vartype operation: str
:ivar start_date: Operation start datetime.
:vartype start_date: str
:ivar end_date: Operation end datetime.
:vartype end_date: str
:ivar status: Operation status.
:vartype status: str
:ivar error: Operation error data.
:vartype error: str
:ivar details: Operation error details.
:vartype details: str
"""
_validation = {
"id": {"readonly": True},
"product_id": {"readonly": True},
"subscription_id": {"readonly": True},
"registration_name": {"readonly": True},
"resource_group_name": {"readonly": True},
"operation": {"readonly": True},
"start_date": {"readonly": True},
"end_date": {"readonly": True},
"status": {"readonly": True},
"error": {"readonly": True},
"details": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"product_id": {"key": "productId", "type": "str"},
"subscription_id": {"key": "subscriptionId", "type": "str"},
"registration_name": {"key": "registrationName", "type": "str"},
"resource_group_name": {"key": "resourceGroupName", "type": "str"},
"operation": {"key": "operation", "type": "str"},
"start_date": {"key": "startDate", "type": "str"},
"end_date": {"key": "endDate", "type": "str"},
"status": {"key": "status", "type": "str"},
"error": {"key": "error", "type": "str"},
"details": {"key": "details", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.id = None
self.product_id = None
self.subscription_id = None
self.registration_name = None
self.resource_group_name = None
self.operation = None
self.start_date = None
self.end_date = None
self.status = None
self.error = None
self.details = None
class ProductProperties(_serialization.Model):
"""Additional properties of the product.
:ivar version: The version.
:vartype version: str
"""
_attribute_map = {
"version": {"key": "version", "type": "str"},
}
def __init__(self, *, version: Optional[str] = None, **kwargs):
"""
:keyword version: The version.
:paramtype version: str
"""
super().__init__(**kwargs)
self.version = version
class TrackedResource(_serialization.Model):
"""Base resource object.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: ID of the resource.
:vartype id: str
:ivar name: Name of the resource.
:vartype name: str
:ivar type: Type of Resource.
:vartype type: str
:ivar location: Location of the resource. Required. "global"
:vartype location: str or ~azure.mgmt.azurestack.models.Location
:ivar tags: Custom tags for the resource.
:vartype tags: dict[str, str]
:ivar etag: The entity tag used for optimistic concurrency when modifying the resource.
:vartype etag: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"location": {"key": "location", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"etag": {"key": "etag", "type": "str"},
}
def __init__(
self,
*,
location: Union[str, "_models.Location"],
tags: Optional[Dict[str, str]] = None,
etag: Optional[str] = None,
**kwargs
):
"""
:keyword location: Location of the resource. Required. "global"
:paramtype location: str or ~azure.mgmt.azurestack.models.Location
:keyword tags: Custom tags for the resource.
:paramtype tags: dict[str, str]
:keyword etag: The entity tag used for optimistic concurrency when modifying the resource.
:paramtype etag: str
"""
super().__init__(**kwargs)
self.id = None
self.name = None
self.type = None
self.location = location
self.tags = tags
self.etag = etag
class Registration(TrackedResource):
"""Registration information.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: ID of the resource.
:vartype id: str
:ivar name: Name of the resource.
:vartype name: str
:ivar type: Type of Resource.
:vartype type: str
:ivar location: Location of the resource. Required. "global"
:vartype location: str or ~azure.mgmt.azurestack.models.Location
:ivar tags: Custom tags for the resource.
:vartype tags: dict[str, str]
:ivar etag: The entity tag used for optimistic concurrency when modifying the resource.
:vartype etag: str
:ivar object_id: The object identifier associated with the Azure Stack connecting to Azure.
:vartype object_id: str
:ivar cloud_id: The identifier of the registered Azure Stack.
:vartype cloud_id: str
:ivar billing_model: Specifies the billing mode for the Azure Stack registration.
:vartype billing_model: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"location": {"key": "location", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"etag": {"key": "etag", "type": "str"},
"object_id": {"key": "properties.objectId", "type": "str"},
"cloud_id": {"key": "properties.cloudId", "type": "str"},
"billing_model": {"key": "properties.billingModel", "type": "str"},
}
def __init__(
self,
*,
location: Union[str, "_models.Location"],
tags: Optional[Dict[str, str]] = None,
etag: Optional[str] = None,
object_id: Optional[str] = None,
cloud_id: Optional[str] = None,
billing_model: Optional[str] = None,
**kwargs
):
"""
:keyword location: Location of the resource. Required. "global"
:paramtype location: str or ~azure.mgmt.azurestack.models.Location
:keyword tags: Custom tags for the resource.
:paramtype tags: dict[str, str]
:keyword etag: The entity tag used for optimistic concurrency when modifying the resource.
:paramtype etag: str
:keyword object_id: The object identifier associated with the Azure Stack connecting to Azure.
:paramtype object_id: str
:keyword cloud_id: The identifier of the registered Azure Stack.
:paramtype cloud_id: str
:keyword billing_model: Specifies the billing mode for the Azure Stack registration.
:paramtype billing_model: str
"""
super().__init__(location=location, tags=tags, etag=etag, **kwargs)
self.object_id = object_id
self.cloud_id = cloud_id
self.billing_model = billing_model
class RegistrationList(_serialization.Model):
"""Pageable list of registrations.
:ivar next_link: URI to the next page.
:vartype next_link: str
:ivar value: List of Registrations.
:vartype value: list[~azure.mgmt.azurestack.models.Registration]
"""
_attribute_map = {
"next_link": {"key": "nextLink", "type": "str"},
"value": {"key": "value", "type": "[Registration]"},
}
def __init__(
self, *, next_link: Optional[str] = None, value: Optional[List["_models.Registration"]] = None, **kwargs
):
"""
:keyword next_link: URI to the next page.
:paramtype next_link: str
:keyword value: List of Registrations.
:paramtype value: list[~azure.mgmt.azurestack.models.Registration]
"""
super().__init__(**kwargs)
self.next_link = next_link
self.value = value
class RegistrationParameter(_serialization.Model):
"""Registration resource.
All required parameters must be populated in order to send to Azure.
:ivar location: Location of the resource. Required. "global"
:vartype location: str or ~azure.mgmt.azurestack.models.Location
:ivar registration_token: The token identifying registered Azure Stack. Required.
:vartype registration_token: str
"""
_validation = {
"location": {"required": True},
"registration_token": {"required": True},
}
_attribute_map = {
"location": {"key": "location", "type": "str"},
"registration_token": {"key": "properties.registrationToken", "type": "str"},
}
def __init__(self, *, location: Union[str, "_models.Location"], registration_token: str, **kwargs):
"""
:keyword location: Location of the resource. Required. "global"
:paramtype location: str or ~azure.mgmt.azurestack.models.Location
:keyword registration_token: The token identifying registered Azure Stack. Required.
:paramtype registration_token: str
"""
super().__init__(**kwargs)
self.location = location
self.registration_token = registration_token
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/models/_models_py3.py
|
_models_py3.py
|
from typing import Dict, List, Optional, TYPE_CHECKING, Union
from .. import _serialization
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from .. import models as _models
class ActivationKeyResult(_serialization.Model):
"""The resource containing the Azure Stack activation key.
:ivar activation_key: Azure Stack activation key.
:vartype activation_key: str
"""
_attribute_map = {
"activation_key": {"key": "activationKey", "type": "str"},
}
def __init__(self, *, activation_key: Optional[str] = None, **kwargs):
"""
:keyword activation_key: Azure Stack activation key.
:paramtype activation_key: str
"""
super().__init__(**kwargs)
self.activation_key = activation_key
class CloudManifestFileDeploymentData(_serialization.Model):
"""Cloud specific manifest data for AzureStack deployment.
:ivar external_dsms_certificates: Dsms external certificates.
:vartype external_dsms_certificates: str
:ivar custom_cloud_verification_key: Signing verification public key.
:vartype custom_cloud_verification_key: str
:ivar custom_cloud_arm_endpoint: ARM endpoint.
:vartype custom_cloud_arm_endpoint: str
:ivar external_dsms_endpoint: Dsms endpoint.
:vartype external_dsms_endpoint: str
"""
_attribute_map = {
"external_dsms_certificates": {"key": "externalDsmsCertificates", "type": "str"},
"custom_cloud_verification_key": {"key": "customCloudVerificationKey", "type": "str"},
"custom_cloud_arm_endpoint": {"key": "customEnvironmentEndpoints.customCloudArmEndpoint", "type": "str"},
"external_dsms_endpoint": {"key": "customEnvironmentEndpoints.externalDsmsEndpoint", "type": "str"},
}
def __init__(
self,
*,
external_dsms_certificates: Optional[str] = None,
custom_cloud_verification_key: Optional[str] = None,
custom_cloud_arm_endpoint: Optional[str] = None,
external_dsms_endpoint: Optional[str] = None,
**kwargs
):
"""
:keyword external_dsms_certificates: Dsms external certificates.
:paramtype external_dsms_certificates: str
:keyword custom_cloud_verification_key: Signing verification public key.
:paramtype custom_cloud_verification_key: str
:keyword custom_cloud_arm_endpoint: ARM endpoint.
:paramtype custom_cloud_arm_endpoint: str
:keyword external_dsms_endpoint: Dsms endpoint.
:paramtype external_dsms_endpoint: str
"""
super().__init__(**kwargs)
self.external_dsms_certificates = external_dsms_certificates
self.custom_cloud_verification_key = custom_cloud_verification_key
self.custom_cloud_arm_endpoint = custom_cloud_arm_endpoint
self.external_dsms_endpoint = external_dsms_endpoint
class CloudManifestFileProperties(_serialization.Model):
"""Cloud specific manifest JSON properties.
:ivar deployment_data: Cloud specific manifest data.
:vartype deployment_data: ~azure.mgmt.azurestack.models.CloudManifestFileDeploymentData
:ivar signature: Signature of the cloud specific manifest data.
:vartype signature: str
"""
_attribute_map = {
"deployment_data": {"key": "deploymentData", "type": "CloudManifestFileDeploymentData"},
"signature": {"key": "signature", "type": "str"},
}
def __init__(
self,
*,
deployment_data: Optional["_models.CloudManifestFileDeploymentData"] = None,
signature: Optional[str] = None,
**kwargs
):
"""
:keyword deployment_data: Cloud specific manifest data.
:paramtype deployment_data: ~azure.mgmt.azurestack.models.CloudManifestFileDeploymentData
:keyword signature: Signature of the cloud specific manifest data.
:paramtype signature: str
"""
super().__init__(**kwargs)
self.deployment_data = deployment_data
self.signature = signature
class Resource(_serialization.Model):
"""Base resource object.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: ID of the resource.
:vartype id: str
:ivar name: Name of the resource.
:vartype name: str
:ivar type: Type of Resource.
:vartype type: str
:ivar etag: The entity tag used for optimistic concurrency when modifying the resource.
:vartype etag: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"etag": {"key": "etag", "type": "str"},
}
def __init__(self, *, etag: Optional[str] = None, **kwargs):
"""
:keyword etag: The entity tag used for optimistic concurrency when modifying the resource.
:paramtype etag: str
"""
super().__init__(**kwargs)
self.id = None
self.name = None
self.type = None
self.etag = etag
class CloudManifestFileResponse(Resource):
"""Cloud specific manifest GET response.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: ID of the resource.
:vartype id: str
:ivar name: Name of the resource.
:vartype name: str
:ivar type: Type of Resource.
:vartype type: str
:ivar etag: The entity tag used for optimistic concurrency when modifying the resource.
:vartype etag: str
:ivar properties: Cloud specific manifest data.
:vartype properties: ~azure.mgmt.azurestack.models.CloudManifestFileProperties
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"etag": {"key": "etag", "type": "str"},
"properties": {"key": "properties", "type": "CloudManifestFileProperties"},
}
def __init__(
self,
*,
etag: Optional[str] = None,
properties: Optional["_models.CloudManifestFileProperties"] = None,
**kwargs
):
"""
:keyword etag: The entity tag used for optimistic concurrency when modifying the resource.
:paramtype etag: str
:keyword properties: Cloud specific manifest data.
:paramtype properties: ~azure.mgmt.azurestack.models.CloudManifestFileProperties
"""
super().__init__(etag=etag, **kwargs)
self.properties = properties
class Compatibility(_serialization.Model):
"""Product compatibility.
:ivar is_compatible: Tells if product is compatible with current device.
:vartype is_compatible: bool
:ivar message: Short error message if any compatibility issues are found.
:vartype message: str
:ivar description: Full error message if any compatibility issues are found.
:vartype description: str
:ivar issues: List of all issues found.
:vartype issues: list[str or ~azure.mgmt.azurestack.models.CompatibilityIssue]
"""
_attribute_map = {
"is_compatible": {"key": "isCompatible", "type": "bool"},
"message": {"key": "message", "type": "str"},
"description": {"key": "description", "type": "str"},
"issues": {"key": "issues", "type": "[str]"},
}
def __init__(
self,
*,
is_compatible: Optional[bool] = None,
message: Optional[str] = None,
description: Optional[str] = None,
issues: Optional[List[Union[str, "_models.CompatibilityIssue"]]] = None,
**kwargs
):
"""
:keyword is_compatible: Tells if product is compatible with current device.
:paramtype is_compatible: bool
:keyword message: Short error message if any compatibility issues are found.
:paramtype message: str
:keyword description: Full error message if any compatibility issues are found.
:paramtype description: str
:keyword issues: List of all issues found.
:paramtype issues: list[str or ~azure.mgmt.azurestack.models.CompatibilityIssue]
"""
super().__init__(**kwargs)
self.is_compatible = is_compatible
self.message = message
self.description = description
self.issues = issues
class CustomerSubscription(Resource):
"""Customer subscription.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: ID of the resource.
:vartype id: str
:ivar name: Name of the resource.
:vartype name: str
:ivar type: Type of Resource.
:vartype type: str
:ivar etag: The entity tag used for optimistic concurrency when modifying the resource.
:vartype etag: str
:ivar tenant_id: Tenant Id.
:vartype tenant_id: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"etag": {"key": "etag", "type": "str"},
"tenant_id": {"key": "properties.tenantId", "type": "str"},
}
def __init__(self, *, etag: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs):
"""
:keyword etag: The entity tag used for optimistic concurrency when modifying the resource.
:paramtype etag: str
:keyword tenant_id: Tenant Id.
:paramtype tenant_id: str
"""
super().__init__(etag=etag, **kwargs)
self.tenant_id = tenant_id
class CustomerSubscriptionList(_serialization.Model):
"""Pageable list of customer subscriptions.
:ivar next_link: URI to the next page.
:vartype next_link: str
:ivar value: List of customer subscriptions.
:vartype value: list[~azure.mgmt.azurestack.models.CustomerSubscription]
"""
_attribute_map = {
"next_link": {"key": "nextLink", "type": "str"},
"value": {"key": "value", "type": "[CustomerSubscription]"},
}
def __init__(
self, *, next_link: Optional[str] = None, value: Optional[List["_models.CustomerSubscription"]] = None, **kwargs
):
"""
:keyword next_link: URI to the next page.
:paramtype next_link: str
:keyword value: List of customer subscriptions.
:paramtype value: list[~azure.mgmt.azurestack.models.CustomerSubscription]
"""
super().__init__(**kwargs)
self.next_link = next_link
self.value = value
class DataDiskImage(_serialization.Model):
"""Data disk image.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar lun: The LUN.
:vartype lun: int
:ivar source_blob_sas_uri: SAS key for source blob.
:vartype source_blob_sas_uri: str
"""
_validation = {
"lun": {"readonly": True},
"source_blob_sas_uri": {"readonly": True},
}
_attribute_map = {
"lun": {"key": "lun", "type": "int"},
"source_blob_sas_uri": {"key": "sourceBlobSasUri", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.lun = None
self.source_blob_sas_uri = None
class DeploymentLicenseRequest(_serialization.Model):
"""Request details for generating a deployment license.
:ivar verification_version: Signing verification public key version.
:vartype verification_version: str
"""
_attribute_map = {
"verification_version": {"key": "verificationVersion", "type": "str"},
}
def __init__(self, *, verification_version: Optional[str] = None, **kwargs):
"""
:keyword verification_version: Signing verification public key version.
:paramtype verification_version: str
"""
super().__init__(**kwargs)
self.verification_version = verification_version
class DeploymentLicenseResponse(_serialization.Model):
"""A license that can be used to deploy an Azure Stack device.
:ivar temporary_license_chain: A license chain that can be used to temporarily activate an
Azure Stack device.
:vartype temporary_license_chain: list[str]
:ivar signature: Signature of the license chain.
:vartype signature: str
"""
_attribute_map = {
"temporary_license_chain": {"key": "temporaryLicenseChain", "type": "[str]"},
"signature": {"key": "signature", "type": "str"},
}
def __init__(
self, *, temporary_license_chain: Optional[List[str]] = None, signature: Optional[str] = None, **kwargs
):
"""
:keyword temporary_license_chain: A license chain that can be used to temporarily activate an
Azure Stack device.
:paramtype temporary_license_chain: list[str]
:keyword signature: Signature of the license chain.
:paramtype signature: str
"""
super().__init__(**kwargs)
self.temporary_license_chain = temporary_license_chain
self.signature = signature
class DeviceConfiguration(_serialization.Model):
"""Device Configuration.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar device_version: Version of the device.
:vartype device_version: str
:ivar identity_system: Identity system of the device. Known values are: "AzureAD" and "ADFS".
:vartype identity_system: str or ~azure.mgmt.azurestack.models.Category
"""
_validation = {
"device_version": {"readonly": True},
"identity_system": {"readonly": True},
}
_attribute_map = {
"device_version": {"key": "deviceVersion", "type": "str"},
"identity_system": {"key": "identitySystem", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.device_version = None
self.identity_system = None
class Display(_serialization.Model):
"""Contains the localized display information for this particular operation or action.
:ivar provider: The localized, friendly version of the resource provider name.
:vartype provider: str
:ivar resource: The localized, friendly version of the resource type related to this action or
operation; the resource type should match the public documentation for the resource provider.
:vartype resource: str
:ivar operation: The localized, friendly name for the operation. Use the name as it will
displayed to the user.
:vartype operation: str
:ivar description: The localized, friendly description for the operation. The description will
be displayed to the user. It should be thorough and concise for used in both tooltips and
detailed views.
:vartype 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,
*,
provider: Optional[str] = None,
resource: Optional[str] = None,
operation: Optional[str] = None,
description: Optional[str] = None,
**kwargs
):
"""
:keyword provider: The localized, friendly version of the resource provider name.
:paramtype provider: str
:keyword resource: The localized, friendly version of the resource type related to this action
or operation; the resource type should match the public documentation for the resource
provider.
:paramtype resource: str
:keyword operation: The localized, friendly name for the operation. Use the name as it will
displayed to the user.
:paramtype operation: str
:keyword description: The localized, friendly description for the operation. The description
will be displayed to the user. It should be thorough and concise for used in both tooltips and
detailed views.
:paramtype description: str
"""
super().__init__(**kwargs)
self.provider = provider
self.resource = resource
self.operation = operation
self.description = description
class ErrorDetails(_serialization.Model):
"""The details of the error.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: Error code.
:vartype code: str
:ivar message: Error message indicating why the operation failed.
:vartype message: str
:ivar target: The target of the particular error.
:vartype target: str
"""
_validation = {
"code": {"readonly": True},
"message": {"readonly": True},
"target": {"readonly": True},
}
_attribute_map = {
"code": {"key": "code", "type": "str"},
"message": {"key": "message", "type": "str"},
"target": {"key": "target", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.code = None
self.message = None
self.target = None
class ErrorResponse(_serialization.Model):
"""Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message.
:ivar error: The details of the error.
:vartype error: ~azure.mgmt.azurestack.models.ErrorDetails
"""
_attribute_map = {
"error": {"key": "error", "type": "ErrorDetails"},
}
def __init__(self, *, error: Optional["_models.ErrorDetails"] = None, **kwargs):
"""
:keyword error: The details of the error.
:paramtype error: ~azure.mgmt.azurestack.models.ErrorDetails
"""
super().__init__(**kwargs)
self.error = error
class ExtendedProduct(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""Extended description about the product required for installing it into Azure Stack.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar gallery_package_blob_sas_uri: The URI to the .azpkg file that provides information
required for showing product in the gallery.
:vartype gallery_package_blob_sas_uri: str
:ivar product_kind: Specifies the kind of the product (virtualMachine or
virtualMachineExtension).
:vartype product_kind: str
:ivar compute_role: Specifies kind of compute role included in the package. Known values are:
"None", "IaaS", and "PaaS".
:vartype compute_role: str or ~azure.mgmt.azurestack.models.ComputeRole
:ivar is_system_extension: Specifies if product is a Virtual Machine Extension.
:vartype is_system_extension: bool
:ivar support_multiple_extensions: Indicates if specified product supports multiple extensions.
:vartype support_multiple_extensions: bool
:ivar version_properties_version: Specifies product version.
:vartype version_properties_version: str
:ivar vm_os_type: Specifies operating system used by the product. Known values are: "None",
"Windows", and "Linux".
:vartype vm_os_type: str or ~azure.mgmt.azurestack.models.OperatingSystem
:ivar vm_scale_set_enabled: Indicates if virtual machine Scale Set is enabled in the specified
product.
:vartype vm_scale_set_enabled: bool
:ivar uri: The URI.
:vartype uri: str
:ivar version: Specifies product version.
:vartype version: str
:ivar os_disk_image: OS disk image used by product.
:vartype os_disk_image: ~azure.mgmt.azurestack.models.OsDiskImage
:ivar data_disk_images: List of attached data disks.
:vartype data_disk_images: list[~azure.mgmt.azurestack.models.DataDiskImage]
"""
_validation = {
"gallery_package_blob_sas_uri": {"readonly": True},
"product_kind": {"readonly": True},
"compute_role": {"readonly": True},
"is_system_extension": {"readonly": True},
"support_multiple_extensions": {"readonly": True},
"version_properties_version": {"readonly": True},
"vm_os_type": {"readonly": True},
"vm_scale_set_enabled": {"readonly": True},
"uri": {"readonly": True},
"version": {"readonly": True},
"os_disk_image": {"readonly": True},
"data_disk_images": {"readonly": True},
}
_attribute_map = {
"gallery_package_blob_sas_uri": {"key": "galleryPackageBlobSasUri", "type": "str"},
"product_kind": {"key": "productKind", "type": "str"},
"compute_role": {"key": "properties.computeRole", "type": "str"},
"is_system_extension": {"key": "properties.isSystemExtension", "type": "bool"},
"support_multiple_extensions": {"key": "properties.supportMultipleExtensions", "type": "bool"},
"version_properties_version": {"key": "properties.version", "type": "str"},
"vm_os_type": {"key": "properties.vmOsType", "type": "str"},
"vm_scale_set_enabled": {"key": "properties.vmScaleSetEnabled", "type": "bool"},
"uri": {"key": "properties.sourceBlob.uri", "type": "str"},
"version": {"key": "properties.version", "type": "str"},
"os_disk_image": {"key": "properties.osDiskImage", "type": "OsDiskImage"},
"data_disk_images": {"key": "properties.dataDiskImages", "type": "[DataDiskImage]"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.gallery_package_blob_sas_uri = None
self.product_kind = None
self.compute_role = None
self.is_system_extension = None
self.support_multiple_extensions = None
self.version_properties_version = None
self.vm_os_type = None
self.vm_scale_set_enabled = None
self.uri = None
self.version = None
self.os_disk_image = None
self.data_disk_images = None
class VirtualMachineProductProperties(_serialization.Model):
"""Product information.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar version: Specifies product version.
:vartype version: str
:ivar os_disk_image: OS disk image used by product.
:vartype os_disk_image: ~azure.mgmt.azurestack.models.OsDiskImage
:ivar data_disk_images: List of attached data disks.
:vartype data_disk_images: list[~azure.mgmt.azurestack.models.DataDiskImage]
"""
_validation = {
"version": {"readonly": True},
"os_disk_image": {"readonly": True},
"data_disk_images": {"readonly": True},
}
_attribute_map = {
"version": {"key": "version", "type": "str"},
"os_disk_image": {"key": "osDiskImage", "type": "OsDiskImage"},
"data_disk_images": {"key": "dataDiskImages", "type": "[DataDiskImage]"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.version = None
self.os_disk_image = None
self.data_disk_images = None
class VirtualMachineExtensionProductProperties(_serialization.Model):
"""Product information.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar compute_role: Specifies kind of compute role included in the package. Known values are:
"None", "IaaS", and "PaaS".
:vartype compute_role: str or ~azure.mgmt.azurestack.models.ComputeRole
:ivar is_system_extension: Specifies if product is a Virtual Machine Extension.
:vartype is_system_extension: bool
:ivar support_multiple_extensions: Indicates if specified product supports multiple extensions.
:vartype support_multiple_extensions: bool
:ivar version: Specifies product version.
:vartype version: str
:ivar vm_os_type: Specifies operating system used by the product. Known values are: "None",
"Windows", and "Linux".
:vartype vm_os_type: str or ~azure.mgmt.azurestack.models.OperatingSystem
:ivar vm_scale_set_enabled: Indicates if virtual machine Scale Set is enabled in the specified
product.
:vartype vm_scale_set_enabled: bool
:ivar uri: The URI.
:vartype uri: str
"""
_validation = {
"compute_role": {"readonly": True},
"is_system_extension": {"readonly": True},
"support_multiple_extensions": {"readonly": True},
"version": {"readonly": True},
"vm_os_type": {"readonly": True},
"vm_scale_set_enabled": {"readonly": True},
"uri": {"readonly": True},
}
_attribute_map = {
"compute_role": {"key": "computeRole", "type": "str"},
"is_system_extension": {"key": "isSystemExtension", "type": "bool"},
"support_multiple_extensions": {"key": "supportMultipleExtensions", "type": "bool"},
"version": {"key": "version", "type": "str"},
"vm_os_type": {"key": "vmOsType", "type": "str"},
"vm_scale_set_enabled": {"key": "vmScaleSetEnabled", "type": "bool"},
"uri": {"key": "sourceBlob.uri", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.compute_role = None
self.is_system_extension = None
self.support_multiple_extensions = None
self.version = None
self.vm_os_type = None
self.vm_scale_set_enabled = None
self.uri = None
class ExtendedProductProperties(VirtualMachineExtensionProductProperties, VirtualMachineProductProperties):
"""Product information.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar os_disk_image: OS disk image used by product.
:vartype os_disk_image: ~azure.mgmt.azurestack.models.OsDiskImage
:ivar data_disk_images: List of attached data disks.
:vartype data_disk_images: list[~azure.mgmt.azurestack.models.DataDiskImage]
:ivar compute_role: Specifies kind of compute role included in the package. Known values are:
"None", "IaaS", and "PaaS".
:vartype compute_role: str or ~azure.mgmt.azurestack.models.ComputeRole
:ivar is_system_extension: Specifies if product is a Virtual Machine Extension.
:vartype is_system_extension: bool
:ivar support_multiple_extensions: Indicates if specified product supports multiple extensions.
:vartype support_multiple_extensions: bool
:ivar version: Specifies product version.
:vartype version: str
:ivar vm_os_type: Specifies operating system used by the product. Known values are: "None",
"Windows", and "Linux".
:vartype vm_os_type: str or ~azure.mgmt.azurestack.models.OperatingSystem
:ivar vm_scale_set_enabled: Indicates if virtual machine Scale Set is enabled in the specified
product.
:vartype vm_scale_set_enabled: bool
:ivar uri: The URI.
:vartype uri: str
"""
_validation = {
"os_disk_image": {"readonly": True},
"data_disk_images": {"readonly": True},
"compute_role": {"readonly": True},
"is_system_extension": {"readonly": True},
"support_multiple_extensions": {"readonly": True},
"version": {"readonly": True},
"vm_os_type": {"readonly": True},
"vm_scale_set_enabled": {"readonly": True},
"uri": {"readonly": True},
}
_attribute_map = {
"os_disk_image": {"key": "osDiskImage", "type": "OsDiskImage"},
"data_disk_images": {"key": "dataDiskImages", "type": "[DataDiskImage]"},
"compute_role": {"key": "computeRole", "type": "str"},
"is_system_extension": {"key": "isSystemExtension", "type": "bool"},
"support_multiple_extensions": {"key": "supportMultipleExtensions", "type": "bool"},
"version": {"key": "version", "type": "str"},
"vm_os_type": {"key": "vmOsType", "type": "str"},
"vm_scale_set_enabled": {"key": "vmScaleSetEnabled", "type": "bool"},
"uri": {"key": "sourceBlob.uri", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.os_disk_image = None
self.data_disk_images = None
self.compute_role = None
self.is_system_extension = None
self.support_multiple_extensions = None
self.version = None
self.vm_os_type = None
self.vm_scale_set_enabled = None
self.uri = None
class IconUris(_serialization.Model):
"""Links to product icons.
:ivar large: URI to large icon.
:vartype large: str
:ivar wide: URI to wide icon.
:vartype wide: str
:ivar medium: URI to medium icon.
:vartype medium: str
:ivar small: URI to small icon.
:vartype small: str
:ivar hero: URI to hero icon.
:vartype hero: str
"""
_attribute_map = {
"large": {"key": "large", "type": "str"},
"wide": {"key": "wide", "type": "str"},
"medium": {"key": "medium", "type": "str"},
"small": {"key": "small", "type": "str"},
"hero": {"key": "hero", "type": "str"},
}
def __init__(
self,
*,
large: Optional[str] = None,
wide: Optional[str] = None,
medium: Optional[str] = None,
small: Optional[str] = None,
hero: Optional[str] = None,
**kwargs
):
"""
:keyword large: URI to large icon.
:paramtype large: str
:keyword wide: URI to wide icon.
:paramtype wide: str
:keyword medium: URI to medium icon.
:paramtype medium: str
:keyword small: URI to small icon.
:paramtype small: str
:keyword hero: URI to hero icon.
:paramtype hero: str
"""
super().__init__(**kwargs)
self.large = large
self.wide = wide
self.medium = medium
self.small = small
self.hero = hero
class MarketplaceProductLogUpdate(_serialization.Model):
"""Update details for product log.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar operation: Operation to log.
:vartype operation: str
:ivar status: Operation status to log.
:vartype status: str
:ivar error: Error related to the operation.
:vartype error: str
:ivar details: Error details related to operation.
:vartype details: str
"""
_validation = {
"operation": {"readonly": True},
"status": {"readonly": True},
"error": {"readonly": True},
"details": {"readonly": True},
}
_attribute_map = {
"operation": {"key": "operation", "type": "str"},
"status": {"key": "status", "type": "str"},
"error": {"key": "error", "type": "str"},
"details": {"key": "details", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.operation = None
self.status = None
self.error = None
self.details = None
class Operation(_serialization.Model):
"""Describes the supported REST operation.
:ivar name: The name of the operation being performed on this particular object.
:vartype name: str
:ivar display: Contains the localized display information for this particular operation or
action.
:vartype display: ~azure.mgmt.azurestack.models.Display
:ivar origin: The intended executor of the operation.
:vartype origin: str
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"display": {"key": "display", "type": "Display"},
"origin": {"key": "origin", "type": "str"},
}
def __init__(
self,
*,
name: Optional[str] = None,
display: Optional["_models.Display"] = None,
origin: Optional[str] = None,
**kwargs
):
"""
:keyword name: The name of the operation being performed on this particular object.
:paramtype name: str
:keyword display: Contains the localized display information for this particular operation or
action.
:paramtype display: ~azure.mgmt.azurestack.models.Display
:keyword origin: The intended executor of the operation.
:paramtype origin: str
"""
super().__init__(**kwargs)
self.name = name
self.display = display
self.origin = origin
class OperationList(_serialization.Model):
"""List of Operations.
:ivar value: Array of operations.
:vartype value: list[~azure.mgmt.azurestack.models.Operation]
:ivar next_link: URI to the next page of operations.
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[Operation]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs):
"""
:keyword value: Array of operations.
:paramtype value: list[~azure.mgmt.azurestack.models.Operation]
:keyword next_link: URI to the next page of operations.
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class OsDiskImage(_serialization.Model):
"""OS disk image.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar operating_system: OS operating system type. Known values are: "None", "Windows", and
"Linux".
:vartype operating_system: str or ~azure.mgmt.azurestack.models.OperatingSystem
:ivar source_blob_sas_uri: SAS key for source blob.
:vartype source_blob_sas_uri: str
"""
_validation = {
"operating_system": {"readonly": True},
"source_blob_sas_uri": {"readonly": True},
}
_attribute_map = {
"operating_system": {"key": "operatingSystem", "type": "str"},
"source_blob_sas_uri": {"key": "sourceBlobSasUri", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.operating_system = None
self.source_blob_sas_uri = None
class Product(Resource): # pylint: disable=too-many-instance-attributes
"""Product information.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: ID of the resource.
:vartype id: str
:ivar name: Name of the resource.
:vartype name: str
:ivar type: Type of Resource.
:vartype type: str
:ivar etag: The entity tag used for optimistic concurrency when modifying the resource.
:vartype etag: str
:ivar display_name: The display name of the product.
:vartype display_name: str
:ivar description: The description of the product.
:vartype description: str
:ivar publisher_display_name: The user-friendly name of the product publisher.
:vartype publisher_display_name: str
:ivar publisher_identifier: Publisher identifier.
:vartype publisher_identifier: str
:ivar offer: The offer representing the product.
:vartype offer: str
:ivar offer_version: The version of the product offer.
:vartype offer_version: str
:ivar sku: The product SKU.
:vartype sku: str
:ivar billing_part_number: The part number used for billing purposes.
:vartype billing_part_number: str
:ivar vm_extension_type: The type of the Virtual Machine Extension.
:vartype vm_extension_type: str
:ivar gallery_item_identity: The identifier of the gallery item corresponding to the product.
:vartype gallery_item_identity: str
:ivar icon_uris: Additional links available for this product.
:vartype icon_uris: ~azure.mgmt.azurestack.models.IconUris
:ivar links: Additional links available for this product.
:vartype links: list[~azure.mgmt.azurestack.models.ProductLink]
:ivar legal_terms: The legal terms.
:vartype legal_terms: str
:ivar privacy_policy: The privacy policy.
:vartype privacy_policy: str
:ivar payload_length: The length of product content.
:vartype payload_length: int
:ivar product_kind: The kind of the product (virtualMachine or virtualMachineExtension).
:vartype product_kind: str
:ivar product_properties: Additional properties for the product.
:vartype product_properties: ~azure.mgmt.azurestack.models.ProductProperties
:ivar compatibility: Product compatibility with current device.
:vartype compatibility: ~azure.mgmt.azurestack.models.Compatibility
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"etag": {"key": "etag", "type": "str"},
"display_name": {"key": "properties.displayName", "type": "str"},
"description": {"key": "properties.description", "type": "str"},
"publisher_display_name": {"key": "properties.publisherDisplayName", "type": "str"},
"publisher_identifier": {"key": "properties.publisherIdentifier", "type": "str"},
"offer": {"key": "properties.offer", "type": "str"},
"offer_version": {"key": "properties.offerVersion", "type": "str"},
"sku": {"key": "properties.sku", "type": "str"},
"billing_part_number": {"key": "properties.billingPartNumber", "type": "str"},
"vm_extension_type": {"key": "properties.vmExtensionType", "type": "str"},
"gallery_item_identity": {"key": "properties.galleryItemIdentity", "type": "str"},
"icon_uris": {"key": "properties.iconUris", "type": "IconUris"},
"links": {"key": "properties.links", "type": "[ProductLink]"},
"legal_terms": {"key": "properties.legalTerms", "type": "str"},
"privacy_policy": {"key": "properties.privacyPolicy", "type": "str"},
"payload_length": {"key": "properties.payloadLength", "type": "int"},
"product_kind": {"key": "properties.productKind", "type": "str"},
"product_properties": {"key": "properties.productProperties", "type": "ProductProperties"},
"compatibility": {"key": "properties.compatibility", "type": "Compatibility"},
}
def __init__(
self,
*,
etag: Optional[str] = None,
display_name: Optional[str] = None,
description: Optional[str] = None,
publisher_display_name: Optional[str] = None,
publisher_identifier: Optional[str] = None,
offer: Optional[str] = None,
offer_version: Optional[str] = None,
sku: Optional[str] = None,
billing_part_number: Optional[str] = None,
vm_extension_type: Optional[str] = None,
gallery_item_identity: Optional[str] = None,
icon_uris: Optional["_models.IconUris"] = None,
links: Optional[List["_models.ProductLink"]] = None,
legal_terms: Optional[str] = None,
privacy_policy: Optional[str] = None,
payload_length: Optional[int] = None,
product_kind: Optional[str] = None,
product_properties: Optional["_models.ProductProperties"] = None,
compatibility: Optional["_models.Compatibility"] = None,
**kwargs
):
"""
:keyword etag: The entity tag used for optimistic concurrency when modifying the resource.
:paramtype etag: str
:keyword display_name: The display name of the product.
:paramtype display_name: str
:keyword description: The description of the product.
:paramtype description: str
:keyword publisher_display_name: The user-friendly name of the product publisher.
:paramtype publisher_display_name: str
:keyword publisher_identifier: Publisher identifier.
:paramtype publisher_identifier: str
:keyword offer: The offer representing the product.
:paramtype offer: str
:keyword offer_version: The version of the product offer.
:paramtype offer_version: str
:keyword sku: The product SKU.
:paramtype sku: str
:keyword billing_part_number: The part number used for billing purposes.
:paramtype billing_part_number: str
:keyword vm_extension_type: The type of the Virtual Machine Extension.
:paramtype vm_extension_type: str
:keyword gallery_item_identity: The identifier of the gallery item corresponding to the
product.
:paramtype gallery_item_identity: str
:keyword icon_uris: Additional links available for this product.
:paramtype icon_uris: ~azure.mgmt.azurestack.models.IconUris
:keyword links: Additional links available for this product.
:paramtype links: list[~azure.mgmt.azurestack.models.ProductLink]
:keyword legal_terms: The legal terms.
:paramtype legal_terms: str
:keyword privacy_policy: The privacy policy.
:paramtype privacy_policy: str
:keyword payload_length: The length of product content.
:paramtype payload_length: int
:keyword product_kind: The kind of the product (virtualMachine or virtualMachineExtension).
:paramtype product_kind: str
:keyword product_properties: Additional properties for the product.
:paramtype product_properties: ~azure.mgmt.azurestack.models.ProductProperties
:keyword compatibility: Product compatibility with current device.
:paramtype compatibility: ~azure.mgmt.azurestack.models.Compatibility
"""
super().__init__(etag=etag, **kwargs)
self.display_name = display_name
self.description = description
self.publisher_display_name = publisher_display_name
self.publisher_identifier = publisher_identifier
self.offer = offer
self.offer_version = offer_version
self.sku = sku
self.billing_part_number = billing_part_number
self.vm_extension_type = vm_extension_type
self.gallery_item_identity = gallery_item_identity
self.icon_uris = icon_uris
self.links = links
self.legal_terms = legal_terms
self.privacy_policy = privacy_policy
self.payload_length = payload_length
self.product_kind = product_kind
self.product_properties = product_properties
self.compatibility = compatibility
class ProductLink(_serialization.Model):
"""Link with additional information about a product.
:ivar display_name: The description of the link.
:vartype display_name: str
:ivar uri: The URI corresponding to the link.
:vartype uri: str
"""
_attribute_map = {
"display_name": {"key": "displayName", "type": "str"},
"uri": {"key": "uri", "type": "str"},
}
def __init__(self, *, display_name: Optional[str] = None, uri: Optional[str] = None, **kwargs):
"""
:keyword display_name: The description of the link.
:paramtype display_name: str
:keyword uri: The URI corresponding to the link.
:paramtype uri: str
"""
super().__init__(**kwargs)
self.display_name = display_name
self.uri = uri
class ProductList(_serialization.Model):
"""Pageable list of products.
:ivar next_link: URI to the next page.
:vartype next_link: str
:ivar value: List of products.
:vartype value: list[~azure.mgmt.azurestack.models.Product]
"""
_attribute_map = {
"next_link": {"key": "nextLink", "type": "str"},
"value": {"key": "value", "type": "[Product]"},
}
def __init__(self, *, next_link: Optional[str] = None, value: Optional[List["_models.Product"]] = None, **kwargs):
"""
:keyword next_link: URI to the next page.
:paramtype next_link: str
:keyword value: List of products.
:paramtype value: list[~azure.mgmt.azurestack.models.Product]
"""
super().__init__(**kwargs)
self.next_link = next_link
self.value = value
class ProductLog(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""Product action log.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Log ID.
:vartype id: str
:ivar product_id: Logged product ID.
:vartype product_id: str
:ivar subscription_id: Logged subscription ID.
:vartype subscription_id: str
:ivar registration_name: Logged registration name.
:vartype registration_name: str
:ivar resource_group_name: Logged resource group name.
:vartype resource_group_name: str
:ivar operation: Logged operation.
:vartype operation: str
:ivar start_date: Operation start datetime.
:vartype start_date: str
:ivar end_date: Operation end datetime.
:vartype end_date: str
:ivar status: Operation status.
:vartype status: str
:ivar error: Operation error data.
:vartype error: str
:ivar details: Operation error details.
:vartype details: str
"""
_validation = {
"id": {"readonly": True},
"product_id": {"readonly": True},
"subscription_id": {"readonly": True},
"registration_name": {"readonly": True},
"resource_group_name": {"readonly": True},
"operation": {"readonly": True},
"start_date": {"readonly": True},
"end_date": {"readonly": True},
"status": {"readonly": True},
"error": {"readonly": True},
"details": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"product_id": {"key": "productId", "type": "str"},
"subscription_id": {"key": "subscriptionId", "type": "str"},
"registration_name": {"key": "registrationName", "type": "str"},
"resource_group_name": {"key": "resourceGroupName", "type": "str"},
"operation": {"key": "operation", "type": "str"},
"start_date": {"key": "startDate", "type": "str"},
"end_date": {"key": "endDate", "type": "str"},
"status": {"key": "status", "type": "str"},
"error": {"key": "error", "type": "str"},
"details": {"key": "details", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.id = None
self.product_id = None
self.subscription_id = None
self.registration_name = None
self.resource_group_name = None
self.operation = None
self.start_date = None
self.end_date = None
self.status = None
self.error = None
self.details = None
class ProductProperties(_serialization.Model):
"""Additional properties of the product.
:ivar version: The version.
:vartype version: str
"""
_attribute_map = {
"version": {"key": "version", "type": "str"},
}
def __init__(self, *, version: Optional[str] = None, **kwargs):
"""
:keyword version: The version.
:paramtype version: str
"""
super().__init__(**kwargs)
self.version = version
class TrackedResource(_serialization.Model):
"""Base resource object.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: ID of the resource.
:vartype id: str
:ivar name: Name of the resource.
:vartype name: str
:ivar type: Type of Resource.
:vartype type: str
:ivar location: Location of the resource. Required. "global"
:vartype location: str or ~azure.mgmt.azurestack.models.Location
:ivar tags: Custom tags for the resource.
:vartype tags: dict[str, str]
:ivar etag: The entity tag used for optimistic concurrency when modifying the resource.
:vartype etag: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"location": {"key": "location", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"etag": {"key": "etag", "type": "str"},
}
def __init__(
self,
*,
location: Union[str, "_models.Location"],
tags: Optional[Dict[str, str]] = None,
etag: Optional[str] = None,
**kwargs
):
"""
:keyword location: Location of the resource. Required. "global"
:paramtype location: str or ~azure.mgmt.azurestack.models.Location
:keyword tags: Custom tags for the resource.
:paramtype tags: dict[str, str]
:keyword etag: The entity tag used for optimistic concurrency when modifying the resource.
:paramtype etag: str
"""
super().__init__(**kwargs)
self.id = None
self.name = None
self.type = None
self.location = location
self.tags = tags
self.etag = etag
class Registration(TrackedResource):
"""Registration information.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: ID of the resource.
:vartype id: str
:ivar name: Name of the resource.
:vartype name: str
:ivar type: Type of Resource.
:vartype type: str
:ivar location: Location of the resource. Required. "global"
:vartype location: str or ~azure.mgmt.azurestack.models.Location
:ivar tags: Custom tags for the resource.
:vartype tags: dict[str, str]
:ivar etag: The entity tag used for optimistic concurrency when modifying the resource.
:vartype etag: str
:ivar object_id: The object identifier associated with the Azure Stack connecting to Azure.
:vartype object_id: str
:ivar cloud_id: The identifier of the registered Azure Stack.
:vartype cloud_id: str
:ivar billing_model: Specifies the billing mode for the Azure Stack registration.
:vartype billing_model: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"location": {"key": "location", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"etag": {"key": "etag", "type": "str"},
"object_id": {"key": "properties.objectId", "type": "str"},
"cloud_id": {"key": "properties.cloudId", "type": "str"},
"billing_model": {"key": "properties.billingModel", "type": "str"},
}
def __init__(
self,
*,
location: Union[str, "_models.Location"],
tags: Optional[Dict[str, str]] = None,
etag: Optional[str] = None,
object_id: Optional[str] = None,
cloud_id: Optional[str] = None,
billing_model: Optional[str] = None,
**kwargs
):
"""
:keyword location: Location of the resource. Required. "global"
:paramtype location: str or ~azure.mgmt.azurestack.models.Location
:keyword tags: Custom tags for the resource.
:paramtype tags: dict[str, str]
:keyword etag: The entity tag used for optimistic concurrency when modifying the resource.
:paramtype etag: str
:keyword object_id: The object identifier associated with the Azure Stack connecting to Azure.
:paramtype object_id: str
:keyword cloud_id: The identifier of the registered Azure Stack.
:paramtype cloud_id: str
:keyword billing_model: Specifies the billing mode for the Azure Stack registration.
:paramtype billing_model: str
"""
super().__init__(location=location, tags=tags, etag=etag, **kwargs)
self.object_id = object_id
self.cloud_id = cloud_id
self.billing_model = billing_model
class RegistrationList(_serialization.Model):
"""Pageable list of registrations.
:ivar next_link: URI to the next page.
:vartype next_link: str
:ivar value: List of Registrations.
:vartype value: list[~azure.mgmt.azurestack.models.Registration]
"""
_attribute_map = {
"next_link": {"key": "nextLink", "type": "str"},
"value": {"key": "value", "type": "[Registration]"},
}
def __init__(
self, *, next_link: Optional[str] = None, value: Optional[List["_models.Registration"]] = None, **kwargs
):
"""
:keyword next_link: URI to the next page.
:paramtype next_link: str
:keyword value: List of Registrations.
:paramtype value: list[~azure.mgmt.azurestack.models.Registration]
"""
super().__init__(**kwargs)
self.next_link = next_link
self.value = value
class RegistrationParameter(_serialization.Model):
"""Registration resource.
All required parameters must be populated in order to send to Azure.
:ivar location: Location of the resource. Required. "global"
:vartype location: str or ~azure.mgmt.azurestack.models.Location
:ivar registration_token: The token identifying registered Azure Stack. Required.
:vartype registration_token: str
"""
_validation = {
"location": {"required": True},
"registration_token": {"required": True},
}
_attribute_map = {
"location": {"key": "location", "type": "str"},
"registration_token": {"key": "properties.registrationToken", "type": "str"},
}
def __init__(self, *, location: Union[str, "_models.Location"], registration_token: str, **kwargs):
"""
:keyword location: Location of the resource. Required. "global"
:paramtype location: str or ~azure.mgmt.azurestack.models.Location
:keyword registration_token: The token identifying registered Azure Stack. Required.
:paramtype registration_token: str
"""
super().__init__(**kwargs)
self.location = location
self.registration_token = registration_token
| 0.9292 | 0.232359 |
from ._models_py3 import ActivationKeyResult
from ._models_py3 import CloudManifestFileDeploymentData
from ._models_py3 import CloudManifestFileProperties
from ._models_py3 import CloudManifestFileResponse
from ._models_py3 import Compatibility
from ._models_py3 import CustomerSubscription
from ._models_py3 import CustomerSubscriptionList
from ._models_py3 import DataDiskImage
from ._models_py3 import DeploymentLicenseRequest
from ._models_py3 import DeploymentLicenseResponse
from ._models_py3 import DeviceConfiguration
from ._models_py3 import Display
from ._models_py3 import ErrorDetails
from ._models_py3 import ErrorResponse
from ._models_py3 import ExtendedProduct
from ._models_py3 import ExtendedProductProperties
from ._models_py3 import IconUris
from ._models_py3 import MarketplaceProductLogUpdate
from ._models_py3 import Operation
from ._models_py3 import OperationList
from ._models_py3 import OsDiskImage
from ._models_py3 import Product
from ._models_py3 import ProductLink
from ._models_py3 import ProductList
from ._models_py3 import ProductLog
from ._models_py3 import ProductProperties
from ._models_py3 import Registration
from ._models_py3 import RegistrationList
from ._models_py3 import RegistrationParameter
from ._models_py3 import Resource
from ._models_py3 import TrackedResource
from ._models_py3 import VirtualMachineExtensionProductProperties
from ._models_py3 import VirtualMachineProductProperties
from ._azure_stack_management_client_enums import Category
from ._azure_stack_management_client_enums import CompatibilityIssue
from ._azure_stack_management_client_enums import ComputeRole
from ._azure_stack_management_client_enums import Location
from ._azure_stack_management_client_enums import OperatingSystem
from ._azure_stack_management_client_enums import ProvisioningState
from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
from ._patch import patch_sdk as _patch_sdk
__all__ = [
"ActivationKeyResult",
"CloudManifestFileDeploymentData",
"CloudManifestFileProperties",
"CloudManifestFileResponse",
"Compatibility",
"CustomerSubscription",
"CustomerSubscriptionList",
"DataDiskImage",
"DeploymentLicenseRequest",
"DeploymentLicenseResponse",
"DeviceConfiguration",
"Display",
"ErrorDetails",
"ErrorResponse",
"ExtendedProduct",
"ExtendedProductProperties",
"IconUris",
"MarketplaceProductLogUpdate",
"Operation",
"OperationList",
"OsDiskImage",
"Product",
"ProductLink",
"ProductList",
"ProductLog",
"ProductProperties",
"Registration",
"RegistrationList",
"RegistrationParameter",
"Resource",
"TrackedResource",
"VirtualMachineExtensionProductProperties",
"VirtualMachineProductProperties",
"Category",
"CompatibilityIssue",
"ComputeRole",
"Location",
"OperatingSystem",
"ProvisioningState",
]
__all__.extend([p for p in _patch_all if p not in __all__])
_patch_sdk()
|
azure-mgmt-azurestack
|
/azure-mgmt-azurestack-2.0.0b1.zip/azure-mgmt-azurestack-2.0.0b1/azure/mgmt/azurestack/models/__init__.py
|
__init__.py
|
from ._models_py3 import ActivationKeyResult
from ._models_py3 import CloudManifestFileDeploymentData
from ._models_py3 import CloudManifestFileProperties
from ._models_py3 import CloudManifestFileResponse
from ._models_py3 import Compatibility
from ._models_py3 import CustomerSubscription
from ._models_py3 import CustomerSubscriptionList
from ._models_py3 import DataDiskImage
from ._models_py3 import DeploymentLicenseRequest
from ._models_py3 import DeploymentLicenseResponse
from ._models_py3 import DeviceConfiguration
from ._models_py3 import Display
from ._models_py3 import ErrorDetails
from ._models_py3 import ErrorResponse
from ._models_py3 import ExtendedProduct
from ._models_py3 import ExtendedProductProperties
from ._models_py3 import IconUris
from ._models_py3 import MarketplaceProductLogUpdate
from ._models_py3 import Operation
from ._models_py3 import OperationList
from ._models_py3 import OsDiskImage
from ._models_py3 import Product
from ._models_py3 import ProductLink
from ._models_py3 import ProductList
from ._models_py3 import ProductLog
from ._models_py3 import ProductProperties
from ._models_py3 import Registration
from ._models_py3 import RegistrationList
from ._models_py3 import RegistrationParameter
from ._models_py3 import Resource
from ._models_py3 import TrackedResource
from ._models_py3 import VirtualMachineExtensionProductProperties
from ._models_py3 import VirtualMachineProductProperties
from ._azure_stack_management_client_enums import Category
from ._azure_stack_management_client_enums import CompatibilityIssue
from ._azure_stack_management_client_enums import ComputeRole
from ._azure_stack_management_client_enums import Location
from ._azure_stack_management_client_enums import OperatingSystem
from ._azure_stack_management_client_enums import ProvisioningState
from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
from ._patch import patch_sdk as _patch_sdk
__all__ = [
"ActivationKeyResult",
"CloudManifestFileDeploymentData",
"CloudManifestFileProperties",
"CloudManifestFileResponse",
"Compatibility",
"CustomerSubscription",
"CustomerSubscriptionList",
"DataDiskImage",
"DeploymentLicenseRequest",
"DeploymentLicenseResponse",
"DeviceConfiguration",
"Display",
"ErrorDetails",
"ErrorResponse",
"ExtendedProduct",
"ExtendedProductProperties",
"IconUris",
"MarketplaceProductLogUpdate",
"Operation",
"OperationList",
"OsDiskImage",
"Product",
"ProductLink",
"ProductList",
"ProductLog",
"ProductProperties",
"Registration",
"RegistrationList",
"RegistrationParameter",
"Resource",
"TrackedResource",
"VirtualMachineExtensionProductProperties",
"VirtualMachineProductProperties",
"Category",
"CompatibilityIssue",
"ComputeRole",
"Location",
"OperatingSystem",
"ProvisioningState",
]
__all__.extend([p for p in _patch_all if p not in __all__])
_patch_sdk()
| 0.473901 | 0.071494 |
from copy import deepcopy
from typing import Any, TYPE_CHECKING
from azure.core.rest import HttpRequest, HttpResponse
from azure.mgmt.core import ARMPipelineClient
from . import models as _models
from ._configuration import AzureStackHCIClientConfiguration
from ._serialization import Deserializer, Serializer
from .operations import (
ArcSettingsOperations,
ClustersOperations,
ExtensionsOperations,
GalleryimagesOperations,
GuestAgentOperations,
GuestAgentsOperations,
HybridIdentityMetadataOperations,
MachineExtensionsOperations,
MarketplacegalleryimagesOperations,
NetworkinterfacesOperations,
Operations,
StoragecontainersOperations,
VirtualharddisksOperations,
VirtualmachinesOperations,
VirtualnetworksOperations,
)
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class AzureStackHCIClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
"""Azure Stack HCI management service.
:ivar arc_settings: ArcSettingsOperations operations
:vartype arc_settings: azure.mgmt.azurestackhci.operations.ArcSettingsOperations
:ivar clusters: ClustersOperations operations
:vartype clusters: azure.mgmt.azurestackhci.operations.ClustersOperations
:ivar extensions: ExtensionsOperations operations
:vartype extensions: azure.mgmt.azurestackhci.operations.ExtensionsOperations
:ivar galleryimages: GalleryimagesOperations operations
:vartype galleryimages: azure.mgmt.azurestackhci.operations.GalleryimagesOperations
:ivar marketplacegalleryimages: MarketplacegalleryimagesOperations operations
:vartype marketplacegalleryimages:
azure.mgmt.azurestackhci.operations.MarketplacegalleryimagesOperations
:ivar networkinterfaces: NetworkinterfacesOperations operations
:vartype networkinterfaces: azure.mgmt.azurestackhci.operations.NetworkinterfacesOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.azurestackhci.operations.Operations
:ivar storagecontainers: StoragecontainersOperations operations
:vartype storagecontainers: azure.mgmt.azurestackhci.operations.StoragecontainersOperations
:ivar virtualharddisks: VirtualharddisksOperations operations
:vartype virtualharddisks: azure.mgmt.azurestackhci.operations.VirtualharddisksOperations
:ivar virtualmachines: VirtualmachinesOperations operations
:vartype virtualmachines: azure.mgmt.azurestackhci.operations.VirtualmachinesOperations
:ivar hybrid_identity_metadata: HybridIdentityMetadataOperations operations
:vartype hybrid_identity_metadata:
azure.mgmt.azurestackhci.operations.HybridIdentityMetadataOperations
:ivar machine_extensions: MachineExtensionsOperations operations
:vartype machine_extensions: azure.mgmt.azurestackhci.operations.MachineExtensionsOperations
:ivar guest_agent: GuestAgentOperations operations
:vartype guest_agent: azure.mgmt.azurestackhci.operations.GuestAgentOperations
:ivar guest_agents: GuestAgentsOperations operations
:vartype guest_agents: azure.mgmt.azurestackhci.operations.GuestAgentsOperations
:ivar virtualnetworks: VirtualnetworksOperations operations
:vartype virtualnetworks: azure.mgmt.azurestackhci.operations.VirtualnetworksOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
"""
def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = AzureStackHCIClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.arc_settings = ArcSettingsOperations(self._client, self._config, self._serialize, self._deserialize)
self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize)
self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize)
self.galleryimages = GalleryimagesOperations(self._client, self._config, self._serialize, self._deserialize)
self.marketplacegalleryimages = MarketplacegalleryimagesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.networkinterfaces = NetworkinterfacesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.storagecontainers = StoragecontainersOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.virtualharddisks = VirtualharddisksOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.virtualmachines = VirtualmachinesOperations(self._client, self._config, self._serialize, self._deserialize)
self.hybrid_identity_metadata = HybridIdentityMetadataOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.machine_extensions = MachineExtensionsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.guest_agent = GuestAgentOperations(self._client, self._config, self._serialize, self._deserialize)
self.guest_agents = GuestAgentsOperations(self._client, self._config, self._serialize, self._deserialize)
self.virtualnetworks = VirtualnetworksOperations(self._client, self._config, self._serialize, self._deserialize)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.HttpResponse
"""
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) -> None:
self._client.close()
def __enter__(self) -> "AzureStackHCIClient":
self._client.__enter__()
return self
def __exit__(self, *exc_details) -> None:
self._client.__exit__(*exc_details)
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/_azure_stack_hci_client.py
|
_azure_stack_hci_client.py
|
from copy import deepcopy
from typing import Any, TYPE_CHECKING
from azure.core.rest import HttpRequest, HttpResponse
from azure.mgmt.core import ARMPipelineClient
from . import models as _models
from ._configuration import AzureStackHCIClientConfiguration
from ._serialization import Deserializer, Serializer
from .operations import (
ArcSettingsOperations,
ClustersOperations,
ExtensionsOperations,
GalleryimagesOperations,
GuestAgentOperations,
GuestAgentsOperations,
HybridIdentityMetadataOperations,
MachineExtensionsOperations,
MarketplacegalleryimagesOperations,
NetworkinterfacesOperations,
Operations,
StoragecontainersOperations,
VirtualharddisksOperations,
VirtualmachinesOperations,
VirtualnetworksOperations,
)
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class AzureStackHCIClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
"""Azure Stack HCI management service.
:ivar arc_settings: ArcSettingsOperations operations
:vartype arc_settings: azure.mgmt.azurestackhci.operations.ArcSettingsOperations
:ivar clusters: ClustersOperations operations
:vartype clusters: azure.mgmt.azurestackhci.operations.ClustersOperations
:ivar extensions: ExtensionsOperations operations
:vartype extensions: azure.mgmt.azurestackhci.operations.ExtensionsOperations
:ivar galleryimages: GalleryimagesOperations operations
:vartype galleryimages: azure.mgmt.azurestackhci.operations.GalleryimagesOperations
:ivar marketplacegalleryimages: MarketplacegalleryimagesOperations operations
:vartype marketplacegalleryimages:
azure.mgmt.azurestackhci.operations.MarketplacegalleryimagesOperations
:ivar networkinterfaces: NetworkinterfacesOperations operations
:vartype networkinterfaces: azure.mgmt.azurestackhci.operations.NetworkinterfacesOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.azurestackhci.operations.Operations
:ivar storagecontainers: StoragecontainersOperations operations
:vartype storagecontainers: azure.mgmt.azurestackhci.operations.StoragecontainersOperations
:ivar virtualharddisks: VirtualharddisksOperations operations
:vartype virtualharddisks: azure.mgmt.azurestackhci.operations.VirtualharddisksOperations
:ivar virtualmachines: VirtualmachinesOperations operations
:vartype virtualmachines: azure.mgmt.azurestackhci.operations.VirtualmachinesOperations
:ivar hybrid_identity_metadata: HybridIdentityMetadataOperations operations
:vartype hybrid_identity_metadata:
azure.mgmt.azurestackhci.operations.HybridIdentityMetadataOperations
:ivar machine_extensions: MachineExtensionsOperations operations
:vartype machine_extensions: azure.mgmt.azurestackhci.operations.MachineExtensionsOperations
:ivar guest_agent: GuestAgentOperations operations
:vartype guest_agent: azure.mgmt.azurestackhci.operations.GuestAgentOperations
:ivar guest_agents: GuestAgentsOperations operations
:vartype guest_agents: azure.mgmt.azurestackhci.operations.GuestAgentsOperations
:ivar virtualnetworks: VirtualnetworksOperations operations
:vartype virtualnetworks: azure.mgmt.azurestackhci.operations.VirtualnetworksOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
"""
def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = AzureStackHCIClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.arc_settings = ArcSettingsOperations(self._client, self._config, self._serialize, self._deserialize)
self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize)
self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize)
self.galleryimages = GalleryimagesOperations(self._client, self._config, self._serialize, self._deserialize)
self.marketplacegalleryimages = MarketplacegalleryimagesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.networkinterfaces = NetworkinterfacesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.storagecontainers = StoragecontainersOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.virtualharddisks = VirtualharddisksOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.virtualmachines = VirtualmachinesOperations(self._client, self._config, self._serialize, self._deserialize)
self.hybrid_identity_metadata = HybridIdentityMetadataOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.machine_extensions = MachineExtensionsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.guest_agent = GuestAgentOperations(self._client, self._config, self._serialize, self._deserialize)
self.guest_agents = GuestAgentsOperations(self._client, self._config, self._serialize, self._deserialize)
self.virtualnetworks = VirtualnetworksOperations(self._client, self._config, self._serialize, self._deserialize)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.HttpResponse
"""
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) -> None:
self._client.close()
def __enter__(self) -> "AzureStackHCIClient":
self._client.__enter__()
return self
def __exit__(self, *exc_details) -> None:
self._client.__exit__(*exc_details)
| 0.833799 | 0.131731 |
import sys
from typing import Any, TYPE_CHECKING
from azure.core.configuration import Configuration
from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
from ._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class AzureStackHCIClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureStackHCIClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(AzureStackHCIClientConfiguration, self).__init__(**kwargs)
api_version: Literal["2021-09-01-preview"] = kwargs.pop("api_version", "2021-09-01-preview")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-azurestackhci/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = ARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/_configuration.py
|
_configuration.py
|
import sys
from typing import Any, TYPE_CHECKING
from azure.core.configuration import Configuration
from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
from ._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class AzureStackHCIClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureStackHCIClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(AzureStackHCIClientConfiguration, self).__init__(**kwargs)
api_version: Literal["2021-09-01-preview"] = kwargs.pop("api_version", "2021-09-01-preview")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-azurestackhci/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = ARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
| 0.551332 | 0.084909 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_get_request(
resource_group_name: str, marketplacegalleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"marketplacegalleryimagesName": _SERIALIZER.url(
"marketplacegalleryimages_name", marketplacegalleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, marketplacegalleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"marketplacegalleryimagesName": _SERIALIZER.url(
"marketplacegalleryimages_name", marketplacegalleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, marketplacegalleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"marketplacegalleryimagesName": _SERIALIZER.url(
"marketplacegalleryimages_name", marketplacegalleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, marketplacegalleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"marketplacegalleryimagesName": _SERIALIZER.url(
"marketplacegalleryimages_name", marketplacegalleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages"
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class MarketplacegalleryimagesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`marketplacegalleryimages` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def get(
self, resource_group_name: str, marketplacegalleryimages_name: str, **kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Gets marketplacegalleryimages by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: Union[_models.Marketplacegalleryimages, IO],
**kwargs: Any
) -> _models.Marketplacegalleryimages:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(marketplacegalleryimages, (IO, bytes)):
_content = marketplacegalleryimages
else:
_json = self._serialize.body(marketplacegalleryimages, "Marketplacegalleryimages")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: _models.Marketplacegalleryimages,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Marketplacegalleryimages]:
"""Creates or updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Marketplacegalleryimages or the result of
cls(response)
:rtype:
~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Marketplacegalleryimages]:
"""Creates or updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Marketplacegalleryimages or the result of
cls(response)
:rtype:
~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: Union[_models.Marketplacegalleryimages, IO],
**kwargs: Any
) -> LROPoller[_models.Marketplacegalleryimages]:
"""Creates or updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Is either a model type or a IO type. Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Marketplacegalleryimages or the result of
cls(response)
:rtype:
~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
marketplacegalleryimages=marketplacegalleryimages,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, marketplacegalleryimages_name: str, **kwargs: Any
) -> None:
"""Deletes a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@overload
def update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: _models.MarketplacegalleryimagesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.MarketplacegalleryimagesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: Union[_models.MarketplacegalleryimagesPatch, IO],
**kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Is either a model type or a IO type. Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.MarketplacegalleryimagesPatch
or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(marketplacegalleryimages, (IO, bytes)):
_content = marketplacegalleryimages
else:
_json = self._serialize.body(marketplacegalleryimages, "MarketplacegalleryimagesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> Iterable["_models.Marketplacegalleryimages"]:
"""Lists all marketplacegalleryimages under the resource group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Marketplacegalleryimages or the result of
cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MarketplacegalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("MarketplacegalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Marketplacegalleryimages"]:
"""Lists all marketplacegalleryimages under the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Marketplacegalleryimages or the result of
cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MarketplacegalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("MarketplacegalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_marketplacegalleryimages_operations.py
|
_marketplacegalleryimages_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_get_request(
resource_group_name: str, marketplacegalleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"marketplacegalleryimagesName": _SERIALIZER.url(
"marketplacegalleryimages_name", marketplacegalleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, marketplacegalleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"marketplacegalleryimagesName": _SERIALIZER.url(
"marketplacegalleryimages_name", marketplacegalleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, marketplacegalleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"marketplacegalleryimagesName": _SERIALIZER.url(
"marketplacegalleryimages_name", marketplacegalleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, marketplacegalleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"marketplacegalleryimagesName": _SERIALIZER.url(
"marketplacegalleryimages_name", marketplacegalleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages"
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class MarketplacegalleryimagesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`marketplacegalleryimages` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def get(
self, resource_group_name: str, marketplacegalleryimages_name: str, **kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Gets marketplacegalleryimages by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: Union[_models.Marketplacegalleryimages, IO],
**kwargs: Any
) -> _models.Marketplacegalleryimages:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(marketplacegalleryimages, (IO, bytes)):
_content = marketplacegalleryimages
else:
_json = self._serialize.body(marketplacegalleryimages, "Marketplacegalleryimages")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: _models.Marketplacegalleryimages,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Marketplacegalleryimages]:
"""Creates or updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Marketplacegalleryimages or the result of
cls(response)
:rtype:
~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Marketplacegalleryimages]:
"""Creates or updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Marketplacegalleryimages or the result of
cls(response)
:rtype:
~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: Union[_models.Marketplacegalleryimages, IO],
**kwargs: Any
) -> LROPoller[_models.Marketplacegalleryimages]:
"""Creates or updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Is either a model type or a IO type. Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Marketplacegalleryimages or the result of
cls(response)
:rtype:
~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
marketplacegalleryimages=marketplacegalleryimages,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, marketplacegalleryimages_name: str, **kwargs: Any
) -> None:
"""Deletes a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@overload
def update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: _models.MarketplacegalleryimagesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.MarketplacegalleryimagesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: Union[_models.MarketplacegalleryimagesPatch, IO],
**kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Is either a model type or a IO type. Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.MarketplacegalleryimagesPatch
or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(marketplacegalleryimages, (IO, bytes)):
_content = marketplacegalleryimages
else:
_json = self._serialize.body(marketplacegalleryimages, "MarketplacegalleryimagesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> Iterable["_models.Marketplacegalleryimages"]:
"""Lists all marketplacegalleryimages under the resource group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Marketplacegalleryimages or the result of
cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MarketplacegalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("MarketplacegalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Marketplacegalleryimages"]:
"""Lists all marketplacegalleryimages under the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Marketplacegalleryimages or the result of
cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MarketplacegalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("MarketplacegalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages"
}
| 0.546375 | 0.089375 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_list_by_arc_setting_request(
resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
class ExtensionsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`extensions` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_arc_setting(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> Iterable["_models.Extension"]:
"""List all Extensions under ArcSetting resource.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Extension or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ExtensionList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_arc_setting_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_arc_setting.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ExtensionList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_arc_setting.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions"
}
@distributed_trace
def get(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any
) -> _models.Extension:
"""Get particular Arc Extension of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Extension or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Extension
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
def _create_initial(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> _models.Extension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension, (IO, bytes)):
_content = extension
else:
_json = self._serialize.body(extension, "Extension")
request = build_create_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Extension", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
@overload
def begin_create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: _models.Extension,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Extension]:
"""Create Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Extension or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Extension]:
"""Create Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Extension or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> LROPoller[_models.Extension]:
"""Create Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Is either a model type or a
IO type. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Extension or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_initial(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
extension=extension,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
def _update_initial(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> _models.Extension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension, (IO, bytes)):
_content = extension
else:
_json = self._serialize.body(extension, "Extension")
request = build_update_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
@overload
def begin_update(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: _models.Extension,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Extension]:
"""Update Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Extension or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_update(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Extension]:
"""Update Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Extension or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_update(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> LROPoller[_models.Extension]:
"""Update Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Is either a model type or a
IO type. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Extension or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._update_initial(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
extension=extension,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "original-uri"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
@distributed_trace
def begin_delete(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any
) -> LROPoller[None]:
"""Delete particular Arc Extension of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_extensions_operations.py
|
_extensions_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_list_by_arc_setting_request(
resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
subscription_id: str,
**kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
class ExtensionsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`extensions` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_arc_setting(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> Iterable["_models.Extension"]:
"""List all Extensions under ArcSetting resource.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Extension or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ExtensionList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_arc_setting_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_arc_setting.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ExtensionList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_arc_setting.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions"
}
@distributed_trace
def get(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any
) -> _models.Extension:
"""Get particular Arc Extension of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Extension or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Extension
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
def _create_initial(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> _models.Extension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension, (IO, bytes)):
_content = extension
else:
_json = self._serialize.body(extension, "Extension")
request = build_create_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Extension", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
@overload
def begin_create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: _models.Extension,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Extension]:
"""Create Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Extension or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Extension]:
"""Create Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Extension or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> LROPoller[_models.Extension]:
"""Create Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Is either a model type or a
IO type. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Extension or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_initial(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
extension=extension,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
def _update_initial(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> _models.Extension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension, (IO, bytes)):
_content = extension
else:
_json = self._serialize.body(extension, "Extension")
request = build_update_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
@overload
def begin_update(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: _models.Extension,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Extension]:
"""Update Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Extension or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_update(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Extension]:
"""Update Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Extension or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_update(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> LROPoller[_models.Extension]:
"""Update Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Is either a model type or a
IO type. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Extension or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._update_initial(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
extension=extension,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "original-uri"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
@distributed_trace
def begin_delete(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any
) -> LROPoller[None]:
"""Delete particular Arc Extension of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
| 0.566258 | 0.085671 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_create_request(
resource_group_name: str, virtual_machine_name: str, metadata_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
"metadataName": _SERIALIZER.url("metadata_name", metadata_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, virtual_machine_name: str, metadata_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
"metadataName": _SERIALIZER.url("metadata_name", metadata_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, virtual_machine_name: str, metadata_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
"metadataName": _SERIALIZER.url("metadata_name", metadata_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_virtual_machines_request(
resource_group_name: str, virtual_machine_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class HybridIdentityMetadataOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`hybrid_identity_metadata` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@overload
def create(
self,
resource_group_name: str,
virtual_machine_name: str,
metadata_name: str,
body: Optional[_models.HybridIdentityMetadata] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Implements HybridIdentityMetadata PUT method.
Create Or Update HybridIdentityMetadata.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the hybridIdentityMetadata. Required.
:type metadata_name: str
:param body: Request payload. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def create(
self,
resource_group_name: str,
virtual_machine_name: str,
metadata_name: str,
body: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Implements HybridIdentityMetadata PUT method.
Create Or Update HybridIdentityMetadata.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the hybridIdentityMetadata. Required.
:type metadata_name: str
:param body: Request payload. Default value is None.
:type body: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def create(
self,
resource_group_name: str,
virtual_machine_name: str,
metadata_name: str,
body: Optional[Union[_models.HybridIdentityMetadata, IO]] = None,
**kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Implements HybridIdentityMetadata PUT method.
Create Or Update HybridIdentityMetadata.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the hybridIdentityMetadata. Required.
:type metadata_name: str
:param body: Request payload. Is either a model type or a IO type. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.HybridIdentityMetadata] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(body, (IO, bytes)):
_content = body
else:
if body is not None:
_json = self._serialize.body(body, "HybridIdentityMetadata")
else:
_json = None
request = build_create_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
metadata_name=metadata_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"
}
@distributed_trace
def get(
self, resource_group_name: str, virtual_machine_name: str, metadata_name: str, **kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Gets HybridIdentityMetadata.
Implements HybridIdentityMetadata GET method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the HybridIdentityMetadata. Required.
:type metadata_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.HybridIdentityMetadata] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
metadata_name=metadata_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtual_machine_name: str, metadata_name: str, **kwargs: Any
) -> None:
"""Deletes an HybridIdentityMetadata.
Implements HybridIdentityMetadata DELETE method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the HybridIdentityMetadata. Required.
:type metadata_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
metadata_name=metadata_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"
}
@distributed_trace
def list_by_virtual_machines(
self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any
) -> Iterable["_models.HybridIdentityMetadata"]:
"""Implements GET HybridIdentityMetadata in a vm.
Returns the list of HybridIdentityMetadata of the given vm.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either HybridIdentityMetadata or the result of
cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.HybridIdentityMetadata]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.HybridIdentityMetadataList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_virtual_machines_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_virtual_machines.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("HybridIdentityMetadataList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_virtual_machines.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_hybrid_identity_metadata_operations.py
|
_hybrid_identity_metadata_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_create_request(
resource_group_name: str, virtual_machine_name: str, metadata_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
"metadataName": _SERIALIZER.url("metadata_name", metadata_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, virtual_machine_name: str, metadata_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
"metadataName": _SERIALIZER.url("metadata_name", metadata_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, virtual_machine_name: str, metadata_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
"metadataName": _SERIALIZER.url("metadata_name", metadata_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_virtual_machines_request(
resource_group_name: str, virtual_machine_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class HybridIdentityMetadataOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`hybrid_identity_metadata` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@overload
def create(
self,
resource_group_name: str,
virtual_machine_name: str,
metadata_name: str,
body: Optional[_models.HybridIdentityMetadata] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Implements HybridIdentityMetadata PUT method.
Create Or Update HybridIdentityMetadata.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the hybridIdentityMetadata. Required.
:type metadata_name: str
:param body: Request payload. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def create(
self,
resource_group_name: str,
virtual_machine_name: str,
metadata_name: str,
body: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Implements HybridIdentityMetadata PUT method.
Create Or Update HybridIdentityMetadata.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the hybridIdentityMetadata. Required.
:type metadata_name: str
:param body: Request payload. Default value is None.
:type body: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def create(
self,
resource_group_name: str,
virtual_machine_name: str,
metadata_name: str,
body: Optional[Union[_models.HybridIdentityMetadata, IO]] = None,
**kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Implements HybridIdentityMetadata PUT method.
Create Or Update HybridIdentityMetadata.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the hybridIdentityMetadata. Required.
:type metadata_name: str
:param body: Request payload. Is either a model type or a IO type. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.HybridIdentityMetadata] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(body, (IO, bytes)):
_content = body
else:
if body is not None:
_json = self._serialize.body(body, "HybridIdentityMetadata")
else:
_json = None
request = build_create_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
metadata_name=metadata_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"
}
@distributed_trace
def get(
self, resource_group_name: str, virtual_machine_name: str, metadata_name: str, **kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Gets HybridIdentityMetadata.
Implements HybridIdentityMetadata GET method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the HybridIdentityMetadata. Required.
:type metadata_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.HybridIdentityMetadata] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
metadata_name=metadata_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtual_machine_name: str, metadata_name: str, **kwargs: Any
) -> None:
"""Deletes an HybridIdentityMetadata.
Implements HybridIdentityMetadata DELETE method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the HybridIdentityMetadata. Required.
:type metadata_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
metadata_name=metadata_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"
}
@distributed_trace
def list_by_virtual_machines(
self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any
) -> Iterable["_models.HybridIdentityMetadata"]:
"""Implements GET HybridIdentityMetadata in a vm.
Returns the list of HybridIdentityMetadata of the given vm.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either HybridIdentityMetadata or the result of
cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.HybridIdentityMetadata]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.HybridIdentityMetadataList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_virtual_machines_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_virtual_machines.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("HybridIdentityMetadataList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_virtual_machines.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata"
}
| 0.549157 | 0.077413 |
import sys
from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_create_request(
resource_group_name: str, virtual_machine_name: str, name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
"name": _SERIALIZER.url("name", name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, virtual_machine_name: str, name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
"name": _SERIALIZER.url("name", name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, virtual_machine_name: str, name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
"name": _SERIALIZER.url("name", name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
class GuestAgentOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`guest_agent` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
def _create_initial(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[Union[_models.GuestAgent, IO]] = None,
**kwargs: Any
) -> _models.GuestAgent:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(body, (IO, bytes)):
_content = body
else:
if body is not None:
_json = self._serialize.body(body, "GuestAgent")
else:
_json = None
request = build_create_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("GuestAgent", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("GuestAgent", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
@overload
def begin_create(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[_models.GuestAgent] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.GuestAgent]:
"""Implements GuestAgent PUT method.
Create Or Update GuestAgent.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the guestAgents. Required.
:type name: str
:param body: Request payload. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.GuestAgent
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either GuestAgent or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.GuestAgent]:
"""Implements GuestAgent PUT method.
Create Or Update GuestAgent.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the guestAgents. Required.
:type name: str
:param body: Request payload. Default value is None.
:type body: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either GuestAgent or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[Union[_models.GuestAgent, IO]] = None,
**kwargs: Any
) -> LROPoller[_models.GuestAgent]:
"""Implements GuestAgent PUT method.
Create Or Update GuestAgent.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the guestAgents. Required.
:type name: str
:param body: Request payload. Is either a model type or a IO type. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.GuestAgent or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either GuestAgent or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_initial(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
body=body,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("GuestAgent", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
@distributed_trace
def get(self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any) -> _models.GuestAgent:
"""Gets GuestAgent.
Implements GuestAgent GET method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the GuestAgent. Required.
:type name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestAgent or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.GuestAgent
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("GuestAgent", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
@distributed_trace
def begin_delete(
self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any
) -> LROPoller[None]:
"""Deletes an GuestAgent.
Implements GuestAgent DELETE method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the GuestAgent. Required.
:type name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_guest_agent_operations.py
|
_guest_agent_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_create_request(
resource_group_name: str, virtual_machine_name: str, name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
"name": _SERIALIZER.url("name", name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, virtual_machine_name: str, name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
"name": _SERIALIZER.url("name", name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, virtual_machine_name: str, name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
"name": _SERIALIZER.url("name", name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
class GuestAgentOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`guest_agent` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
def _create_initial(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[Union[_models.GuestAgent, IO]] = None,
**kwargs: Any
) -> _models.GuestAgent:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(body, (IO, bytes)):
_content = body
else:
if body is not None:
_json = self._serialize.body(body, "GuestAgent")
else:
_json = None
request = build_create_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("GuestAgent", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("GuestAgent", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
@overload
def begin_create(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[_models.GuestAgent] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.GuestAgent]:
"""Implements GuestAgent PUT method.
Create Or Update GuestAgent.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the guestAgents. Required.
:type name: str
:param body: Request payload. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.GuestAgent
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either GuestAgent or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.GuestAgent]:
"""Implements GuestAgent PUT method.
Create Or Update GuestAgent.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the guestAgents. Required.
:type name: str
:param body: Request payload. Default value is None.
:type body: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either GuestAgent or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[Union[_models.GuestAgent, IO]] = None,
**kwargs: Any
) -> LROPoller[_models.GuestAgent]:
"""Implements GuestAgent PUT method.
Create Or Update GuestAgent.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the guestAgents. Required.
:type name: str
:param body: Request payload. Is either a model type or a IO type. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.GuestAgent or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either GuestAgent or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_initial(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
body=body,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("GuestAgent", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
@distributed_trace
def get(self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any) -> _models.GuestAgent:
"""Gets GuestAgent.
Implements GuestAgent GET method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the GuestAgent. Required.
:type name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestAgent or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.GuestAgent
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("GuestAgent", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
@distributed_trace
def begin_delete(
self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any
) -> LROPoller[None]:
"""Deletes an GuestAgent.
Implements GuestAgent DELETE method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the GuestAgent. Required.
:type name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
| 0.543833 | 0.077832 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/clusters")
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
class ClustersOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`clusters` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Cluster"]:
"""List all HCI clusters in a subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Cluster or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Cluster]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ClusterList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/clusters"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Cluster"]:
"""List all HCI clusters in a resource group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Cluster or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Cluster]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ClusterList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters"
}
@distributed_trace
def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.Cluster:
"""Get HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Cluster] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Cluster", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
@overload
def create(
self,
resource_group_name: str,
cluster_name: str,
cluster: _models.Cluster,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Create an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.Cluster
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def create(
self,
resource_group_name: str,
cluster_name: str,
cluster: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Create an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def create(
self, resource_group_name: str, cluster_name: str, cluster: Union[_models.Cluster, IO], **kwargs: Any
) -> _models.Cluster:
"""Create an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Is either a model type or a IO type. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.Cluster or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Cluster] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(cluster, (IO, bytes)):
_content = cluster
else:
_json = self._serialize.body(cluster, "Cluster")
request = build_create_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Cluster", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
@overload
def update(
self,
resource_group_name: str,
cluster_name: str,
cluster: _models.ClusterPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Update an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.ClusterPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
cluster_name: str,
cluster: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Update an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self, resource_group_name: str, cluster_name: str, cluster: Union[_models.ClusterPatch, IO], **kwargs: Any
) -> _models.Cluster:
"""Update an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Is either a model type or a IO type. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.ClusterPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Cluster] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(cluster, (IO, bytes)):
_content = cluster
else:
_json = self._serialize.body(cluster, "ClusterPatch")
request = build_update_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Cluster", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, cluster_name: str, **kwargs: Any
) -> None:
"""Delete an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_clusters_operations.py
|
_clusters_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/clusters")
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
class ClustersOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`clusters` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Cluster"]:
"""List all HCI clusters in a subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Cluster or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Cluster]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ClusterList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/clusters"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Cluster"]:
"""List all HCI clusters in a resource group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Cluster or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Cluster]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ClusterList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters"
}
@distributed_trace
def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.Cluster:
"""Get HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Cluster] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Cluster", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
@overload
def create(
self,
resource_group_name: str,
cluster_name: str,
cluster: _models.Cluster,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Create an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.Cluster
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def create(
self,
resource_group_name: str,
cluster_name: str,
cluster: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Create an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def create(
self, resource_group_name: str, cluster_name: str, cluster: Union[_models.Cluster, IO], **kwargs: Any
) -> _models.Cluster:
"""Create an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Is either a model type or a IO type. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.Cluster or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Cluster] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(cluster, (IO, bytes)):
_content = cluster
else:
_json = self._serialize.body(cluster, "Cluster")
request = build_create_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Cluster", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
@overload
def update(
self,
resource_group_name: str,
cluster_name: str,
cluster: _models.ClusterPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Update an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.ClusterPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
cluster_name: str,
cluster: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Update an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self, resource_group_name: str, cluster_name: str, cluster: Union[_models.ClusterPatch, IO], **kwargs: Any
) -> _models.Cluster:
"""Update an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Is either a model type or a IO type. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.ClusterPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Cluster] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(cluster, (IO, bytes)):
_content = cluster
else:
_json = self._serialize.body(cluster, "ClusterPatch")
request = build_update_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Cluster", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, cluster_name: str, **kwargs: Any
) -> None:
"""Delete an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
| 0.563258 | 0.081849 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_retrieve_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_start_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/start",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_stop_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/stop",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_restart_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/restart",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualmachines"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class VirtualmachinesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`virtualmachines` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def retrieve(self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any) -> _models.Virtualmachines:
"""Gets virtual machines by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: Union[_models.Virtualmachines, IO],
**kwargs: Any
) -> _models.Virtualmachines:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualmachines, (IO, bytes)):
_content = virtualmachines
else:
_json = self._serialize.body(virtualmachines, "Virtualmachines")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: _models.Virtualmachines,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Virtualmachines]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.Virtualmachines
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualmachines or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Virtualmachines]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualmachines or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: Union[_models.Virtualmachines, IO],
**kwargs: Any
) -> LROPoller[_models.Virtualmachines]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Is either a model type or a IO type. Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.Virtualmachines or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualmachines or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
virtualmachines=virtualmachines,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
@overload
def update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: _models.VirtualmachinesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualmachines:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.VirtualmachinesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualmachines:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: Union[_models.VirtualmachinesPatch, IO],
**kwargs: Any
) -> _models.Virtualmachines:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Is either a model type or a IO type. Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.VirtualmachinesPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualmachines, (IO, bytes)):
_content = virtualmachines
else:
_json = self._serialize.body(virtualmachines, "VirtualmachinesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
def _start_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_start_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._start_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
if cls:
return cls(pipeline_response, None, {})
_start_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/start"
}
@distributed_trace
def begin_start(self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any) -> LROPoller[None]:
"""start.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._start_initial( # type: ignore
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_start.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/start"
}
def _stop_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_stop_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._stop_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
if cls:
return cls(pipeline_response, None, {})
_stop_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/stop"
}
@distributed_trace
def begin_stop(self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any) -> LROPoller[None]:
"""stop.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._stop_initial( # type: ignore
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_stop.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/stop"
}
def _restart_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_restart_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._restart_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
if cls:
return cls(pipeline_response, None, {})
_restart_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/restart"
}
@distributed_trace
def begin_restart(self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any) -> LROPoller[None]:
"""restart.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._restart_initial( # type: ignore
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_restart.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/restart"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Virtualmachines"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualmachines or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualmachinesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualmachinesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Virtualmachines"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualmachines or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualmachinesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualmachinesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualmachines"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_virtualmachines_operations.py
|
_virtualmachines_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_retrieve_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_start_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/start",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_stop_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/stop",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_restart_request(
resource_group_name: str, virtualmachines_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/restart",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualmachinesName": _SERIALIZER.url(
"virtualmachines_name", virtualmachines_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualmachines"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class VirtualmachinesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`virtualmachines` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def retrieve(self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any) -> _models.Virtualmachines:
"""Gets virtual machines by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: Union[_models.Virtualmachines, IO],
**kwargs: Any
) -> _models.Virtualmachines:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualmachines, (IO, bytes)):
_content = virtualmachines
else:
_json = self._serialize.body(virtualmachines, "Virtualmachines")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: _models.Virtualmachines,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Virtualmachines]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.Virtualmachines
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualmachines or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Virtualmachines]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualmachines or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: Union[_models.Virtualmachines, IO],
**kwargs: Any
) -> LROPoller[_models.Virtualmachines]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Is either a model type or a IO type. Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.Virtualmachines or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualmachines or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
virtualmachines=virtualmachines,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
@overload
def update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: _models.VirtualmachinesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualmachines:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.VirtualmachinesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualmachines:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: Union[_models.VirtualmachinesPatch, IO],
**kwargs: Any
) -> _models.Virtualmachines:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Is either a model type or a IO type. Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.VirtualmachinesPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualmachines, (IO, bytes)):
_content = virtualmachines
else:
_json = self._serialize.body(virtualmachines, "VirtualmachinesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
def _start_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_start_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._start_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
if cls:
return cls(pipeline_response, None, {})
_start_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/start"
}
@distributed_trace
def begin_start(self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any) -> LROPoller[None]:
"""start.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._start_initial( # type: ignore
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_start.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/start"
}
def _stop_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_stop_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._stop_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
if cls:
return cls(pipeline_response, None, {})
_stop_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/stop"
}
@distributed_trace
def begin_stop(self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any) -> LROPoller[None]:
"""stop.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._stop_initial( # type: ignore
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_stop.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/stop"
}
def _restart_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_restart_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._restart_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
if cls:
return cls(pipeline_response, None, {})
_restart_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/restart"
}
@distributed_trace
def begin_restart(self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any) -> LROPoller[None]:
"""restart.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._restart_initial( # type: ignore
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_restart.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/restart"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Virtualmachines"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualmachines or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualmachinesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualmachinesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Virtualmachines"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualmachines or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualmachinesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualmachinesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualmachines"
}
| 0.584983 | 0.081082 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_retrieve_request(
resource_group_name: str, virtualharddisks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualharddisksName": _SERIALIZER.url(
"virtualharddisks_name", virtualharddisks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, virtualharddisks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualharddisksName": _SERIALIZER.url(
"virtualharddisks_name", virtualharddisks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, virtualharddisks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualharddisksName": _SERIALIZER.url(
"virtualharddisks_name", virtualharddisks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, virtualharddisks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualharddisksName": _SERIALIZER.url(
"virtualharddisks_name", virtualharddisks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualharddisks"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class VirtualharddisksOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`virtualharddisks` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def retrieve(self, resource_group_name: str, virtualharddisks_name: str, **kwargs: Any) -> _models.Virtualharddisks:
"""Gets virtualharddisks by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: Union[_models.Virtualharddisks, IO],
**kwargs: Any
) -> _models.Virtualharddisks:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualharddisks, (IO, bytes)):
_content = virtualharddisks
else:
_json = self._serialize.body(virtualharddisks, "Virtualharddisks")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: _models.Virtualharddisks,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Virtualharddisks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualharddisks or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Virtualharddisks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualharddisks or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: Union[_models.Virtualharddisks, IO],
**kwargs: Any
) -> LROPoller[_models.Virtualharddisks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Is either a model type or a IO type. Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.Virtualharddisks or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualharddisks or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
virtualharddisks=virtualharddisks,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualharddisks_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@overload
def update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: _models.VirtualharddisksPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualharddisks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.VirtualharddisksPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualharddisks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: Union[_models.VirtualharddisksPatch, IO],
**kwargs: Any
) -> _models.Virtualharddisks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Is either a model type or a IO type. Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.VirtualharddisksPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualharddisks, (IO, bytes)):
_content = virtualharddisks
else:
_json = self._serialize.body(virtualharddisks, "VirtualharddisksPatch")
request = build_update_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Virtualharddisks"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualharddisks or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualharddisksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualharddisksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Virtualharddisks"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualharddisks or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualharddisksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualharddisksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualharddisks"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_virtualharddisks_operations.py
|
_virtualharddisks_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_retrieve_request(
resource_group_name: str, virtualharddisks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualharddisksName": _SERIALIZER.url(
"virtualharddisks_name", virtualharddisks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, virtualharddisks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualharddisksName": _SERIALIZER.url(
"virtualharddisks_name", virtualharddisks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, virtualharddisks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualharddisksName": _SERIALIZER.url(
"virtualharddisks_name", virtualharddisks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, virtualharddisks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualharddisksName": _SERIALIZER.url(
"virtualharddisks_name", virtualharddisks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualharddisks"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class VirtualharddisksOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`virtualharddisks` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def retrieve(self, resource_group_name: str, virtualharddisks_name: str, **kwargs: Any) -> _models.Virtualharddisks:
"""Gets virtualharddisks by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: Union[_models.Virtualharddisks, IO],
**kwargs: Any
) -> _models.Virtualharddisks:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualharddisks, (IO, bytes)):
_content = virtualharddisks
else:
_json = self._serialize.body(virtualharddisks, "Virtualharddisks")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: _models.Virtualharddisks,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Virtualharddisks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualharddisks or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Virtualharddisks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualharddisks or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: Union[_models.Virtualharddisks, IO],
**kwargs: Any
) -> LROPoller[_models.Virtualharddisks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Is either a model type or a IO type. Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.Virtualharddisks or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualharddisks or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
virtualharddisks=virtualharddisks,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualharddisks_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@overload
def update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: _models.VirtualharddisksPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualharddisks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.VirtualharddisksPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualharddisks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: Union[_models.VirtualharddisksPatch, IO],
**kwargs: Any
) -> _models.Virtualharddisks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Is either a model type or a IO type. Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.VirtualharddisksPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualharddisks, (IO, bytes)):
_content = virtualharddisks
else:
_json = self._serialize.body(virtualharddisks, "VirtualharddisksPatch")
request = build_update_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Virtualharddisks"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualharddisks or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualharddisksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualharddisksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Virtualharddisks"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualharddisks or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualharddisksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualharddisksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualharddisks"
}
| 0.579519 | 0.08318 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_retrieve_request(
resource_group_name: str, networkinterfaces_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"networkinterfacesName": _SERIALIZER.url(
"networkinterfaces_name", networkinterfaces_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, networkinterfaces_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"networkinterfacesName": _SERIALIZER.url(
"networkinterfaces_name", networkinterfaces_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, networkinterfaces_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"networkinterfacesName": _SERIALIZER.url(
"networkinterfaces_name", networkinterfaces_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, networkinterfaces_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"networkinterfacesName": _SERIALIZER.url(
"networkinterfaces_name", networkinterfaces_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/networkinterfaces"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class NetworkinterfacesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`networkinterfaces` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def retrieve(
self, resource_group_name: str, networkinterfaces_name: str, **kwargs: Any
) -> _models.Networkinterfaces:
"""Gets network interfaces by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: Union[_models.Networkinterfaces, IO],
**kwargs: Any
) -> _models.Networkinterfaces:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(networkinterfaces, (IO, bytes)):
_content = networkinterfaces
else:
_json = self._serialize.body(networkinterfaces, "Networkinterfaces")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: _models.Networkinterfaces,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Networkinterfaces]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Networkinterfaces or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Networkinterfaces]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Networkinterfaces or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: Union[_models.Networkinterfaces, IO],
**kwargs: Any
) -> LROPoller[_models.Networkinterfaces]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Is either a model type or a IO type. Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.Networkinterfaces or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Networkinterfaces or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
networkinterfaces=networkinterfaces,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, networkinterfaces_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@overload
def update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: _models.NetworkinterfacesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Networkinterfaces:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.NetworkinterfacesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Networkinterfaces:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: Union[_models.NetworkinterfacesPatch, IO],
**kwargs: Any
) -> _models.Networkinterfaces:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Is either a model type or a IO type. Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.NetworkinterfacesPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(networkinterfaces, (IO, bytes)):
_content = networkinterfaces
else:
_json = self._serialize.body(networkinterfaces, "NetworkinterfacesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Networkinterfaces"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Networkinterfaces or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.NetworkinterfacesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("NetworkinterfacesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Networkinterfaces"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Networkinterfaces or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.NetworkinterfacesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("NetworkinterfacesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/networkinterfaces"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_networkinterfaces_operations.py
|
_networkinterfaces_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_retrieve_request(
resource_group_name: str, networkinterfaces_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"networkinterfacesName": _SERIALIZER.url(
"networkinterfaces_name", networkinterfaces_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, networkinterfaces_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"networkinterfacesName": _SERIALIZER.url(
"networkinterfaces_name", networkinterfaces_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, networkinterfaces_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"networkinterfacesName": _SERIALIZER.url(
"networkinterfaces_name", networkinterfaces_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, networkinterfaces_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"networkinterfacesName": _SERIALIZER.url(
"networkinterfaces_name", networkinterfaces_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/networkinterfaces"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class NetworkinterfacesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`networkinterfaces` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def retrieve(
self, resource_group_name: str, networkinterfaces_name: str, **kwargs: Any
) -> _models.Networkinterfaces:
"""Gets network interfaces by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: Union[_models.Networkinterfaces, IO],
**kwargs: Any
) -> _models.Networkinterfaces:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(networkinterfaces, (IO, bytes)):
_content = networkinterfaces
else:
_json = self._serialize.body(networkinterfaces, "Networkinterfaces")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: _models.Networkinterfaces,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Networkinterfaces]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Networkinterfaces or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Networkinterfaces]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Networkinterfaces or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: Union[_models.Networkinterfaces, IO],
**kwargs: Any
) -> LROPoller[_models.Networkinterfaces]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Is either a model type or a IO type. Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.Networkinterfaces or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Networkinterfaces or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
networkinterfaces=networkinterfaces,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, networkinterfaces_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@overload
def update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: _models.NetworkinterfacesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Networkinterfaces:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.NetworkinterfacesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Networkinterfaces:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: Union[_models.NetworkinterfacesPatch, IO],
**kwargs: Any
) -> _models.Networkinterfaces:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Is either a model type or a IO type. Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.NetworkinterfacesPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(networkinterfaces, (IO, bytes)):
_content = networkinterfaces
else:
_json = self._serialize.body(networkinterfaces, "NetworkinterfacesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Networkinterfaces"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Networkinterfaces or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.NetworkinterfacesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("NetworkinterfacesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Networkinterfaces"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Networkinterfaces or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.NetworkinterfacesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("NetworkinterfacesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/networkinterfaces"
}
| 0.603581 | 0.085556 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_list_by_cluster_request(
resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
class ArcSettingsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`arc_settings` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_cluster(
self, resource_group_name: str, cluster_name: str, **kwargs: Any
) -> Iterable["_models.ArcSetting"]:
"""Get ArcSetting resources of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either ArcSetting or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.ArcSetting]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ArcSettingList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_cluster_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_cluster.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ArcSettingList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_cluster.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings"
}
@distributed_trace
def get(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> _models.ArcSetting:
"""Get ArcSetting resource details of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ArcSetting", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
@overload
def create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
arc_setting: _models.ArcSetting,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ArcSetting:
"""Create ArcSetting for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster.
Required.
:type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSetting
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
arc_setting: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ArcSetting:
"""Create ArcSetting for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster.
Required.
:type arc_setting: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
arc_setting: Union[_models.ArcSetting, IO],
**kwargs: Any
) -> _models.ArcSetting:
"""Create ArcSetting for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster.
Is either a model type or a IO type. Required.
:type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSetting or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(arc_setting, (IO, bytes)):
_content = arc_setting
else:
_json = self._serialize.body(arc_setting, "ArcSetting")
request = build_create_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ArcSetting", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
@distributed_trace
def begin_delete(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> LROPoller[None]:
"""Delete ArcSetting resource details of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_arc_settings_operations.py
|
_arc_settings_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_list_by_cluster_request(
resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_request(
resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"),
"arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
class ArcSettingsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`arc_settings` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_cluster(
self, resource_group_name: str, cluster_name: str, **kwargs: Any
) -> Iterable["_models.ArcSetting"]:
"""Get ArcSetting resources of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either ArcSetting or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.ArcSetting]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ArcSettingList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_cluster_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_cluster.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ArcSettingList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_cluster.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings"
}
@distributed_trace
def get(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> _models.ArcSetting:
"""Get ArcSetting resource details of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ArcSetting", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
@overload
def create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
arc_setting: _models.ArcSetting,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ArcSetting:
"""Create ArcSetting for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster.
Required.
:type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSetting
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
arc_setting: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ArcSetting:
"""Create ArcSetting for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster.
Required.
:type arc_setting: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
arc_setting: Union[_models.ArcSetting, IO],
**kwargs: Any
) -> _models.ArcSetting:
"""Create ArcSetting for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster.
Is either a model type or a IO type. Required.
:type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSetting or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(arc_setting, (IO, bytes)):
_content = arc_setting
else:
_json = self._serialize.body(arc_setting, "ArcSetting")
request = build_create_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ArcSetting", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
@distributed_trace
def begin_delete(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> LROPoller[None]:
"""Delete ArcSetting resource details of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
| 0.585101 | 0.090133 |
import sys
from typing import Any, Callable, Dict, Optional, TypeVar
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/providers/Microsoft.AzureStackHCI/operations")
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> _models.OperationListResult:
"""List all available Microsoft.AzureStackHCI provider operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: OperationListResult or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.OperationListResult
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None)
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("OperationListResult", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list.metadata = {"url": "/providers/Microsoft.AzureStackHCI/operations"}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_operations.py
|
_operations.py
|
import sys
from typing import Any, Callable, Dict, Optional, TypeVar
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/providers/Microsoft.AzureStackHCI/operations")
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> _models.OperationListResult:
"""List all available Microsoft.AzureStackHCI provider operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: OperationListResult or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.OperationListResult
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None)
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("OperationListResult", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list.metadata = {"url": "/providers/Microsoft.AzureStackHCI/operations"}
| 0.602529 | 0.073463 |
import sys
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_list_by_virtual_machines_request(
resource_group_name: str, virtual_machine_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class GuestAgentsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`guest_agents` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_virtual_machines(
self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any
) -> Iterable["_models.GuestAgent"]:
"""Implements GET GuestAgent in a vm.
Returns the list of GuestAgent of the given vm.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either GuestAgent or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GuestAgentList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_virtual_machines_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_virtual_machines.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("GuestAgentList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_virtual_machines.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_guest_agents_operations.py
|
_guest_agents_operations.py
|
import sys
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_list_by_virtual_machines_request(
resource_group_name: str, virtual_machine_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class GuestAgentsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`guest_agents` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_virtual_machines(
self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any
) -> Iterable["_models.GuestAgent"]:
"""Implements GET GuestAgent in a vm.
Returns the list of GuestAgent of the given vm.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either GuestAgent or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GuestAgentList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_virtual_machines_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_virtual_machines.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("GuestAgentList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_virtual_machines.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents"
}
| 0.609873 | 0.066055 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_create_or_update_request(
resource_group_name: str, name: str, extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"name": _SERIALIZER.url("name", name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, name: str, extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"name": _SERIALIZER.url("name", name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, name: str, extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"name": _SERIALIZER.url("name", name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, name: str, extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"name": _SERIALIZER.url("name", name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_virtual_machines_request(
resource_group_name: str, name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"name": _SERIALIZER.url("name", name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
if expand is not None:
_params["$expand"] = _SERIALIZER.query("expand", expand, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class MachineExtensionsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`machine_extensions` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
def _create_or_update_initial(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtension, IO],
**kwargs: Any
) -> _models.MachineExtension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension_parameters, (IO, bytes)):
_content = extension_parameters
else:
_json = self._serialize.body(extension_parameters, "MachineExtension")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: _models.MachineExtension,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.MachineExtension]:
"""The operation to create or update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtension
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.MachineExtension]:
"""The operation to create or update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtension, IO],
**kwargs: Any
) -> LROPoller[_models.MachineExtension]:
"""The operation to create or update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is
either a model type or a IO type. Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtension or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
extension_parameters=extension_parameters,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
def _update_initial(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtensionUpdate, IO],
**kwargs: Any
) -> _models.MachineExtension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension_parameters, (IO, bytes)):
_content = extension_parameters
else:
_json = self._serialize.body(extension_parameters, "MachineExtensionUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@overload
def begin_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: _models.MachineExtensionUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.MachineExtension]:
"""The operation to update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtensionUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.MachineExtension]:
"""The operation to update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtensionUpdate, IO],
**kwargs: Any
) -> LROPoller[_models.MachineExtension]:
"""The operation to update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is
either a model type or a IO type. Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtensionUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._update_initial(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
extension_parameters=extension_parameters,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@distributed_trace
def begin_delete(self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any) -> LROPoller[None]:
"""The operation to delete the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be deleted. Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@distributed_trace
def get(self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any) -> _models.MachineExtension:
"""The operation to get the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine containing the extension. Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: MachineExtension or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.MachineExtension
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@distributed_trace
def list_by_virtual_machines(
self, resource_group_name: str, name: str, expand: Optional[str] = None, **kwargs: Any
) -> Iterable["_models.MachineExtension"]:
"""The operation to get all extensions of a non-Azure machine.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine containing the extension. Required.
:type name: str
:param expand: The expand expression to apply on the operation. Default value is None.
:type expand: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either MachineExtension or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MachineExtensionsListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_virtual_machines_request(
resource_group_name=resource_group_name,
name=name,
subscription_id=self._config.subscription_id,
expand=expand,
api_version=api_version,
template_url=self.list_by_virtual_machines.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("MachineExtensionsListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_virtual_machines.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_machine_extensions_operations.py
|
_machine_extensions_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_create_or_update_request(
resource_group_name: str, name: str, extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"name": _SERIALIZER.url("name", name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, name: str, extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"name": _SERIALIZER.url("name", name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, name: str, extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"name": _SERIALIZER.url("name", name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, name: str, extension_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"name": _SERIALIZER.url("name", name, "str"),
"extensionName": _SERIALIZER.url("extension_name", extension_name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_virtual_machines_request(
resource_group_name: str, name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"name": _SERIALIZER.url("name", name, "str"),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
if expand is not None:
_params["$expand"] = _SERIALIZER.query("expand", expand, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class MachineExtensionsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`machine_extensions` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
def _create_or_update_initial(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtension, IO],
**kwargs: Any
) -> _models.MachineExtension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension_parameters, (IO, bytes)):
_content = extension_parameters
else:
_json = self._serialize.body(extension_parameters, "MachineExtension")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: _models.MachineExtension,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.MachineExtension]:
"""The operation to create or update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtension
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.MachineExtension]:
"""The operation to create or update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtension, IO],
**kwargs: Any
) -> LROPoller[_models.MachineExtension]:
"""The operation to create or update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is
either a model type or a IO type. Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtension or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
extension_parameters=extension_parameters,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
def _update_initial(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtensionUpdate, IO],
**kwargs: Any
) -> _models.MachineExtension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension_parameters, (IO, bytes)):
_content = extension_parameters
else:
_json = self._serialize.body(extension_parameters, "MachineExtensionUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@overload
def begin_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: _models.MachineExtensionUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.MachineExtension]:
"""The operation to update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtensionUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.MachineExtension]:
"""The operation to update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtensionUpdate, IO],
**kwargs: Any
) -> LROPoller[_models.MachineExtension]:
"""The operation to update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is
either a model type or a IO type. Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtensionUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._update_initial(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
extension_parameters=extension_parameters,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@distributed_trace
def begin_delete(self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any) -> LROPoller[None]:
"""The operation to delete the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be deleted. Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.LROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@distributed_trace
def get(self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any) -> _models.MachineExtension:
"""The operation to get the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine containing the extension. Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: MachineExtension or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.MachineExtension
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@distributed_trace
def list_by_virtual_machines(
self, resource_group_name: str, name: str, expand: Optional[str] = None, **kwargs: Any
) -> Iterable["_models.MachineExtension"]:
"""The operation to get all extensions of a non-Azure machine.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine containing the extension. Required.
:type name: str
:param expand: The expand expression to apply on the operation. Default value is None.
:type expand: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either MachineExtension or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MachineExtensionsListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_virtual_machines_request(
resource_group_name=resource_group_name,
name=name,
subscription_id=self._config.subscription_id,
expand=expand,
api_version=api_version,
template_url=self.list_by_virtual_machines.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("MachineExtensionsListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_virtual_machines.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions"
}
| 0.566019 | 0.091788 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_retrieve_request(
resource_group_name: str, virtualnetworks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualnetworksName": _SERIALIZER.url(
"virtualnetworks_name", virtualnetworks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, virtualnetworks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualnetworksName": _SERIALIZER.url(
"virtualnetworks_name", virtualnetworks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, virtualnetworks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualnetworksName": _SERIALIZER.url(
"virtualnetworks_name", virtualnetworks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, virtualnetworks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualnetworksName": _SERIALIZER.url(
"virtualnetworks_name", virtualnetworks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualnetworks"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class VirtualnetworksOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`virtualnetworks` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def retrieve(self, resource_group_name: str, virtualnetworks_name: str, **kwargs: Any) -> _models.Virtualnetworks:
"""retrieve.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: Union[_models.Virtualnetworks, IO],
**kwargs: Any
) -> _models.Virtualnetworks:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualnetworks, (IO, bytes)):
_content = virtualnetworks
else:
_json = self._serialize.body(virtualnetworks, "Virtualnetworks")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: _models.Virtualnetworks,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Virtualnetworks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualnetworks or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Virtualnetworks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualnetworks or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: Union[_models.Virtualnetworks, IO],
**kwargs: Any
) -> LROPoller[_models.Virtualnetworks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Is either a model type or a IO type. Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.Virtualnetworks or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualnetworks or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
virtualnetworks=virtualnetworks,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualnetworks_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@overload
def update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: _models.VirtualnetworksPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualnetworks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.VirtualnetworksPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualnetworks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: Union[_models.VirtualnetworksPatch, IO],
**kwargs: Any
) -> _models.Virtualnetworks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Is either a model type or a IO type. Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.VirtualnetworksPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualnetworks, (IO, bytes)):
_content = virtualnetworks
else:
_json = self._serialize.body(virtualnetworks, "VirtualnetworksPatch")
request = build_update_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Virtualnetworks"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualnetworks or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualnetworksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualnetworksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Virtualnetworks"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualnetworks or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualnetworksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualnetworksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualnetworks"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_virtualnetworks_operations.py
|
_virtualnetworks_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_retrieve_request(
resource_group_name: str, virtualnetworks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualnetworksName": _SERIALIZER.url(
"virtualnetworks_name", virtualnetworks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, virtualnetworks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualnetworksName": _SERIALIZER.url(
"virtualnetworks_name", virtualnetworks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, virtualnetworks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualnetworksName": _SERIALIZER.url(
"virtualnetworks_name", virtualnetworks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, virtualnetworks_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"virtualnetworksName": _SERIALIZER.url(
"virtualnetworks_name", virtualnetworks_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualnetworks"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class VirtualnetworksOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`virtualnetworks` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def retrieve(self, resource_group_name: str, virtualnetworks_name: str, **kwargs: Any) -> _models.Virtualnetworks:
"""retrieve.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: Union[_models.Virtualnetworks, IO],
**kwargs: Any
) -> _models.Virtualnetworks:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualnetworks, (IO, bytes)):
_content = virtualnetworks
else:
_json = self._serialize.body(virtualnetworks, "Virtualnetworks")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: _models.Virtualnetworks,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Virtualnetworks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualnetworks or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Virtualnetworks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualnetworks or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: Union[_models.Virtualnetworks, IO],
**kwargs: Any
) -> LROPoller[_models.Virtualnetworks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Is either a model type or a IO type. Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.Virtualnetworks or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Virtualnetworks or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
virtualnetworks=virtualnetworks,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualnetworks_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@overload
def update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: _models.VirtualnetworksPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualnetworks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.VirtualnetworksPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualnetworks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: Union[_models.VirtualnetworksPatch, IO],
**kwargs: Any
) -> _models.Virtualnetworks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Is either a model type or a IO type. Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.VirtualnetworksPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualnetworks, (IO, bytes)):
_content = virtualnetworks
else:
_json = self._serialize.body(virtualnetworks, "VirtualnetworksPatch")
request = build_update_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Virtualnetworks"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualnetworks or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualnetworksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualnetworksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Virtualnetworks"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualnetworks or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualnetworksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualnetworksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualnetworks"
}
| 0.58261 | 0.082365 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_retrieve_request(
resource_group_name: str, galleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"galleryimagesName": _SERIALIZER.url(
"galleryimages_name", galleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, galleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"galleryimagesName": _SERIALIZER.url(
"galleryimages_name", galleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, galleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"galleryimagesName": _SERIALIZER.url(
"galleryimages_name", galleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, galleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"galleryimagesName": _SERIALIZER.url(
"galleryimages_name", galleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/galleryimages")
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class GalleryimagesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`galleryimages` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def retrieve(self, resource_group_name: str, galleryimages_name: str, **kwargs: Any) -> _models.Galleryimages:
"""Gets galleryimages by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: Union[_models.Galleryimages, IO],
**kwargs: Any
) -> _models.Galleryimages:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(galleryimages, (IO, bytes)):
_content = galleryimages
else:
_json = self._serialize.body(galleryimages, "Galleryimages")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: _models.Galleryimages,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Galleryimages]:
"""Create or update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.Galleryimages
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Galleryimages or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Galleryimages]:
"""Create or update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Galleryimages or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: Union[_models.Galleryimages, IO],
**kwargs: Any
) -> LROPoller[_models.Galleryimages]:
"""Create or update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Is either a model type or a IO type. Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.Galleryimages or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Galleryimages or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
galleryimages=galleryimages,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, galleryimages_name: str, **kwargs: Any
) -> None:
"""Delete a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@overload
def update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: _models.GalleryimagesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Galleryimages:
"""Update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.GalleryimagesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Galleryimages:
"""Update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: Union[_models.GalleryimagesPatch, IO],
**kwargs: Any
) -> _models.Galleryimages:
"""Update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Is either a model type or a IO type. Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.GalleryimagesPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(galleryimages, (IO, bytes)):
_content = galleryimages
else:
_json = self._serialize.body(galleryimages, "GalleryimagesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Galleryimages"]:
"""Lists all galleryimages under the resource group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Galleryimages or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("GalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Galleryimages"]:
"""List all galleryimages under the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Galleryimages or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("GalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/galleryimages"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_galleryimages_operations.py
|
_galleryimages_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_retrieve_request(
resource_group_name: str, galleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"galleryimagesName": _SERIALIZER.url(
"galleryimages_name", galleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, galleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"galleryimagesName": _SERIALIZER.url(
"galleryimages_name", galleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, galleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"galleryimagesName": _SERIALIZER.url(
"galleryimages_name", galleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, galleryimages_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"galleryimagesName": _SERIALIZER.url(
"galleryimages_name", galleryimages_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/galleryimages")
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class GalleryimagesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`galleryimages` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def retrieve(self, resource_group_name: str, galleryimages_name: str, **kwargs: Any) -> _models.Galleryimages:
"""Gets galleryimages by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: Union[_models.Galleryimages, IO],
**kwargs: Any
) -> _models.Galleryimages:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(galleryimages, (IO, bytes)):
_content = galleryimages
else:
_json = self._serialize.body(galleryimages, "Galleryimages")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: _models.Galleryimages,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Galleryimages]:
"""Create or update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.Galleryimages
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Galleryimages or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Galleryimages]:
"""Create or update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Galleryimages or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: Union[_models.Galleryimages, IO],
**kwargs: Any
) -> LROPoller[_models.Galleryimages]:
"""Create or update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Is either a model type or a IO type. Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.Galleryimages or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Galleryimages or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
galleryimages=galleryimages,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, galleryimages_name: str, **kwargs: Any
) -> None:
"""Delete a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@overload
def update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: _models.GalleryimagesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Galleryimages:
"""Update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.GalleryimagesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Galleryimages:
"""Update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: Union[_models.GalleryimagesPatch, IO],
**kwargs: Any
) -> _models.Galleryimages:
"""Update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Is either a model type or a IO type. Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.GalleryimagesPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(galleryimages, (IO, bytes)):
_content = galleryimages
else:
_json = self._serialize.body(galleryimages, "GalleryimagesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Galleryimages"]:
"""Lists all galleryimages under the resource group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Galleryimages or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("GalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Galleryimages"]:
"""List all galleryimages under the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Galleryimages or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("GalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/galleryimages"
}
| 0.569134 | 0.102619 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_retrieve_request(
resource_group_name: str, storagecontainers_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"storagecontainersName": _SERIALIZER.url(
"storagecontainers_name", storagecontainers_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, storagecontainers_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"storagecontainersName": _SERIALIZER.url(
"storagecontainers_name", storagecontainers_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, storagecontainers_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"storagecontainersName": _SERIALIZER.url(
"storagecontainers_name", storagecontainers_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, storagecontainers_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"storagecontainersName": _SERIALIZER.url(
"storagecontainers_name", storagecontainers_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/storagecontainers"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class StoragecontainersOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`storagecontainers` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def retrieve(
self, resource_group_name: str, storagecontainers_name: str, **kwargs: Any
) -> _models.Storagecontainers:
"""Gets storagecontainers by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: Union[_models.Storagecontainers, IO],
**kwargs: Any
) -> _models.Storagecontainers:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(storagecontainers, (IO, bytes)):
_content = storagecontainers
else:
_json = self._serialize.body(storagecontainers, "Storagecontainers")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: _models.Storagecontainers,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Storagecontainers]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.Storagecontainers
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Storagecontainers or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Storagecontainers]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Storagecontainers or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: Union[_models.Storagecontainers, IO],
**kwargs: Any
) -> LROPoller[_models.Storagecontainers]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Is either a model type or a IO type. Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.Storagecontainers or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Storagecontainers or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
storagecontainers=storagecontainers,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, storagecontainers_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@overload
def update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: _models.StoragecontainersPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Storagecontainers:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.StoragecontainersPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Storagecontainers:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: Union[_models.StoragecontainersPatch, IO],
**kwargs: Any
) -> _models.Storagecontainers:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Is either a model type or a IO type. Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.StoragecontainersPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(storagecontainers, (IO, bytes)):
_content = storagecontainers
else:
_json = self._serialize.body(storagecontainers, "StoragecontainersPatch")
request = build_update_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Storagecontainers"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Storagecontainers or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.StoragecontainersListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("StoragecontainersListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Storagecontainers"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Storagecontainers or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.StoragecontainersListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("StoragecontainersListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/storagecontainers"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/operations/_storagecontainers_operations.py
|
_storagecontainers_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.polling import LROPoller, NoPolling, PollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.arm_polling import ARMPolling
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_retrieve_request(
resource_group_name: str, storagecontainers_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"storagecontainersName": _SERIALIZER.url(
"storagecontainers_name", storagecontainers_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_create_or_update_request(
resource_group_name: str, storagecontainers_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"storagecontainersName": _SERIALIZER.url(
"storagecontainers_name", storagecontainers_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
def build_delete_request(
resource_group_name: str, storagecontainers_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"storagecontainersName": _SERIALIZER.url(
"storagecontainers_name", storagecontainers_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, storagecontainers_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"storagecontainersName": _SERIALIZER.url(
"storagecontainers_name", storagecontainers_name, "str", max_length=64, min_length=3
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", "2021-09-01-preview")
)
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/storagecontainers"
)
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url: str = _format_url_section(_url, **path_format_arguments) # type: ignore
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class StoragecontainersOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s
:attr:`storagecontainers` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def retrieve(
self, resource_group_name: str, storagecontainers_name: str, **kwargs: Any
) -> _models.Storagecontainers:
"""Gets storagecontainers by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
def _create_or_update_initial(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: Union[_models.Storagecontainers, IO],
**kwargs: Any
) -> _models.Storagecontainers:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(storagecontainers, (IO, bytes)):
_content = storagecontainers
else:
_json = self._serialize.body(storagecontainers, "Storagecontainers")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@overload
def begin_create_or_update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: _models.Storagecontainers,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Storagecontainers]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.Storagecontainers
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Storagecontainers or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def begin_create_or_update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> LROPoller[_models.Storagecontainers]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Storagecontainers or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def begin_create_or_update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: Union[_models.Storagecontainers, IO],
**kwargs: Any
) -> LROPoller[_models.Storagecontainers]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Is either a model type or a IO type. Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.Storagecontainers or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be ARMPolling. Pass in False for this
operation to not poll, or pass in your own initialized polling object for a personal polling
strategy.
:paramtype polling: bool or ~azure.core.polling.PollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of LROPoller that returns either Storagecontainers or the result of
cls(response)
:rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = self._create_or_update_initial(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
storagecontainers=storagecontainers,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: PollingMethod = cast(
PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs)
)
elif polling is False:
polling_method = cast(PollingMethod, NoPolling())
else:
polling_method = polling
if cont_token:
return LROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@distributed_trace
def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, storagecontainers_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@overload
def update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: _models.StoragecontainersPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Storagecontainers:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.StoragecontainersPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Storagecontainers:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: Union[_models.StoragecontainersPatch, IO],
**kwargs: Any
) -> _models.Storagecontainers:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Is either a model type or a IO type. Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.StoragecontainersPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(storagecontainers, (IO, bytes)):
_content = storagecontainers
else:
_json = self._serialize.body(storagecontainers, "StoragecontainersPatch")
request = build_update_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Storagecontainers"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Storagecontainers or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.StoragecontainersListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("StoragecontainersListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Storagecontainers"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Storagecontainers or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.StoragecontainersListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("StoragecontainersListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/storagecontainers"
}
| 0.594198 | 0.085978 |
from copy import deepcopy
from typing import Any, Awaitable, TYPE_CHECKING
from azure.core.rest import AsyncHttpResponse, HttpRequest
from azure.mgmt.core import AsyncARMPipelineClient
from .. import models as _models
from .._serialization import Deserializer, Serializer
from ._configuration import AzureStackHCIClientConfiguration
from .operations import (
ArcSettingsOperations,
ClustersOperations,
ExtensionsOperations,
GalleryimagesOperations,
GuestAgentOperations,
GuestAgentsOperations,
HybridIdentityMetadataOperations,
MachineExtensionsOperations,
MarketplacegalleryimagesOperations,
NetworkinterfacesOperations,
Operations,
StoragecontainersOperations,
VirtualharddisksOperations,
VirtualmachinesOperations,
VirtualnetworksOperations,
)
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class AzureStackHCIClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
"""Azure Stack HCI management service.
:ivar arc_settings: ArcSettingsOperations operations
:vartype arc_settings: azure.mgmt.azurestackhci.aio.operations.ArcSettingsOperations
:ivar clusters: ClustersOperations operations
:vartype clusters: azure.mgmt.azurestackhci.aio.operations.ClustersOperations
:ivar extensions: ExtensionsOperations operations
:vartype extensions: azure.mgmt.azurestackhci.aio.operations.ExtensionsOperations
:ivar galleryimages: GalleryimagesOperations operations
:vartype galleryimages: azure.mgmt.azurestackhci.aio.operations.GalleryimagesOperations
:ivar marketplacegalleryimages: MarketplacegalleryimagesOperations operations
:vartype marketplacegalleryimages:
azure.mgmt.azurestackhci.aio.operations.MarketplacegalleryimagesOperations
:ivar networkinterfaces: NetworkinterfacesOperations operations
:vartype networkinterfaces: azure.mgmt.azurestackhci.aio.operations.NetworkinterfacesOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.azurestackhci.aio.operations.Operations
:ivar storagecontainers: StoragecontainersOperations operations
:vartype storagecontainers: azure.mgmt.azurestackhci.aio.operations.StoragecontainersOperations
:ivar virtualharddisks: VirtualharddisksOperations operations
:vartype virtualharddisks: azure.mgmt.azurestackhci.aio.operations.VirtualharddisksOperations
:ivar virtualmachines: VirtualmachinesOperations operations
:vartype virtualmachines: azure.mgmt.azurestackhci.aio.operations.VirtualmachinesOperations
:ivar hybrid_identity_metadata: HybridIdentityMetadataOperations operations
:vartype hybrid_identity_metadata:
azure.mgmt.azurestackhci.aio.operations.HybridIdentityMetadataOperations
:ivar machine_extensions: MachineExtensionsOperations operations
:vartype machine_extensions:
azure.mgmt.azurestackhci.aio.operations.MachineExtensionsOperations
:ivar guest_agent: GuestAgentOperations operations
:vartype guest_agent: azure.mgmt.azurestackhci.aio.operations.GuestAgentOperations
:ivar guest_agents: GuestAgentsOperations operations
:vartype guest_agents: azure.mgmt.azurestackhci.aio.operations.GuestAgentsOperations
:ivar virtualnetworks: VirtualnetworksOperations operations
:vartype virtualnetworks: azure.mgmt.azurestackhci.aio.operations.VirtualnetworksOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
"""
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = AzureStackHCIClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.arc_settings = ArcSettingsOperations(self._client, self._config, self._serialize, self._deserialize)
self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize)
self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize)
self.galleryimages = GalleryimagesOperations(self._client, self._config, self._serialize, self._deserialize)
self.marketplacegalleryimages = MarketplacegalleryimagesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.networkinterfaces = NetworkinterfacesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.storagecontainers = StoragecontainersOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.virtualharddisks = VirtualharddisksOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.virtualmachines = VirtualmachinesOperations(self._client, self._config, self._serialize, self._deserialize)
self.hybrid_identity_metadata = HybridIdentityMetadataOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.machine_extensions = MachineExtensionsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.guest_agent = GuestAgentOperations(self._client, self._config, self._serialize, self._deserialize)
self.guest_agents = GuestAgentsOperations(self._client, self._config, self._serialize, self._deserialize)
self.virtualnetworks = VirtualnetworksOperations(self._client, self._config, self._serialize, self._deserialize)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client._send_request(request)
<AsyncHttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.AsyncHttpResponse
"""
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()
async def __aenter__(self) -> "AzureStackHCIClient":
await self._client.__aenter__()
return self
async def __aexit__(self, *exc_details) -> None:
await self._client.__aexit__(*exc_details)
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/_azure_stack_hci_client.py
|
_azure_stack_hci_client.py
|
from copy import deepcopy
from typing import Any, Awaitable, TYPE_CHECKING
from azure.core.rest import AsyncHttpResponse, HttpRequest
from azure.mgmt.core import AsyncARMPipelineClient
from .. import models as _models
from .._serialization import Deserializer, Serializer
from ._configuration import AzureStackHCIClientConfiguration
from .operations import (
ArcSettingsOperations,
ClustersOperations,
ExtensionsOperations,
GalleryimagesOperations,
GuestAgentOperations,
GuestAgentsOperations,
HybridIdentityMetadataOperations,
MachineExtensionsOperations,
MarketplacegalleryimagesOperations,
NetworkinterfacesOperations,
Operations,
StoragecontainersOperations,
VirtualharddisksOperations,
VirtualmachinesOperations,
VirtualnetworksOperations,
)
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class AzureStackHCIClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
"""Azure Stack HCI management service.
:ivar arc_settings: ArcSettingsOperations operations
:vartype arc_settings: azure.mgmt.azurestackhci.aio.operations.ArcSettingsOperations
:ivar clusters: ClustersOperations operations
:vartype clusters: azure.mgmt.azurestackhci.aio.operations.ClustersOperations
:ivar extensions: ExtensionsOperations operations
:vartype extensions: azure.mgmt.azurestackhci.aio.operations.ExtensionsOperations
:ivar galleryimages: GalleryimagesOperations operations
:vartype galleryimages: azure.mgmt.azurestackhci.aio.operations.GalleryimagesOperations
:ivar marketplacegalleryimages: MarketplacegalleryimagesOperations operations
:vartype marketplacegalleryimages:
azure.mgmt.azurestackhci.aio.operations.MarketplacegalleryimagesOperations
:ivar networkinterfaces: NetworkinterfacesOperations operations
:vartype networkinterfaces: azure.mgmt.azurestackhci.aio.operations.NetworkinterfacesOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.azurestackhci.aio.operations.Operations
:ivar storagecontainers: StoragecontainersOperations operations
:vartype storagecontainers: azure.mgmt.azurestackhci.aio.operations.StoragecontainersOperations
:ivar virtualharddisks: VirtualharddisksOperations operations
:vartype virtualharddisks: azure.mgmt.azurestackhci.aio.operations.VirtualharddisksOperations
:ivar virtualmachines: VirtualmachinesOperations operations
:vartype virtualmachines: azure.mgmt.azurestackhci.aio.operations.VirtualmachinesOperations
:ivar hybrid_identity_metadata: HybridIdentityMetadataOperations operations
:vartype hybrid_identity_metadata:
azure.mgmt.azurestackhci.aio.operations.HybridIdentityMetadataOperations
:ivar machine_extensions: MachineExtensionsOperations operations
:vartype machine_extensions:
azure.mgmt.azurestackhci.aio.operations.MachineExtensionsOperations
:ivar guest_agent: GuestAgentOperations operations
:vartype guest_agent: azure.mgmt.azurestackhci.aio.operations.GuestAgentOperations
:ivar guest_agents: GuestAgentsOperations operations
:vartype guest_agents: azure.mgmt.azurestackhci.aio.operations.GuestAgentsOperations
:ivar virtualnetworks: VirtualnetworksOperations operations
:vartype virtualnetworks: azure.mgmt.azurestackhci.aio.operations.VirtualnetworksOperations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
"""
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = AzureStackHCIClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.arc_settings = ArcSettingsOperations(self._client, self._config, self._serialize, self._deserialize)
self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize)
self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize)
self.galleryimages = GalleryimagesOperations(self._client, self._config, self._serialize, self._deserialize)
self.marketplacegalleryimages = MarketplacegalleryimagesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.networkinterfaces = NetworkinterfacesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
self.storagecontainers = StoragecontainersOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.virtualharddisks = VirtualharddisksOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.virtualmachines = VirtualmachinesOperations(self._client, self._config, self._serialize, self._deserialize)
self.hybrid_identity_metadata = HybridIdentityMetadataOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.machine_extensions = MachineExtensionsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.guest_agent = GuestAgentOperations(self._client, self._config, self._serialize, self._deserialize)
self.guest_agents = GuestAgentsOperations(self._client, self._config, self._serialize, self._deserialize)
self.virtualnetworks = VirtualnetworksOperations(self._client, self._config, self._serialize, self._deserialize)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client._send_request(request)
<AsyncHttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.AsyncHttpResponse
"""
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()
async def __aenter__(self) -> "AzureStackHCIClient":
await self._client.__aenter__()
return self
async def __aexit__(self, *exc_details) -> None:
await self._client.__aexit__(*exc_details)
| 0.807916 | 0.142053 |
import sys
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, AsyncARMChallengeAuthenticationPolicy
from .._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class AzureStackHCIClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureStackHCIClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(AzureStackHCIClientConfiguration, self).__init__(**kwargs)
api_version: Literal["2021-09-01-preview"] = kwargs.pop("api_version", "2021-09-01-preview")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-azurestackhci/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/_configuration.py
|
_configuration.py
|
import sys
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, AsyncARMChallengeAuthenticationPolicy
from .._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class AzureStackHCIClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureStackHCIClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(AzureStackHCIClientConfiguration, self).__init__(**kwargs)
api_version: Literal["2021-09-01-preview"] = kwargs.pop("api_version", "2021-09-01-preview")
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-azurestackhci/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
| 0.550607 | 0.087291 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._marketplacegalleryimages_operations import (
build_create_or_update_request,
build_delete_request,
build_get_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class MarketplacegalleryimagesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`marketplacegalleryimages` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def get(
self, resource_group_name: str, marketplacegalleryimages_name: str, **kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Gets marketplacegalleryimages by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: Union[_models.Marketplacegalleryimages, IO],
**kwargs: Any
) -> _models.Marketplacegalleryimages:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(marketplacegalleryimages, (IO, bytes)):
_content = marketplacegalleryimages
else:
_json = self._serialize.body(marketplacegalleryimages, "Marketplacegalleryimages")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: _models.Marketplacegalleryimages,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Marketplacegalleryimages]:
"""Creates or updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Marketplacegalleryimages or the
result of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Marketplacegalleryimages]:
"""Creates or updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Marketplacegalleryimages or the
result of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: Union[_models.Marketplacegalleryimages, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Marketplacegalleryimages]:
"""Creates or updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Is either a model type or a IO type. Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Marketplacegalleryimages or the
result of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
marketplacegalleryimages=marketplacegalleryimages,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, marketplacegalleryimages_name: str, **kwargs: Any
) -> None:
"""Deletes a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@overload
async def update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: _models.MarketplacegalleryimagesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.MarketplacegalleryimagesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: Union[_models.MarketplacegalleryimagesPatch, IO],
**kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Is either a model type or a IO type. Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.MarketplacegalleryimagesPatch
or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(marketplacegalleryimages, (IO, bytes)):
_content = marketplacegalleryimages
else:
_json = self._serialize.body(marketplacegalleryimages, "MarketplacegalleryimagesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.Marketplacegalleryimages"]:
"""Lists all marketplacegalleryimages under the resource group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Marketplacegalleryimages or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MarketplacegalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("MarketplacegalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Marketplacegalleryimages"]:
"""Lists all marketplacegalleryimages under the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Marketplacegalleryimages or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MarketplacegalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("MarketplacegalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_marketplacegalleryimages_operations.py
|
_marketplacegalleryimages_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._marketplacegalleryimages_operations import (
build_create_or_update_request,
build_delete_request,
build_get_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class MarketplacegalleryimagesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`marketplacegalleryimages` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def get(
self, resource_group_name: str, marketplacegalleryimages_name: str, **kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Gets marketplacegalleryimages by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: Union[_models.Marketplacegalleryimages, IO],
**kwargs: Any
) -> _models.Marketplacegalleryimages:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(marketplacegalleryimages, (IO, bytes)):
_content = marketplacegalleryimages
else:
_json = self._serialize.body(marketplacegalleryimages, "Marketplacegalleryimages")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: _models.Marketplacegalleryimages,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Marketplacegalleryimages]:
"""Creates or updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Marketplacegalleryimages or the
result of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Marketplacegalleryimages]:
"""Creates or updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Marketplacegalleryimages or the
result of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: Union[_models.Marketplacegalleryimages, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Marketplacegalleryimages]:
"""Creates or updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Is either a model type or a IO type. Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Marketplacegalleryimages or the
result of cls(response)
:rtype:
~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
marketplacegalleryimages=marketplacegalleryimages,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, marketplacegalleryimages_name: str, **kwargs: Any
) -> None:
"""Deletes a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@overload
async def update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: _models.MarketplacegalleryimagesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.MarketplacegalleryimagesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Required.
:type marketplacegalleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
marketplacegalleryimages_name: str,
marketplacegalleryimages: Union[_models.MarketplacegalleryimagesPatch, IO],
**kwargs: Any
) -> _models.Marketplacegalleryimages:
"""Updates a marketplace gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param marketplacegalleryimages_name: Name of the marketplace gallery image. Required.
:type marketplacegalleryimages_name: str
:param marketplacegalleryimages: Is either a model type or a IO type. Required.
:type marketplacegalleryimages: ~azure.mgmt.azurestackhci.models.MarketplacegalleryimagesPatch
or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Marketplacegalleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Marketplacegalleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Marketplacegalleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(marketplacegalleryimages, (IO, bytes)):
_content = marketplacegalleryimages
else:
_json = self._serialize.body(marketplacegalleryimages, "MarketplacegalleryimagesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
marketplacegalleryimages_name=marketplacegalleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Marketplacegalleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages/{marketplacegalleryimagesName}"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.Marketplacegalleryimages"]:
"""Lists all marketplacegalleryimages under the resource group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Marketplacegalleryimages or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MarketplacegalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("MarketplacegalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Marketplacegalleryimages"]:
"""Lists all marketplacegalleryimages under the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Marketplacegalleryimages or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MarketplacegalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("MarketplacegalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/marketplacegalleryimages"
}
| 0.68458 | 0.105671 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._extensions_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_arc_setting_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class ExtensionsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`extensions` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_arc_setting(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> AsyncIterable["_models.Extension"]:
"""List all Extensions under ArcSetting resource.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Extension or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ExtensionList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_arc_setting_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_arc_setting.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ExtensionList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_arc_setting.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any
) -> _models.Extension:
"""Get particular Arc Extension of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Extension or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Extension
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
async def _create_initial(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> _models.Extension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension, (IO, bytes)):
_content = extension
else:
_json = self._serialize.body(extension, "Extension")
request = build_create_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Extension", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
@overload
async def begin_create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: _models.Extension,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Extension]:
"""Create Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Extension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Extension]:
"""Create Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Extension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Extension]:
"""Create Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Is either a model type or a
IO type. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Extension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_initial(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
extension=extension,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
async def _update_initial(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> _models.Extension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension, (IO, bytes)):
_content = extension
else:
_json = self._serialize.body(extension, "Extension")
request = build_update_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
@overload
async def begin_update(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: _models.Extension,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Extension]:
"""Update Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Extension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_update(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Extension]:
"""Update Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Extension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_update(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Extension]:
"""Update Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Is either a model type or a
IO type. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Extension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._update_initial(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
extension=extension,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "original-uri"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Delete particular Arc Extension of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_extensions_operations.py
|
_extensions_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._extensions_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_arc_setting_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class ExtensionsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`extensions` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_arc_setting(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> AsyncIterable["_models.Extension"]:
"""List all Extensions under ArcSetting resource.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Extension or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ExtensionList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_arc_setting_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_arc_setting.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ExtensionList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_arc_setting.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any
) -> _models.Extension:
"""Get particular Arc Extension of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Extension or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Extension
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
async def _create_initial(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> _models.Extension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension, (IO, bytes)):
_content = extension
else:
_json = self._serialize.body(extension, "Extension")
request = build_create_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Extension", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
@overload
async def begin_create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: _models.Extension,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Extension]:
"""Create Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Extension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Extension]:
"""Create Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Extension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Extension]:
"""Create Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Is either a model type or a
IO type. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Extension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_initial(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
extension=extension,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
async def _update_initial(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> _models.Extension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension, (IO, bytes)):
_content = extension
else:
_json = self._serialize.body(extension, "Extension")
request = build_update_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
@overload
async def begin_update(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: _models.Extension,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Extension]:
"""Update Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Extension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_update(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Extension]:
"""Update Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Required.
:type extension: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Extension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_update(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
extension_name: str,
extension: Union[_models.Extension, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Extension]:
"""Update Extension for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension: Details of the Machine Extension to be created. Is either a model type or a
IO type. Required.
:type extension: ~azure.mgmt.azurestackhci.models.Extension or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Extension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Extension] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._update_initial(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
extension=extension,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Extension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "original-uri"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Delete particular Arc Extension of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
extension_name=extension_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}"
}
| 0.702632 | 0.086478 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._hybrid_identity_metadata_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_virtual_machines_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class HybridIdentityMetadataOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`hybrid_identity_metadata` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@overload
async def create(
self,
resource_group_name: str,
virtual_machine_name: str,
metadata_name: str,
body: Optional[_models.HybridIdentityMetadata] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Implements HybridIdentityMetadata PUT method.
Create Or Update HybridIdentityMetadata.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the hybridIdentityMetadata. Required.
:type metadata_name: str
:param body: Request payload. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def create(
self,
resource_group_name: str,
virtual_machine_name: str,
metadata_name: str,
body: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Implements HybridIdentityMetadata PUT method.
Create Or Update HybridIdentityMetadata.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the hybridIdentityMetadata. Required.
:type metadata_name: str
:param body: Request payload. Default value is None.
:type body: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def create(
self,
resource_group_name: str,
virtual_machine_name: str,
metadata_name: str,
body: Optional[Union[_models.HybridIdentityMetadata, IO]] = None,
**kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Implements HybridIdentityMetadata PUT method.
Create Or Update HybridIdentityMetadata.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the hybridIdentityMetadata. Required.
:type metadata_name: str
:param body: Request payload. Is either a model type or a IO type. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.HybridIdentityMetadata] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(body, (IO, bytes)):
_content = body
else:
if body is not None:
_json = self._serialize.body(body, "HybridIdentityMetadata")
else:
_json = None
request = build_create_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
metadata_name=metadata_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, virtual_machine_name: str, metadata_name: str, **kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Gets HybridIdentityMetadata.
Implements HybridIdentityMetadata GET method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the HybridIdentityMetadata. Required.
:type metadata_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.HybridIdentityMetadata] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
metadata_name=metadata_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtual_machine_name: str, metadata_name: str, **kwargs: Any
) -> None:
"""Deletes an HybridIdentityMetadata.
Implements HybridIdentityMetadata DELETE method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the HybridIdentityMetadata. Required.
:type metadata_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
metadata_name=metadata_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"
}
@distributed_trace
def list_by_virtual_machines(
self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any
) -> AsyncIterable["_models.HybridIdentityMetadata"]:
"""Implements GET HybridIdentityMetadata in a vm.
Returns the list of HybridIdentityMetadata of the given vm.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either HybridIdentityMetadata or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.HybridIdentityMetadata]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.HybridIdentityMetadataList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_virtual_machines_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_virtual_machines.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("HybridIdentityMetadataList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_virtual_machines.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_hybrid_identity_metadata_operations.py
|
_hybrid_identity_metadata_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._hybrid_identity_metadata_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_virtual_machines_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class HybridIdentityMetadataOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`hybrid_identity_metadata` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@overload
async def create(
self,
resource_group_name: str,
virtual_machine_name: str,
metadata_name: str,
body: Optional[_models.HybridIdentityMetadata] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Implements HybridIdentityMetadata PUT method.
Create Or Update HybridIdentityMetadata.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the hybridIdentityMetadata. Required.
:type metadata_name: str
:param body: Request payload. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def create(
self,
resource_group_name: str,
virtual_machine_name: str,
metadata_name: str,
body: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Implements HybridIdentityMetadata PUT method.
Create Or Update HybridIdentityMetadata.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the hybridIdentityMetadata. Required.
:type metadata_name: str
:param body: Request payload. Default value is None.
:type body: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def create(
self,
resource_group_name: str,
virtual_machine_name: str,
metadata_name: str,
body: Optional[Union[_models.HybridIdentityMetadata, IO]] = None,
**kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Implements HybridIdentityMetadata PUT method.
Create Or Update HybridIdentityMetadata.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the hybridIdentityMetadata. Required.
:type metadata_name: str
:param body: Request payload. Is either a model type or a IO type. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.HybridIdentityMetadata] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(body, (IO, bytes)):
_content = body
else:
if body is not None:
_json = self._serialize.body(body, "HybridIdentityMetadata")
else:
_json = None
request = build_create_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
metadata_name=metadata_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, virtual_machine_name: str, metadata_name: str, **kwargs: Any
) -> _models.HybridIdentityMetadata:
"""Gets HybridIdentityMetadata.
Implements HybridIdentityMetadata GET method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the HybridIdentityMetadata. Required.
:type metadata_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: HybridIdentityMetadata or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.HybridIdentityMetadata] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
metadata_name=metadata_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtual_machine_name: str, metadata_name: str, **kwargs: Any
) -> None:
"""Deletes an HybridIdentityMetadata.
Implements HybridIdentityMetadata DELETE method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param metadata_name: Name of the HybridIdentityMetadata. Required.
:type metadata_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
metadata_name=metadata_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"
}
@distributed_trace
def list_by_virtual_machines(
self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any
) -> AsyncIterable["_models.HybridIdentityMetadata"]:
"""Implements GET HybridIdentityMetadata in a vm.
Returns the list of HybridIdentityMetadata of the given vm.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either HybridIdentityMetadata or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.HybridIdentityMetadata]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.HybridIdentityMetadataList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_virtual_machines_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_virtual_machines.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("HybridIdentityMetadataList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_virtual_machines.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/hybridIdentityMetadata"
}
| 0.738198 | 0.087019 |
import sys
from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator_async import distributed_trace_async
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._guest_agent_operations import build_create_request, build_delete_request, build_get_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class GuestAgentOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`guest_agent` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
async def _create_initial(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[Union[_models.GuestAgent, IO]] = None,
**kwargs: Any
) -> _models.GuestAgent:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(body, (IO, bytes)):
_content = body
else:
if body is not None:
_json = self._serialize.body(body, "GuestAgent")
else:
_json = None
request = build_create_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("GuestAgent", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("GuestAgent", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
@overload
async def begin_create(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[_models.GuestAgent] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.GuestAgent]:
"""Implements GuestAgent PUT method.
Create Or Update GuestAgent.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the guestAgents. Required.
:type name: str
:param body: Request payload. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.GuestAgent
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either GuestAgent or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.GuestAgent]:
"""Implements GuestAgent PUT method.
Create Or Update GuestAgent.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the guestAgents. Required.
:type name: str
:param body: Request payload. Default value is None.
:type body: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either GuestAgent or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[Union[_models.GuestAgent, IO]] = None,
**kwargs: Any
) -> AsyncLROPoller[_models.GuestAgent]:
"""Implements GuestAgent PUT method.
Create Or Update GuestAgent.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the guestAgents. Required.
:type name: str
:param body: Request payload. Is either a model type or a IO type. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.GuestAgent or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either GuestAgent or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_initial(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
body=body,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("GuestAgent", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any
) -> _models.GuestAgent:
"""Gets GuestAgent.
Implements GuestAgent GET method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the GuestAgent. Required.
:type name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestAgent or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.GuestAgent
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("GuestAgent", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Deletes an GuestAgent.
Implements GuestAgent DELETE method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the GuestAgent. Required.
:type name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_guest_agent_operations.py
|
_guest_agent_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator_async import distributed_trace_async
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._guest_agent_operations import build_create_request, build_delete_request, build_get_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class GuestAgentOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`guest_agent` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
async def _create_initial(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[Union[_models.GuestAgent, IO]] = None,
**kwargs: Any
) -> _models.GuestAgent:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(body, (IO, bytes)):
_content = body
else:
if body is not None:
_json = self._serialize.body(body, "GuestAgent")
else:
_json = None
request = build_create_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("GuestAgent", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("GuestAgent", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
@overload
async def begin_create(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[_models.GuestAgent] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.GuestAgent]:
"""Implements GuestAgent PUT method.
Create Or Update GuestAgent.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the guestAgents. Required.
:type name: str
:param body: Request payload. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.GuestAgent
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either GuestAgent or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[IO] = None,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.GuestAgent]:
"""Implements GuestAgent PUT method.
Create Or Update GuestAgent.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the guestAgents. Required.
:type name: str
:param body: Request payload. Default value is None.
:type body: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either GuestAgent or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create(
self,
resource_group_name: str,
virtual_machine_name: str,
name: str,
body: Optional[Union[_models.GuestAgent, IO]] = None,
**kwargs: Any
) -> AsyncLROPoller[_models.GuestAgent]:
"""Implements GuestAgent PUT method.
Create Or Update GuestAgent.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the guestAgents. Required.
:type name: str
:param body: Request payload. Is either a model type or a IO type. Default value is None.
:type body: ~azure.mgmt.azurestackhci.models.GuestAgent or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either GuestAgent or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_initial(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
body=body,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("GuestAgent", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any
) -> _models.GuestAgent:
"""Gets GuestAgent.
Implements GuestAgent GET method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the GuestAgent. Required.
:type name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: GuestAgent or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.GuestAgent
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("GuestAgent", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Deletes an GuestAgent.
Implements GuestAgent DELETE method.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:param name: Name of the GuestAgent. Required.
:type name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
name=name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents/{name}"
}
| 0.706798 | 0.066721 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._clusters_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class ClustersOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`clusters` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Cluster"]:
"""List all HCI clusters in a subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Cluster or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Cluster]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ClusterList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/clusters"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Cluster"]:
"""List all HCI clusters in a resource group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Cluster or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Cluster]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ClusterList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters"
}
@distributed_trace_async
async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.Cluster:
"""Get HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Cluster] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Cluster", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
@overload
async def create(
self,
resource_group_name: str,
cluster_name: str,
cluster: _models.Cluster,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Create an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.Cluster
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def create(
self,
resource_group_name: str,
cluster_name: str,
cluster: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Create an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def create(
self, resource_group_name: str, cluster_name: str, cluster: Union[_models.Cluster, IO], **kwargs: Any
) -> _models.Cluster:
"""Create an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Is either a model type or a IO type. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.Cluster or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Cluster] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(cluster, (IO, bytes)):
_content = cluster
else:
_json = self._serialize.body(cluster, "Cluster")
request = build_create_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Cluster", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
@overload
async def update(
self,
resource_group_name: str,
cluster_name: str,
cluster: _models.ClusterPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Update an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.ClusterPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
cluster_name: str,
cluster: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Update an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self, resource_group_name: str, cluster_name: str, cluster: Union[_models.ClusterPatch, IO], **kwargs: Any
) -> _models.Cluster:
"""Update an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Is either a model type or a IO type. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.ClusterPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Cluster] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(cluster, (IO, bytes)):
_content = cluster
else:
_json = self._serialize.body(cluster, "ClusterPatch")
request = build_update_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Cluster", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, cluster_name: str, **kwargs: Any
) -> None:
"""Delete an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_clusters_operations.py
|
_clusters_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._clusters_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class ClustersOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`clusters` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Cluster"]:
"""List all HCI clusters in a subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Cluster or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Cluster]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ClusterList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/clusters"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Cluster"]:
"""List all HCI clusters in a resource group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Cluster or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Cluster]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ClusterList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters"
}
@distributed_trace_async
async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.Cluster:
"""Get HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Cluster] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Cluster", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
@overload
async def create(
self,
resource_group_name: str,
cluster_name: str,
cluster: _models.Cluster,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Create an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.Cluster
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def create(
self,
resource_group_name: str,
cluster_name: str,
cluster: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Create an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def create(
self, resource_group_name: str, cluster_name: str, cluster: Union[_models.Cluster, IO], **kwargs: Any
) -> _models.Cluster:
"""Create an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Is either a model type or a IO type. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.Cluster or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Cluster] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(cluster, (IO, bytes)):
_content = cluster
else:
_json = self._serialize.body(cluster, "Cluster")
request = build_create_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Cluster", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
@overload
async def update(
self,
resource_group_name: str,
cluster_name: str,
cluster: _models.ClusterPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Update an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.ClusterPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
cluster_name: str,
cluster: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Cluster:
"""Update an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Required.
:type cluster: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self, resource_group_name: str, cluster_name: str, cluster: Union[_models.ClusterPatch, IO], **kwargs: Any
) -> _models.Cluster:
"""Update an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param cluster: Details of the HCI cluster. Is either a model type or a IO type. Required.
:type cluster: ~azure.mgmt.azurestackhci.models.ClusterPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Cluster or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Cluster
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Cluster] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(cluster, (IO, bytes)):
_content = cluster
else:
_json = self._serialize.body(cluster, "ClusterPatch")
request = build_update_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Cluster", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, cluster_name: str, **kwargs: Any
) -> None:
"""Delete an HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}"
}
| 0.697712 | 0.089893 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._virtualmachines_operations import (
build_create_or_update_request,
build_delete_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_restart_request,
build_retrieve_request,
build_start_request,
build_stop_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class VirtualmachinesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`virtualmachines` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def retrieve(
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> _models.Virtualmachines:
"""Gets virtual machines by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: Union[_models.Virtualmachines, IO],
**kwargs: Any
) -> _models.Virtualmachines:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualmachines, (IO, bytes)):
_content = virtualmachines
else:
_json = self._serialize.body(virtualmachines, "Virtualmachines")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: _models.Virtualmachines,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualmachines]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.Virtualmachines
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualmachines or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualmachines]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualmachines or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: Union[_models.Virtualmachines, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualmachines]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Is either a model type or a IO type. Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.Virtualmachines or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualmachines or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
virtualmachines=virtualmachines,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
@overload
async def update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: _models.VirtualmachinesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualmachines:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.VirtualmachinesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualmachines:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: Union[_models.VirtualmachinesPatch, IO],
**kwargs: Any
) -> _models.Virtualmachines:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Is either a model type or a IO type. Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.VirtualmachinesPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualmachines, (IO, bytes)):
_content = virtualmachines
else:
_json = self._serialize.body(virtualmachines, "VirtualmachinesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
async def _start_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_start_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._start_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
if cls:
return cls(pipeline_response, None, {})
_start_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/start"
}
@distributed_trace_async
async def begin_start(
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""start.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._start_initial( # type: ignore
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_start.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/start"
}
async def _stop_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_stop_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._stop_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
if cls:
return cls(pipeline_response, None, {})
_stop_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/stop"
}
@distributed_trace_async
async def begin_stop(
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""stop.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._stop_initial( # type: ignore
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_stop.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/stop"
}
async def _restart_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_restart_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._restart_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
if cls:
return cls(pipeline_response, None, {})
_restart_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/restart"
}
@distributed_trace_async
async def begin_restart(
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""restart.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._restart_initial( # type: ignore
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_restart.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/restart"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.Virtualmachines"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualmachines or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualmachinesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualmachinesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Virtualmachines"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualmachines or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualmachinesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualmachinesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualmachines"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_virtualmachines_operations.py
|
_virtualmachines_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._virtualmachines_operations import (
build_create_or_update_request,
build_delete_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_restart_request,
build_retrieve_request,
build_start_request,
build_stop_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class VirtualmachinesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`virtualmachines` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def retrieve(
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> _models.Virtualmachines:
"""Gets virtual machines by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: Union[_models.Virtualmachines, IO],
**kwargs: Any
) -> _models.Virtualmachines:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualmachines, (IO, bytes)):
_content = virtualmachines
else:
_json = self._serialize.body(virtualmachines, "Virtualmachines")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: _models.Virtualmachines,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualmachines]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.Virtualmachines
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualmachines or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualmachines]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualmachines or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: Union[_models.Virtualmachines, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualmachines]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Is either a model type or a IO type. Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.Virtualmachines or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualmachines or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
virtualmachines=virtualmachines,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
@overload
async def update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: _models.VirtualmachinesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualmachines:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.VirtualmachinesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualmachines:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Required.
:type virtualmachines: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
virtualmachines_name: str,
virtualmachines: Union[_models.VirtualmachinesPatch, IO],
**kwargs: Any
) -> _models.Virtualmachines:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:param virtualmachines: Is either a model type or a IO type. Required.
:type virtualmachines: ~azure.mgmt.azurestackhci.models.VirtualmachinesPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualmachines or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualmachines
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualmachines] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualmachines, (IO, bytes)):
_content = virtualmachines
else:
_json = self._serialize.body(virtualmachines, "VirtualmachinesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualmachines", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}"
}
async def _start_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_start_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._start_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
if cls:
return cls(pipeline_response, None, {})
_start_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/start"
}
@distributed_trace_async
async def begin_start(
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""start.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._start_initial( # type: ignore
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_start.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/start"
}
async def _stop_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_stop_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._stop_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
if cls:
return cls(pipeline_response, None, {})
_stop_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/stop"
}
@distributed_trace_async
async def begin_stop(
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""stop.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._stop_initial( # type: ignore
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_stop.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/stop"
}
async def _restart_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_restart_request(
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._restart_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202]:
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)
if cls:
return cls(pipeline_response, None, {})
_restart_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/restart"
}
@distributed_trace_async
async def begin_restart(
self, resource_group_name: str, virtualmachines_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""restart.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualmachines_name: Required.
:type virtualmachines_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._restart_initial( # type: ignore
resource_group_name=resource_group_name,
virtualmachines_name=virtualmachines_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_restart.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines/{virtualmachinesName}/restart"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.Virtualmachines"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualmachines or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualmachinesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualmachinesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualmachines"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Virtualmachines"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualmachines or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Virtualmachines]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualmachinesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualmachinesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualmachines"
}
| 0.66356 | 0.074905 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._virtualharddisks_operations import (
build_create_or_update_request,
build_delete_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_retrieve_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class VirtualharddisksOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`virtualharddisks` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def retrieve(
self, resource_group_name: str, virtualharddisks_name: str, **kwargs: Any
) -> _models.Virtualharddisks:
"""Gets virtualharddisks by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: Union[_models.Virtualharddisks, IO],
**kwargs: Any
) -> _models.Virtualharddisks:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualharddisks, (IO, bytes)):
_content = virtualharddisks
else:
_json = self._serialize.body(virtualharddisks, "Virtualharddisks")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: _models.Virtualharddisks,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualharddisks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualharddisks or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualharddisks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualharddisks or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: Union[_models.Virtualharddisks, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualharddisks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Is either a model type or a IO type. Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.Virtualharddisks or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualharddisks or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
virtualharddisks=virtualharddisks,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualharddisks_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@overload
async def update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: _models.VirtualharddisksPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualharddisks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.VirtualharddisksPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualharddisks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: Union[_models.VirtualharddisksPatch, IO],
**kwargs: Any
) -> _models.Virtualharddisks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Is either a model type or a IO type. Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.VirtualharddisksPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualharddisks, (IO, bytes)):
_content = virtualharddisks
else:
_json = self._serialize.body(virtualharddisks, "VirtualharddisksPatch")
request = build_update_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.Virtualharddisks"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualharddisks or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualharddisksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualharddisksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Virtualharddisks"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualharddisks or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualharddisksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualharddisksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualharddisks"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_virtualharddisks_operations.py
|
_virtualharddisks_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._virtualharddisks_operations import (
build_create_or_update_request,
build_delete_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_retrieve_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class VirtualharddisksOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`virtualharddisks` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def retrieve(
self, resource_group_name: str, virtualharddisks_name: str, **kwargs: Any
) -> _models.Virtualharddisks:
"""Gets virtualharddisks by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: Union[_models.Virtualharddisks, IO],
**kwargs: Any
) -> _models.Virtualharddisks:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualharddisks, (IO, bytes)):
_content = virtualharddisks
else:
_json = self._serialize.body(virtualharddisks, "Virtualharddisks")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: _models.Virtualharddisks,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualharddisks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualharddisks or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualharddisks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualharddisks or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: Union[_models.Virtualharddisks, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualharddisks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Is either a model type or a IO type. Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.Virtualharddisks or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualharddisks or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
virtualharddisks=virtualharddisks,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualharddisks_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@overload
async def update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: _models.VirtualharddisksPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualharddisks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.VirtualharddisksPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualharddisks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Required.
:type virtualharddisks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
virtualharddisks_name: str,
virtualharddisks: Union[_models.VirtualharddisksPatch, IO],
**kwargs: Any
) -> _models.Virtualharddisks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualharddisks_name: Required.
:type virtualharddisks_name: str
:param virtualharddisks: Is either a model type or a IO type. Required.
:type virtualharddisks: ~azure.mgmt.azurestackhci.models.VirtualharddisksPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualharddisks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualharddisks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualharddisks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualharddisks, (IO, bytes)):
_content = virtualharddisks
else:
_json = self._serialize.body(virtualharddisks, "VirtualharddisksPatch")
request = build_update_request(
resource_group_name=resource_group_name,
virtualharddisks_name=virtualharddisks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualharddisks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks/{virtualharddisksName}"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.Virtualharddisks"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualharddisks or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualharddisksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualharddisksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualharddisks"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Virtualharddisks"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualharddisks or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualharddisksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualharddisksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualharddisks"
}
| 0.679817 | 0.069479 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._networkinterfaces_operations import (
build_create_or_update_request,
build_delete_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_retrieve_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class NetworkinterfacesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`networkinterfaces` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def retrieve(
self, resource_group_name: str, networkinterfaces_name: str, **kwargs: Any
) -> _models.Networkinterfaces:
"""Gets network interfaces by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: Union[_models.Networkinterfaces, IO],
**kwargs: Any
) -> _models.Networkinterfaces:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(networkinterfaces, (IO, bytes)):
_content = networkinterfaces
else:
_json = self._serialize.body(networkinterfaces, "Networkinterfaces")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: _models.Networkinterfaces,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Networkinterfaces]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Networkinterfaces or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Networkinterfaces]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Networkinterfaces or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: Union[_models.Networkinterfaces, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Networkinterfaces]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Is either a model type or a IO type. Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.Networkinterfaces or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Networkinterfaces or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
networkinterfaces=networkinterfaces,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, networkinterfaces_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@overload
async def update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: _models.NetworkinterfacesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Networkinterfaces:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.NetworkinterfacesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Networkinterfaces:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: Union[_models.NetworkinterfacesPatch, IO],
**kwargs: Any
) -> _models.Networkinterfaces:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Is either a model type or a IO type. Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.NetworkinterfacesPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(networkinterfaces, (IO, bytes)):
_content = networkinterfaces
else:
_json = self._serialize.body(networkinterfaces, "NetworkinterfacesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.Networkinterfaces"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Networkinterfaces or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.NetworkinterfacesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("NetworkinterfacesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Networkinterfaces"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Networkinterfaces or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.NetworkinterfacesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("NetworkinterfacesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/networkinterfaces"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_networkinterfaces_operations.py
|
_networkinterfaces_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._networkinterfaces_operations import (
build_create_or_update_request,
build_delete_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_retrieve_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class NetworkinterfacesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`networkinterfaces` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def retrieve(
self, resource_group_name: str, networkinterfaces_name: str, **kwargs: Any
) -> _models.Networkinterfaces:
"""Gets network interfaces by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: Union[_models.Networkinterfaces, IO],
**kwargs: Any
) -> _models.Networkinterfaces:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(networkinterfaces, (IO, bytes)):
_content = networkinterfaces
else:
_json = self._serialize.body(networkinterfaces, "Networkinterfaces")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: _models.Networkinterfaces,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Networkinterfaces]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Networkinterfaces or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Networkinterfaces]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Networkinterfaces or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: Union[_models.Networkinterfaces, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Networkinterfaces]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Is either a model type or a IO type. Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.Networkinterfaces or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Networkinterfaces or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
networkinterfaces=networkinterfaces,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, networkinterfaces_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@overload
async def update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: _models.NetworkinterfacesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Networkinterfaces:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.NetworkinterfacesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Networkinterfaces:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Required.
:type networkinterfaces: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
networkinterfaces_name: str,
networkinterfaces: Union[_models.NetworkinterfacesPatch, IO],
**kwargs: Any
) -> _models.Networkinterfaces:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param networkinterfaces_name: Required.
:type networkinterfaces_name: str
:param networkinterfaces: Is either a model type or a IO type. Required.
:type networkinterfaces: ~azure.mgmt.azurestackhci.models.NetworkinterfacesPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Networkinterfaces or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Networkinterfaces
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Networkinterfaces] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(networkinterfaces, (IO, bytes)):
_content = networkinterfaces
else:
_json = self._serialize.body(networkinterfaces, "NetworkinterfacesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
networkinterfaces_name=networkinterfaces_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Networkinterfaces", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces/{networkinterfacesName}"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.Networkinterfaces"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Networkinterfaces or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.NetworkinterfacesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("NetworkinterfacesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkinterfaces"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Networkinterfaces"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Networkinterfaces or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.NetworkinterfacesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("NetworkinterfacesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/networkinterfaces"
}
| 0.693161 | 0.08882 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._arc_settings_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_cluster_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class ArcSettingsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`arc_settings` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_cluster(
self, resource_group_name: str, cluster_name: str, **kwargs: Any
) -> AsyncIterable["_models.ArcSetting"]:
"""Get ArcSetting resources of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either ArcSetting or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.ArcSetting]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ArcSettingList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_cluster_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_cluster.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ArcSettingList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_cluster.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> _models.ArcSetting:
"""Get ArcSetting resource details of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ArcSetting", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
@overload
async def create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
arc_setting: _models.ArcSetting,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ArcSetting:
"""Create ArcSetting for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster.
Required.
:type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSetting
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
arc_setting: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ArcSetting:
"""Create ArcSetting for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster.
Required.
:type arc_setting: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
arc_setting: Union[_models.ArcSetting, IO],
**kwargs: Any
) -> _models.ArcSetting:
"""Create ArcSetting for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster.
Is either a model type or a IO type. Required.
:type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSetting or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(arc_setting, (IO, bytes)):
_content = arc_setting
else:
_json = self._serialize.body(arc_setting, "ArcSetting")
request = build_create_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ArcSetting", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Delete ArcSetting resource details of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_arc_settings_operations.py
|
_arc_settings_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._arc_settings_operations import (
build_create_request,
build_delete_request,
build_get_request,
build_list_by_cluster_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class ArcSettingsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`arc_settings` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_cluster(
self, resource_group_name: str, cluster_name: str, **kwargs: Any
) -> AsyncIterable["_models.ArcSetting"]:
"""Get ArcSetting resources of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either ArcSetting or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.ArcSetting]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ArcSettingList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_cluster_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_cluster.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("ArcSettingList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_cluster.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> _models.ArcSetting:
"""Get ArcSetting resource details of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ArcSetting", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
@overload
async def create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
arc_setting: _models.ArcSetting,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ArcSetting:
"""Create ArcSetting for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster.
Required.
:type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSetting
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
arc_setting: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.ArcSetting:
"""Create ArcSetting for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster.
Required.
:type arc_setting: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def create(
self,
resource_group_name: str,
cluster_name: str,
arc_setting_name: str,
arc_setting: Union[_models.ArcSetting, IO],
**kwargs: Any
) -> _models.ArcSetting:
"""Create ArcSetting for HCI cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster.
Is either a model type or a IO type. Required.
:type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSetting or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ArcSetting or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.ArcSetting
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(arc_setting, (IO, bytes)):
_content = arc_setting
else:
_json = self._serialize.body(arc_setting, "ArcSetting")
request = build_create_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.create.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("ArcSetting", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
create.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""Delete ArcSetting resource details of HCI Cluster.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param cluster_name: The name of the cluster. Required.
:type cluster_name: str
:param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting
information. Required.
:type arc_setting_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
cluster_name=cluster_name,
arc_setting_name=arc_setting_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}"
}
| 0.723407 | 0.081776 |
import sys
from typing import Any, Callable, Dict, Optional, TypeVar
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._operations import build_list_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def list(self, **kwargs: Any) -> _models.OperationListResult:
"""List all available Microsoft.AzureStackHCI provider operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: OperationListResult or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.OperationListResult
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None)
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("OperationListResult", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list.metadata = {"url": "/providers/Microsoft.AzureStackHCI/operations"}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_operations.py
|
_operations.py
|
import sys
from typing import Any, Callable, Dict, Optional, TypeVar
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._operations import build_list_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def list(self, **kwargs: Any) -> _models.OperationListResult:
"""List all available Microsoft.AzureStackHCI provider operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: OperationListResult or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.OperationListResult
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None)
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("OperationListResult", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
list.metadata = {"url": "/providers/Microsoft.AzureStackHCI/operations"}
| 0.650245 | 0.076822 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._guest_agents_operations import build_list_by_virtual_machines_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class GuestAgentsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`guest_agents` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_virtual_machines(
self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any
) -> AsyncIterable["_models.GuestAgent"]:
"""Implements GET GuestAgent in a vm.
Returns the list of GuestAgent of the given vm.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either GuestAgent or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GuestAgentList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_virtual_machines_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_virtual_machines.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("GuestAgentList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_virtual_machines.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_guest_agents_operations.py
|
_guest_agents_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._guest_agents_operations import build_list_by_virtual_machines_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class GuestAgentsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`guest_agents` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_virtual_machines(
self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any
) -> AsyncIterable["_models.GuestAgent"]:
"""Implements GET GuestAgent in a vm.
Returns the list of GuestAgent of the given vm.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtual_machine_name: Name of the vm. Required.
:type virtual_machine_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either GuestAgent or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.GuestAgent]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GuestAgentList] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_virtual_machines_request(
resource_group_name=resource_group_name,
virtual_machine_name=virtual_machine_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_virtual_machines.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("GuestAgentList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_virtual_machines.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{virtualMachineName}/guestAgents"
}
| 0.646349 | 0.087994 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._machine_extensions_operations import (
build_create_or_update_request,
build_delete_request,
build_get_request,
build_list_by_virtual_machines_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class MachineExtensionsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`machine_extensions` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
async def _create_or_update_initial(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtension, IO],
**kwargs: Any
) -> _models.MachineExtension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension_parameters, (IO, bytes)):
_content = extension_parameters
else:
_json = self._serialize.body(extension_parameters, "MachineExtension")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: _models.MachineExtension,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.MachineExtension]:
"""The operation to create or update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtension
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.MachineExtension]:
"""The operation to create or update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtension, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.MachineExtension]:
"""The operation to create or update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is
either a model type or a IO type. Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtension or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
extension_parameters=extension_parameters,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
async def _update_initial(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtensionUpdate, IO],
**kwargs: Any
) -> _models.MachineExtension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension_parameters, (IO, bytes)):
_content = extension_parameters
else:
_json = self._serialize.body(extension_parameters, "MachineExtensionUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@overload
async def begin_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: _models.MachineExtensionUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.MachineExtension]:
"""The operation to update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtensionUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.MachineExtension]:
"""The operation to update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtensionUpdate, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.MachineExtension]:
"""The operation to update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is
either a model type or a IO type. Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtensionUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._update_initial(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
extension_parameters=extension_parameters,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""The operation to delete the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be deleted. Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any
) -> _models.MachineExtension:
"""The operation to get the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine containing the extension. Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: MachineExtension or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.MachineExtension
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@distributed_trace
def list_by_virtual_machines(
self, resource_group_name: str, name: str, expand: Optional[str] = None, **kwargs: Any
) -> AsyncIterable["_models.MachineExtension"]:
"""The operation to get all extensions of a non-Azure machine.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine containing the extension. Required.
:type name: str
:param expand: The expand expression to apply on the operation. Default value is None.
:type expand: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either MachineExtension or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MachineExtensionsListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_virtual_machines_request(
resource_group_name=resource_group_name,
name=name,
subscription_id=self._config.subscription_id,
expand=expand,
api_version=api_version,
template_url=self.list_by_virtual_machines.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("MachineExtensionsListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_virtual_machines.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_machine_extensions_operations.py
|
_machine_extensions_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._machine_extensions_operations import (
build_create_or_update_request,
build_delete_request,
build_get_request,
build_list_by_virtual_machines_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class MachineExtensionsOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`machine_extensions` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
async def _create_or_update_initial(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtension, IO],
**kwargs: Any
) -> _models.MachineExtension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension_parameters, (IO, bytes)):
_content = extension_parameters
else:
_json = self._serialize.body(extension_parameters, "MachineExtension")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: _models.MachineExtension,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.MachineExtension]:
"""The operation to create or update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtension
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.MachineExtension]:
"""The operation to create or update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtension, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.MachineExtension]:
"""The operation to create or update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is
either a model type or a IO type. Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtension or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
extension_parameters=extension_parameters,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
async def _update_initial(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtensionUpdate, IO],
**kwargs: Any
) -> _models.MachineExtension:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(extension_parameters, (IO, bytes)):
_content = extension_parameters
else:
_json = self._serialize.body(extension_parameters, "MachineExtensionUpdate")
request = build_update_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@overload
async def begin_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: _models.MachineExtensionUpdate,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.MachineExtension]:
"""The operation to update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtensionUpdate
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.MachineExtension]:
"""The operation to update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation.
Required.
:type extension_parameters: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_update(
self,
resource_group_name: str,
name: str,
extension_name: str,
extension_parameters: Union[_models.MachineExtensionUpdate, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.MachineExtension]:
"""The operation to update the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be created or updated.
Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is
either a model type or a IO type. Required.
:type extension_parameters: ~azure.mgmt.azurestackhci.models.MachineExtensionUpdate or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either MachineExtension or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._update_initial(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
extension_parameters=extension_parameters,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
async def _delete_initial( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any
) -> None:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self._delete_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 202, 204]:
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)
if cls:
return cls(pipeline_response, None, {})
_delete_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@distributed_trace_async
async def begin_delete(
self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any
) -> AsyncLROPoller[None]:
"""The operation to delete the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine where the extension should be deleted. Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[None]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._delete_initial( # type: ignore
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
api_version=api_version,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
if cls:
return cls(pipeline_response, None, {})
if polling is True:
polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs))
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@distributed_trace_async
async def get(
self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any
) -> _models.MachineExtension:
"""The operation to get the extension.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine containing the extension. Required.
:type name: str
:param extension_name: The name of the machine extension. Required.
:type extension_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: MachineExtension or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.MachineExtension
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MachineExtension] = kwargs.pop("cls", None)
request = build_get_request(
resource_group_name=resource_group_name,
name=name,
extension_name=extension_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("MachineExtension", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions/{extensionName}"
}
@distributed_trace
def list_by_virtual_machines(
self, resource_group_name: str, name: str, expand: Optional[str] = None, **kwargs: Any
) -> AsyncIterable["_models.MachineExtension"]:
"""The operation to get all extensions of a non-Azure machine.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param name: The name of the machine containing the extension. Required.
:type name: str
:param expand: The expand expression to apply on the operation. Default value is None.
:type expand: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either MachineExtension or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.MachineExtension]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.MachineExtensionsListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_virtual_machines_request(
resource_group_name=resource_group_name,
name=name,
subscription_id=self._config.subscription_id,
expand=expand,
api_version=api_version,
template_url=self.list_by_virtual_machines.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("MachineExtensionsListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_virtual_machines.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualMachines/{name}/extensions"
}
| 0.651798 | 0.071591 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._virtualnetworks_operations import (
build_create_or_update_request,
build_delete_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_retrieve_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class VirtualnetworksOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`virtualnetworks` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def retrieve(
self, resource_group_name: str, virtualnetworks_name: str, **kwargs: Any
) -> _models.Virtualnetworks:
"""retrieve.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: Union[_models.Virtualnetworks, IO],
**kwargs: Any
) -> _models.Virtualnetworks:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualnetworks, (IO, bytes)):
_content = virtualnetworks
else:
_json = self._serialize.body(virtualnetworks, "Virtualnetworks")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: _models.Virtualnetworks,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualnetworks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualnetworks or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualnetworks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualnetworks or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: Union[_models.Virtualnetworks, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualnetworks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Is either a model type or a IO type. Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.Virtualnetworks or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualnetworks or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
virtualnetworks=virtualnetworks,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualnetworks_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@overload
async def update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: _models.VirtualnetworksPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualnetworks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.VirtualnetworksPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualnetworks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: Union[_models.VirtualnetworksPatch, IO],
**kwargs: Any
) -> _models.Virtualnetworks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Is either a model type or a IO type. Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.VirtualnetworksPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualnetworks, (IO, bytes)):
_content = virtualnetworks
else:
_json = self._serialize.body(virtualnetworks, "VirtualnetworksPatch")
request = build_update_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.Virtualnetworks"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualnetworks or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualnetworksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualnetworksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Virtualnetworks"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualnetworks or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualnetworksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualnetworksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualnetworks"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_virtualnetworks_operations.py
|
_virtualnetworks_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._virtualnetworks_operations import (
build_create_or_update_request,
build_delete_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_retrieve_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class VirtualnetworksOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`virtualnetworks` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def retrieve(
self, resource_group_name: str, virtualnetworks_name: str, **kwargs: Any
) -> _models.Virtualnetworks:
"""retrieve.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: Union[_models.Virtualnetworks, IO],
**kwargs: Any
) -> _models.Virtualnetworks:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualnetworks, (IO, bytes)):
_content = virtualnetworks
else:
_json = self._serialize.body(virtualnetworks, "Virtualnetworks")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: _models.Virtualnetworks,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualnetworks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualnetworks or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualnetworks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualnetworks or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: Union[_models.Virtualnetworks, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Virtualnetworks]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Is either a model type or a IO type. Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.Virtualnetworks or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Virtualnetworks or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
virtualnetworks=virtualnetworks,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, virtualnetworks_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@overload
async def update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: _models.VirtualnetworksPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualnetworks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.VirtualnetworksPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Virtualnetworks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Required.
:type virtualnetworks: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
virtualnetworks_name: str,
virtualnetworks: Union[_models.VirtualnetworksPatch, IO],
**kwargs: Any
) -> _models.Virtualnetworks:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param virtualnetworks_name: Required.
:type virtualnetworks_name: str
:param virtualnetworks: Is either a model type or a IO type. Required.
:type virtualnetworks: ~azure.mgmt.azurestackhci.models.VirtualnetworksPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Virtualnetworks or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Virtualnetworks
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Virtualnetworks] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(virtualnetworks, (IO, bytes)):
_content = virtualnetworks
else:
_json = self._serialize.body(virtualnetworks, "VirtualnetworksPatch")
request = build_update_request(
resource_group_name=resource_group_name,
virtualnetworks_name=virtualnetworks_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Virtualnetworks", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks/{virtualnetworksName}"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.Virtualnetworks"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualnetworks or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualnetworksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualnetworksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualnetworks"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Virtualnetworks"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Virtualnetworks or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.VirtualnetworksListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("VirtualnetworksListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualnetworks"
}
| 0.674158 | 0.079139 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._galleryimages_operations import (
build_create_or_update_request,
build_delete_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_retrieve_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class GalleryimagesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`galleryimages` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def retrieve(self, resource_group_name: str, galleryimages_name: str, **kwargs: Any) -> _models.Galleryimages:
"""Gets galleryimages by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: Union[_models.Galleryimages, IO],
**kwargs: Any
) -> _models.Galleryimages:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(galleryimages, (IO, bytes)):
_content = galleryimages
else:
_json = self._serialize.body(galleryimages, "Galleryimages")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: _models.Galleryimages,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Galleryimages]:
"""Create or update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.Galleryimages
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Galleryimages or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Galleryimages]:
"""Create or update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Galleryimages or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: Union[_models.Galleryimages, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Galleryimages]:
"""Create or update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Is either a model type or a IO type. Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.Galleryimages or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Galleryimages or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
galleryimages=galleryimages,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, galleryimages_name: str, **kwargs: Any
) -> None:
"""Delete a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@overload
async def update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: _models.GalleryimagesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Galleryimages:
"""Update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.GalleryimagesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Galleryimages:
"""Update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: Union[_models.GalleryimagesPatch, IO],
**kwargs: Any
) -> _models.Galleryimages:
"""Update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Is either a model type or a IO type. Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.GalleryimagesPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(galleryimages, (IO, bytes)):
_content = galleryimages
else:
_json = self._serialize.body(galleryimages, "GalleryimagesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Galleryimages"]:
"""Lists all galleryimages under the resource group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Galleryimages or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("GalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Galleryimages"]:
"""List all galleryimages under the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Galleryimages or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("GalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/galleryimages"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_galleryimages_operations.py
|
_galleryimages_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._galleryimages_operations import (
build_create_or_update_request,
build_delete_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_retrieve_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class GalleryimagesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`galleryimages` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def retrieve(self, resource_group_name: str, galleryimages_name: str, **kwargs: Any) -> _models.Galleryimages:
"""Gets galleryimages by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: Union[_models.Galleryimages, IO],
**kwargs: Any
) -> _models.Galleryimages:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(galleryimages, (IO, bytes)):
_content = galleryimages
else:
_json = self._serialize.body(galleryimages, "Galleryimages")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: _models.Galleryimages,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Galleryimages]:
"""Create or update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.Galleryimages
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Galleryimages or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Galleryimages]:
"""Create or update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Galleryimages or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: Union[_models.Galleryimages, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Galleryimages]:
"""Create or update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Is either a model type or a IO type. Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.Galleryimages or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Galleryimages or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
galleryimages=galleryimages,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, galleryimages_name: str, **kwargs: Any
) -> None:
"""Delete a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@overload
async def update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: _models.GalleryimagesPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Galleryimages:
"""Update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.GalleryimagesPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Galleryimages:
"""Update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Required.
:type galleryimages: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
galleryimages_name: str,
galleryimages: Union[_models.GalleryimagesPatch, IO],
**kwargs: Any
) -> _models.Galleryimages:
"""Update a gallery image.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param galleryimages_name: Name of the gallery image. Required.
:type galleryimages_name: str
:param galleryimages: Is either a model type or a IO type. Required.
:type galleryimages: ~azure.mgmt.azurestackhci.models.GalleryimagesPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Galleryimages or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Galleryimages
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Galleryimages] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(galleryimages, (IO, bytes)):
_content = galleryimages
else:
_json = self._serialize.body(galleryimages, "GalleryimagesPatch")
request = build_update_request(
resource_group_name=resource_group_name,
galleryimages_name=galleryimages_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Galleryimages", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages/{galleryimagesName}"
}
@distributed_trace
def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Galleryimages"]:
"""Lists all galleryimages under the resource group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Galleryimages or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("GalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryimages"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Galleryimages"]:
"""List all galleryimages under the subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Galleryimages or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Galleryimages]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.GalleryimagesListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("GalleryimagesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/galleryimages"
}
| 0.682891 | 0.098729 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._storagecontainers_operations import (
build_create_or_update_request,
build_delete_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_retrieve_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class StoragecontainersOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`storagecontainers` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def retrieve(
self, resource_group_name: str, storagecontainers_name: str, **kwargs: Any
) -> _models.Storagecontainers:
"""Gets storagecontainers by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: Union[_models.Storagecontainers, IO],
**kwargs: Any
) -> _models.Storagecontainers:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(storagecontainers, (IO, bytes)):
_content = storagecontainers
else:
_json = self._serialize.body(storagecontainers, "Storagecontainers")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: _models.Storagecontainers,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Storagecontainers]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.Storagecontainers
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Storagecontainers or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Storagecontainers]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Storagecontainers or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: Union[_models.Storagecontainers, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Storagecontainers]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Is either a model type or a IO type. Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.Storagecontainers or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Storagecontainers or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
storagecontainers=storagecontainers,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, storagecontainers_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@overload
async def update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: _models.StoragecontainersPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Storagecontainers:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.StoragecontainersPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Storagecontainers:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: Union[_models.StoragecontainersPatch, IO],
**kwargs: Any
) -> _models.Storagecontainers:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Is either a model type or a IO type. Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.StoragecontainersPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(storagecontainers, (IO, bytes)):
_content = storagecontainers
else:
_json = self._serialize.body(storagecontainers, "StoragecontainersPatch")
request = build_update_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.Storagecontainers"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Storagecontainers or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.StoragecontainersListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("StoragecontainersListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Storagecontainers"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Storagecontainers or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.StoragecontainersListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("StoragecontainersListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/storagecontainers"
}
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/aio/operations/_storagecontainers_operations.py
|
_storagecontainers_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._storagecontainers_operations import (
build_create_or_update_request,
build_delete_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_retrieve_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class StoragecontainersOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s
:attr:`storagecontainers` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace_async
async def retrieve(
self, resource_group_name: str, storagecontainers_name: str, **kwargs: Any
) -> _models.Storagecontainers:
"""Gets storagecontainers by resource name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
request = build_retrieve_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.retrieve.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
retrieve.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
async def _create_or_update_initial(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: Union[_models.Storagecontainers, IO],
**kwargs: Any
) -> _models.Storagecontainers:
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(storagecontainers, (IO, bytes)):
_content = storagecontainers
else:
_json = self._serialize.body(storagecontainers, "Storagecontainers")
request = build_create_or_update_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self._create_or_update_initial.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
_create_or_update_initial.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: _models.Storagecontainers,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Storagecontainers]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.Storagecontainers
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Storagecontainers or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def begin_create_or_update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> AsyncLROPoller[_models.Storagecontainers]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Storagecontainers or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def begin_create_or_update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: Union[_models.Storagecontainers, IO],
**kwargs: Any
) -> AsyncLROPoller[_models.Storagecontainers]:
"""create_or_update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Is either a model type or a IO type. Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.Storagecontainers or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:keyword str continuation_token: A continuation token to restart a poller from a saved state.
:keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for
this operation to not poll, or pass in your own initialized polling object for a personal
polling strategy.
:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
:return: An instance of AsyncLROPoller that returns either Storagecontainers or the result of
cls(response)
:rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._create_or_update_initial(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
storagecontainers=storagecontainers,
api_version=api_version,
content_type=content_type,
cls=lambda x, y, z: x,
headers=_headers,
params=_params,
**kwargs
)
kwargs.pop("error_map", None)
def get_long_running_output(pipeline_response):
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod,
AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs),
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller.from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore
begin_create_or_update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@distributed_trace_async
async def delete( # pylint: disable=inconsistent-return-statements
self, resource_group_name: str, storagecontainers_name: str, **kwargs: Any
) -> None:
"""delete.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: None or the result of cls(response)
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[None] = kwargs.pop("cls", None)
request = build_delete_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.delete.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 204]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if cls:
return cls(pipeline_response, None, {})
delete.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@overload
async def update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: _models.StoragecontainersPatch,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Storagecontainers:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.StoragecontainersPatch
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.Storagecontainers:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Required.
:type storagecontainers: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
storagecontainers_name: str,
storagecontainers: Union[_models.StoragecontainersPatch, IO],
**kwargs: Any
) -> _models.Storagecontainers:
"""update.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param storagecontainers_name: Required.
:type storagecontainers_name: str
:param storagecontainers: Is either a model type or a IO type. Required.
:type storagecontainers: ~azure.mgmt.azurestackhci.models.StoragecontainersPatch or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: Storagecontainers or the result of cls(response)
:rtype: ~azure.mgmt.azurestackhci.models.Storagecontainers
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[_models.Storagecontainers] = kwargs.pop("cls", None)
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(storagecontainers, (IO, bytes)):
_content = storagecontainers
else:
_json = self._serialize.body(storagecontainers, "StoragecontainersPatch")
request = build_update_request(
resource_group_name=resource_group_name,
storagecontainers_name=storagecontainers_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response
if response.status_code not in [200, 201]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
if response.status_code == 200:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if response.status_code == 201:
deserialized = self._deserialize("Storagecontainers", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
return deserialized # type: ignore
update.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers/{storagecontainersName}"
}
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.Storagecontainers"]:
"""list_by_resource_group.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Storagecontainers or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.StoragecontainersListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("StoragecontainersListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {
"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storagecontainers"
}
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Storagecontainers"]:
"""list_by_subscription.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Storagecontainers or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Storagecontainers]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version: Literal["2021-09-01-preview"] = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
)
cls: ClsType[_models.StoragecontainersListResult] = kwargs.pop("cls", None)
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url)
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
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("StoragecontainersListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem) # type: ignore
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {
"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/storagecontainers"
}
| 0.678647 | 0.085327 |
import datetime
import sys
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union
from .. import _serialization
if sys.version_info >= (3, 9):
from collections.abc import MutableMapping
else:
from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from .. import models as _models
JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object
class Resource(_serialization.Model):
"""Common fields that are returned in the response for all Azure Resource Manager resources.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.id = None
self.name = None
self.type = None
class ProxyResource(Resource):
"""The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
class ArcSetting(ProxyResource): # pylint: disable=too-many-instance-attributes
"""ArcSetting details.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar provisioning_state: Provisioning state of the ArcSetting proxy resource. Known values
are: "Succeeded", "Failed", "Canceled", "Accepted", and "Provisioning".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState
:ivar arc_instance_resource_group: The resource group that hosts the Arc agents, ie. Hybrid
Compute Machine resources.
:vartype arc_instance_resource_group: str
:ivar aggregate_state: Aggregate state of Arc agent across the nodes in this HCI cluster. Known
values are: "NotSpecified", "Error", "Succeeded", "Canceled", "Failed", "Connected",
"Disconnected", "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded",
"PartiallyConnected", and "InProgress".
:vartype aggregate_state: str or ~azure.mgmt.azurestackhci.models.ArcSettingAggregateState
:ivar per_node_details: State of Arc agent in each of the nodes.
:vartype per_node_details: list[~azure.mgmt.azurestackhci.models.PerNodeState]
:ivar created_by: The identity that created the resource.
:vartype created_by: str
:ivar created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:vartype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar created_at: The timestamp of resource creation (UTC).
:vartype created_at: ~datetime.datetime
:ivar last_modified_by: The identity that last modified the resource.
:vartype last_modified_by: str
:ivar last_modified_by_type: The type of identity that last modified the resource. Known values
are: "User", "Application", "ManagedIdentity", and "Key".
:vartype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar last_modified_at: The timestamp of resource last modification (UTC).
:vartype last_modified_at: ~datetime.datetime
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"provisioning_state": {"readonly": True},
"arc_instance_resource_group": {"readonly": True},
"aggregate_state": {"readonly": True},
"per_node_details": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"arc_instance_resource_group": {"key": "properties.arcInstanceResourceGroup", "type": "str"},
"aggregate_state": {"key": "properties.aggregateState", "type": "str"},
"per_node_details": {"key": "properties.perNodeDetails", "type": "[PerNodeState]"},
"created_by": {"key": "systemData.createdBy", "type": "str"},
"created_by_type": {"key": "systemData.createdByType", "type": "str"},
"created_at": {"key": "systemData.createdAt", "type": "iso-8601"},
"last_modified_by": {"key": "systemData.lastModifiedBy", "type": "str"},
"last_modified_by_type": {"key": "systemData.lastModifiedByType", "type": "str"},
"last_modified_at": {"key": "systemData.lastModifiedAt", "type": "iso-8601"},
}
def __init__(
self,
*,
created_by: Optional[str] = None,
created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
created_at: Optional[datetime.datetime] = None,
last_modified_by: Optional[str] = None,
last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
last_modified_at: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword created_by: The identity that created the resource.
:paramtype created_by: str
:keyword created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:paramtype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword created_at: The timestamp of resource creation (UTC).
:paramtype created_at: ~datetime.datetime
:keyword last_modified_by: The identity that last modified the resource.
:paramtype last_modified_by: str
:keyword last_modified_by_type: The type of identity that last modified the resource. Known
values are: "User", "Application", "ManagedIdentity", and "Key".
:paramtype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword last_modified_at: The timestamp of resource last modification (UTC).
:paramtype last_modified_at: ~datetime.datetime
"""
super().__init__(**kwargs)
self.provisioning_state = None
self.arc_instance_resource_group = None
self.aggregate_state = None
self.per_node_details = None
self.created_by = created_by
self.created_by_type = created_by_type
self.created_at = created_at
self.last_modified_by = last_modified_by
self.last_modified_by_type = last_modified_by_type
self.last_modified_at = last_modified_at
class ArcSettingList(_serialization.Model):
"""List of ArcSetting proxy resources for the HCI cluster.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of ArcSetting proxy resources.
:vartype value: list[~azure.mgmt.azurestackhci.models.ArcSetting]
:ivar next_link: Link to the next set of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[ArcSetting]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class TrackedResource(Resource):
"""The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
}
def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
"""
super().__init__(**kwargs)
self.tags = tags
self.location = location
class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes
"""Cluster details.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar provisioning_state: Provisioning state. Known values are: "Succeeded", "Failed",
"Canceled", "Accepted", and "Provisioning".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState
:ivar status: Status of the cluster agent. Known values are: "NotYetRegistered",
"ConnectedRecently", "NotConnectedRecently", "Disconnected", and "Error".
:vartype status: str or ~azure.mgmt.azurestackhci.models.Status
:ivar cloud_id: Unique, immutable resource id.
:vartype cloud_id: str
:ivar cloud_management_endpoint: Endpoint configured for management from the Azure portal.
:vartype cloud_management_endpoint: str
:ivar aad_client_id: App id of cluster AAD identity.
:vartype aad_client_id: str
:ivar aad_tenant_id: Tenant id of cluster AAD identity.
:vartype aad_tenant_id: str
:ivar desired_properties: Desired properties of the cluster.
:vartype desired_properties: ~azure.mgmt.azurestackhci.models.ClusterDesiredProperties
:ivar reported_properties: Properties reported by cluster agent.
:vartype reported_properties: ~azure.mgmt.azurestackhci.models.ClusterReportedProperties
:ivar trial_days_remaining: Number of days remaining in the trial period.
:vartype trial_days_remaining: float
:ivar billing_model: Type of billing applied to the resource.
:vartype billing_model: str
:ivar registration_timestamp: First cluster sync timestamp.
:vartype registration_timestamp: ~datetime.datetime
:ivar last_sync_timestamp: Most recent cluster sync timestamp.
:vartype last_sync_timestamp: ~datetime.datetime
:ivar last_billing_timestamp: Most recent billing meter timestamp.
:vartype last_billing_timestamp: ~datetime.datetime
:ivar created_by: The identity that created the resource.
:vartype created_by: str
:ivar created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:vartype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar created_at: The timestamp of resource creation (UTC).
:vartype created_at: ~datetime.datetime
:ivar last_modified_by: The identity that last modified the resource.
:vartype last_modified_by: str
:ivar last_modified_by_type: The type of identity that last modified the resource. Known values
are: "User", "Application", "ManagedIdentity", and "Key".
:vartype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar last_modified_at: The timestamp of resource last modification (UTC).
:vartype last_modified_at: ~datetime.datetime
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
"cloud_id": {"readonly": True},
"reported_properties": {"readonly": True},
"trial_days_remaining": {"readonly": True},
"billing_model": {"readonly": True},
"registration_timestamp": {"readonly": True},
"last_sync_timestamp": {"readonly": True},
"last_billing_timestamp": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"status": {"key": "properties.status", "type": "str"},
"cloud_id": {"key": "properties.cloudId", "type": "str"},
"cloud_management_endpoint": {"key": "properties.cloudManagementEndpoint", "type": "str"},
"aad_client_id": {"key": "properties.aadClientId", "type": "str"},
"aad_tenant_id": {"key": "properties.aadTenantId", "type": "str"},
"desired_properties": {"key": "properties.desiredProperties", "type": "ClusterDesiredProperties"},
"reported_properties": {"key": "properties.reportedProperties", "type": "ClusterReportedProperties"},
"trial_days_remaining": {"key": "properties.trialDaysRemaining", "type": "float"},
"billing_model": {"key": "properties.billingModel", "type": "str"},
"registration_timestamp": {"key": "properties.registrationTimestamp", "type": "iso-8601"},
"last_sync_timestamp": {"key": "properties.lastSyncTimestamp", "type": "iso-8601"},
"last_billing_timestamp": {"key": "properties.lastBillingTimestamp", "type": "iso-8601"},
"created_by": {"key": "systemData.createdBy", "type": "str"},
"created_by_type": {"key": "systemData.createdByType", "type": "str"},
"created_at": {"key": "systemData.createdAt", "type": "iso-8601"},
"last_modified_by": {"key": "systemData.lastModifiedBy", "type": "str"},
"last_modified_by_type": {"key": "systemData.lastModifiedByType", "type": "str"},
"last_modified_at": {"key": "systemData.lastModifiedAt", "type": "iso-8601"},
}
def __init__( # pylint: disable=too-many-locals
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
cloud_management_endpoint: Optional[str] = None,
aad_client_id: Optional[str] = None,
aad_tenant_id: Optional[str] = None,
desired_properties: Optional["_models.ClusterDesiredProperties"] = None,
created_by: Optional[str] = None,
created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
created_at: Optional[datetime.datetime] = None,
last_modified_by: Optional[str] = None,
last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
last_modified_at: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword cloud_management_endpoint: Endpoint configured for management from the Azure portal.
:paramtype cloud_management_endpoint: str
:keyword aad_client_id: App id of cluster AAD identity.
:paramtype aad_client_id: str
:keyword aad_tenant_id: Tenant id of cluster AAD identity.
:paramtype aad_tenant_id: str
:keyword desired_properties: Desired properties of the cluster.
:paramtype desired_properties: ~azure.mgmt.azurestackhci.models.ClusterDesiredProperties
:keyword created_by: The identity that created the resource.
:paramtype created_by: str
:keyword created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:paramtype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword created_at: The timestamp of resource creation (UTC).
:paramtype created_at: ~datetime.datetime
:keyword last_modified_by: The identity that last modified the resource.
:paramtype last_modified_by: str
:keyword last_modified_by_type: The type of identity that last modified the resource. Known
values are: "User", "Application", "ManagedIdentity", and "Key".
:paramtype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword last_modified_at: The timestamp of resource last modification (UTC).
:paramtype last_modified_at: ~datetime.datetime
"""
super().__init__(tags=tags, location=location, **kwargs)
self.provisioning_state = None
self.status = None
self.cloud_id = None
self.cloud_management_endpoint = cloud_management_endpoint
self.aad_client_id = aad_client_id
self.aad_tenant_id = aad_tenant_id
self.desired_properties = desired_properties
self.reported_properties = None
self.trial_days_remaining = None
self.billing_model = None
self.registration_timestamp = None
self.last_sync_timestamp = None
self.last_billing_timestamp = None
self.created_by = created_by
self.created_by_type = created_by_type
self.created_at = created_at
self.last_modified_by = last_modified_by
self.last_modified_by_type = last_modified_by_type
self.last_modified_at = last_modified_at
class ClusterDesiredProperties(_serialization.Model):
"""Desired properties of the cluster.
:ivar windows_server_subscription: Desired state of Windows Server Subscription. Known values
are: "Disabled" and "Enabled".
:vartype windows_server_subscription: str or
~azure.mgmt.azurestackhci.models.WindowsServerSubscription
:ivar diagnostic_level: Desired level of diagnostic data emitted by the cluster. Known values
are: "Off", "Basic", and "Enhanced".
:vartype diagnostic_level: str or ~azure.mgmt.azurestackhci.models.DiagnosticLevel
"""
_attribute_map = {
"windows_server_subscription": {"key": "windowsServerSubscription", "type": "str"},
"diagnostic_level": {"key": "diagnosticLevel", "type": "str"},
}
def __init__(
self,
*,
windows_server_subscription: Optional[Union[str, "_models.WindowsServerSubscription"]] = None,
diagnostic_level: Optional[Union[str, "_models.DiagnosticLevel"]] = None,
**kwargs
):
"""
:keyword windows_server_subscription: Desired state of Windows Server Subscription. Known
values are: "Disabled" and "Enabled".
:paramtype windows_server_subscription: str or
~azure.mgmt.azurestackhci.models.WindowsServerSubscription
:keyword diagnostic_level: Desired level of diagnostic data emitted by the cluster. Known
values are: "Off", "Basic", and "Enhanced".
:paramtype diagnostic_level: str or ~azure.mgmt.azurestackhci.models.DiagnosticLevel
"""
super().__init__(**kwargs)
self.windows_server_subscription = windows_server_subscription
self.diagnostic_level = diagnostic_level
class ClusterList(_serialization.Model):
"""List of clusters.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of clusters.
:vartype value: list[~azure.mgmt.azurestackhci.models.Cluster]
:ivar next_link: Link to the next set of results.
:vartype next_link: str
"""
_validation = {
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[Cluster]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, *, value: Optional[List["_models.Cluster"]] = None, **kwargs):
"""
:keyword value: List of clusters.
:paramtype value: list[~azure.mgmt.azurestackhci.models.Cluster]
"""
super().__init__(**kwargs)
self.value = value
self.next_link = None
class ClusterNode(_serialization.Model):
"""Cluster node details.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Name of the cluster node.
:vartype name: str
:ivar id: Id of the node in the cluster.
:vartype id: float
:ivar windows_server_subscription: State of Windows Server Subscription. Known values are:
"Disabled" and "Enabled".
:vartype windows_server_subscription: str or
~azure.mgmt.azurestackhci.models.WindowsServerSubscription
:ivar manufacturer: Manufacturer of the cluster node hardware.
:vartype manufacturer: str
:ivar model: Model name of the cluster node hardware.
:vartype model: str
:ivar os_name: Operating system running on the cluster node.
:vartype os_name: str
:ivar os_version: Version of the operating system running on the cluster node.
:vartype os_version: str
:ivar serial_number: Immutable id of the cluster node.
:vartype serial_number: str
:ivar core_count: Number of physical cores on the cluster node.
:vartype core_count: float
:ivar memory_in_gi_b: Total available memory on the cluster node (in GiB).
:vartype memory_in_gi_b: float
"""
_validation = {
"name": {"readonly": True},
"id": {"readonly": True},
"windows_server_subscription": {"readonly": True},
"manufacturer": {"readonly": True},
"model": {"readonly": True},
"os_name": {"readonly": True},
"os_version": {"readonly": True},
"serial_number": {"readonly": True},
"core_count": {"readonly": True},
"memory_in_gi_b": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"id": {"key": "id", "type": "float"},
"windows_server_subscription": {"key": "windowsServerSubscription", "type": "str"},
"manufacturer": {"key": "manufacturer", "type": "str"},
"model": {"key": "model", "type": "str"},
"os_name": {"key": "osName", "type": "str"},
"os_version": {"key": "osVersion", "type": "str"},
"serial_number": {"key": "serialNumber", "type": "str"},
"core_count": {"key": "coreCount", "type": "float"},
"memory_in_gi_b": {"key": "memoryInGiB", "type": "float"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.name = None
self.id = None
self.windows_server_subscription = None
self.manufacturer = None
self.model = None
self.os_name = None
self.os_version = None
self.serial_number = None
self.core_count = None
self.memory_in_gi_b = None
class ClusterPatch(_serialization.Model):
"""Cluster details to update.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar cloud_management_endpoint: Endpoint configured for management from the Azure portal.
:vartype cloud_management_endpoint: str
:ivar aad_client_id: App id of cluster AAD identity.
:vartype aad_client_id: str
:ivar aad_tenant_id: Tenant id of cluster AAD identity.
:vartype aad_tenant_id: str
:ivar desired_properties: Desired properties of the cluster.
:vartype desired_properties: ~azure.mgmt.azurestackhci.models.ClusterDesiredProperties
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
"cloud_management_endpoint": {"key": "properties.cloudManagementEndpoint", "type": "str"},
"aad_client_id": {"key": "properties.aadClientId", "type": "str"},
"aad_tenant_id": {"key": "properties.aadTenantId", "type": "str"},
"desired_properties": {"key": "properties.desiredProperties", "type": "ClusterDesiredProperties"},
}
def __init__(
self,
*,
tags: Optional[Dict[str, str]] = None,
cloud_management_endpoint: Optional[str] = None,
aad_client_id: Optional[str] = None,
aad_tenant_id: Optional[str] = None,
desired_properties: Optional["_models.ClusterDesiredProperties"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword cloud_management_endpoint: Endpoint configured for management from the Azure portal.
:paramtype cloud_management_endpoint: str
:keyword aad_client_id: App id of cluster AAD identity.
:paramtype aad_client_id: str
:keyword aad_tenant_id: Tenant id of cluster AAD identity.
:paramtype aad_tenant_id: str
:keyword desired_properties: Desired properties of the cluster.
:paramtype desired_properties: ~azure.mgmt.azurestackhci.models.ClusterDesiredProperties
"""
super().__init__(**kwargs)
self.tags = tags
self.cloud_management_endpoint = cloud_management_endpoint
self.aad_client_id = aad_client_id
self.aad_tenant_id = aad_tenant_id
self.desired_properties = desired_properties
class ClusterReportedProperties(_serialization.Model):
"""Properties reported by cluster agent.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar cluster_name: Name of the on-prem cluster connected to this resource.
:vartype cluster_name: str
:ivar cluster_id: Unique id generated by the on-prem cluster.
:vartype cluster_id: str
:ivar cluster_version: Version of the cluster software.
:vartype cluster_version: str
:ivar nodes: List of nodes reported by the cluster.
:vartype nodes: list[~azure.mgmt.azurestackhci.models.ClusterNode]
:ivar last_updated: Last time the cluster reported the data.
:vartype last_updated: ~datetime.datetime
:ivar imds_attestation: IMDS attestation status of the cluster. Known values are: "Disabled"
and "Enabled".
:vartype imds_attestation: str or ~azure.mgmt.azurestackhci.models.ImdsAttestation
:ivar diagnostic_level: Level of diagnostic data emitted by the cluster. Known values are:
"Off", "Basic", and "Enhanced".
:vartype diagnostic_level: str or ~azure.mgmt.azurestackhci.models.DiagnosticLevel
"""
_validation = {
"cluster_name": {"readonly": True},
"cluster_id": {"readonly": True},
"cluster_version": {"readonly": True},
"nodes": {"readonly": True},
"last_updated": {"readonly": True},
"imds_attestation": {"readonly": True},
}
_attribute_map = {
"cluster_name": {"key": "clusterName", "type": "str"},
"cluster_id": {"key": "clusterId", "type": "str"},
"cluster_version": {"key": "clusterVersion", "type": "str"},
"nodes": {"key": "nodes", "type": "[ClusterNode]"},
"last_updated": {"key": "lastUpdated", "type": "iso-8601"},
"imds_attestation": {"key": "imdsAttestation", "type": "str"},
"diagnostic_level": {"key": "diagnosticLevel", "type": "str"},
}
def __init__(self, *, diagnostic_level: Optional[Union[str, "_models.DiagnosticLevel"]] = None, **kwargs):
"""
:keyword diagnostic_level: Level of diagnostic data emitted by the cluster. Known values are:
"Off", "Basic", and "Enhanced".
:paramtype diagnostic_level: str or ~azure.mgmt.azurestackhci.models.DiagnosticLevel
"""
super().__init__(**kwargs)
self.cluster_name = None
self.cluster_id = None
self.cluster_version = None
self.nodes = None
self.last_updated = None
self.imds_attestation = None
self.diagnostic_level = diagnostic_level
class ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable(_serialization.Model):
"""RouteTable for the subnet.
:ivar id: Etag - Gets a unique read-only string that changes whenever the resource is updated.
:vartype id: str
:ivar name: Name - READ-ONLY; Resource name.
:vartype name: str
:ivar type: Type - READ-ONLY; Resource type.
:vartype type: str
:ivar routes: Routes - Collection of routes contained within a route table.
:vartype routes:
list[~azure.mgmt.azurestackhci.models.VirtualnetworksPropertiesSubnetsPropertiesItemsItem]
"""
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"routes": {"key": "properties.routes", "type": "[VirtualnetworksPropertiesSubnetsPropertiesItemsItem]"},
}
def __init__(
self,
*,
id: Optional[str] = None, # pylint: disable=redefined-builtin
name: Optional[str] = None,
type: Optional[str] = None,
routes: Optional[List["_models.VirtualnetworksPropertiesSubnetsPropertiesItemsItem"]] = None,
**kwargs
):
"""
:keyword id: Etag - Gets a unique read-only string that changes whenever the resource is
updated.
:paramtype id: str
:keyword name: Name - READ-ONLY; Resource name.
:paramtype name: str
:keyword type: Type - READ-ONLY; Resource type.
:paramtype type: str
:keyword routes: Routes - Collection of routes contained within a route table.
:paramtype routes:
list[~azure.mgmt.azurestackhci.models.VirtualnetworksPropertiesSubnetsPropertiesItemsItem]
"""
super().__init__(**kwargs)
self.id = id
self.name = name
self.type = type
self.routes = routes
class ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems(
_serialization.Model
):
"""IPConfigurationReference - Describes a IPConfiguration under the virtual network.
:ivar id: IPConfigurationID.
:vartype id: str
"""
_attribute_map = {
"id": {"key": "ID", "type": "str"},
}
def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin
"""
:keyword id: IPConfigurationID.
:paramtype id: str
"""
super().__init__(**kwargs)
self.id = id
class ErrorAdditionalInfo(_serialization.Model):
"""The resource management error additional info.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar type: The additional info type.
:vartype type: str
:ivar info: The additional info.
:vartype info: JSON
"""
_validation = {
"type": {"readonly": True},
"info": {"readonly": True},
}
_attribute_map = {
"type": {"key": "type", "type": "str"},
"info": {"key": "info", "type": "object"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.type = None
self.info = None
class ErrorDetail(_serialization.Model):
"""The error detail.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: The error code.
:vartype code: str
:ivar message: The error message.
:vartype message: str
:ivar target: The error target.
:vartype target: str
:ivar details: The error details.
:vartype details: list[~azure.mgmt.azurestackhci.models.ErrorDetail]
:ivar additional_info: The error additional info.
:vartype additional_info: list[~azure.mgmt.azurestackhci.models.ErrorAdditionalInfo]
"""
_validation = {
"code": {"readonly": True},
"message": {"readonly": True},
"target": {"readonly": True},
"details": {"readonly": True},
"additional_info": {"readonly": True},
}
_attribute_map = {
"code": {"key": "code", "type": "str"},
"message": {"key": "message", "type": "str"},
"target": {"key": "target", "type": "str"},
"details": {"key": "details", "type": "[ErrorDetail]"},
"additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.code = None
self.message = None
self.target = None
self.details = None
self.additional_info = None
class ErrorResponse(_serialization.Model):
"""Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).
:ivar error: The error object.
:vartype error: ~azure.mgmt.azurestackhci.models.ErrorDetail
"""
_attribute_map = {
"error": {"key": "error", "type": "ErrorDetail"},
}
def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs):
"""
:keyword error: The error object.
:paramtype error: ~azure.mgmt.azurestackhci.models.ErrorDetail
"""
super().__init__(**kwargs)
self.error = error
class ExtendedLocation(_serialization.Model):
"""The complex type of the extended location.
:ivar name: The name of the extended location.
:vartype name: str
:ivar type: The type of the extended location. "CustomLocation"
:vartype type: str or ~azure.mgmt.azurestackhci.models.ExtendedLocationTypes
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
}
def __init__(
self,
*,
name: Optional[str] = None,
type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None,
**kwargs
):
"""
:keyword name: The name of the extended location.
:paramtype name: str
:keyword type: The type of the extended location. "CustomLocation"
:paramtype type: str or ~azure.mgmt.azurestackhci.models.ExtendedLocationTypes
"""
super().__init__(**kwargs)
self.name = name
self.type = type
class Extension(ProxyResource): # pylint: disable=too-many-instance-attributes
"""Details of a particular extension in HCI Cluster.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar provisioning_state: Provisioning state of the Extension proxy resource. Known values are:
"Succeeded", "Failed", "Canceled", "Accepted", and "Provisioning".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState
:ivar aggregate_state: Aggregate state of Arc Extensions across the nodes in this HCI cluster.
Known values are: "NotSpecified", "Error", "Succeeded", "Canceled", "Failed", "Connected",
"Disconnected", "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded",
"PartiallyConnected", and "InProgress".
:vartype aggregate_state: str or ~azure.mgmt.azurestackhci.models.ExtensionAggregateState
:ivar per_node_extension_details: State of Arc Extension in each of the nodes.
:vartype per_node_extension_details:
list[~azure.mgmt.azurestackhci.models.PerNodeExtensionState]
:ivar force_update_tag: How the extension handler should be forced to update even if the
extension configuration has not changed.
:vartype force_update_tag: str
:ivar publisher: The name of the extension handler publisher.
:vartype publisher: str
:ivar type_properties_extension_parameters_type: Specifies the type of the extension; an
example is "CustomScriptExtension".
:vartype type_properties_extension_parameters_type: str
:ivar type_handler_version: Specifies the version of the script handler.
:vartype type_handler_version: str
:ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor
version if one is available at deployment time. Once deployed, however, the extension will not
upgrade minor versions unless redeployed, even with this property set to true.
:vartype auto_upgrade_minor_version: bool
:ivar settings: Json formatted public settings for the extension.
:vartype settings: JSON
:ivar protected_settings: Protected settings (may contain secrets).
:vartype protected_settings: JSON
:ivar created_by: The identity that created the resource.
:vartype created_by: str
:ivar created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:vartype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar created_at: The timestamp of resource creation (UTC).
:vartype created_at: ~datetime.datetime
:ivar last_modified_by: The identity that last modified the resource.
:vartype last_modified_by: str
:ivar last_modified_by_type: The type of identity that last modified the resource. Known values
are: "User", "Application", "ManagedIdentity", and "Key".
:vartype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar last_modified_at: The timestamp of resource last modification (UTC).
:vartype last_modified_at: ~datetime.datetime
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"provisioning_state": {"readonly": True},
"aggregate_state": {"readonly": True},
"per_node_extension_details": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"aggregate_state": {"key": "properties.aggregateState", "type": "str"},
"per_node_extension_details": {"key": "properties.perNodeExtensionDetails", "type": "[PerNodeExtensionState]"},
"force_update_tag": {"key": "properties.extensionParameters.forceUpdateTag", "type": "str"},
"publisher": {"key": "properties.extensionParameters.publisher", "type": "str"},
"type_properties_extension_parameters_type": {"key": "properties.extensionParameters.type", "type": "str"},
"type_handler_version": {"key": "properties.extensionParameters.typeHandlerVersion", "type": "str"},
"auto_upgrade_minor_version": {"key": "properties.extensionParameters.autoUpgradeMinorVersion", "type": "bool"},
"settings": {"key": "properties.extensionParameters.settings", "type": "object"},
"protected_settings": {"key": "properties.extensionParameters.protectedSettings", "type": "object"},
"created_by": {"key": "systemData.createdBy", "type": "str"},
"created_by_type": {"key": "systemData.createdByType", "type": "str"},
"created_at": {"key": "systemData.createdAt", "type": "iso-8601"},
"last_modified_by": {"key": "systemData.lastModifiedBy", "type": "str"},
"last_modified_by_type": {"key": "systemData.lastModifiedByType", "type": "str"},
"last_modified_at": {"key": "systemData.lastModifiedAt", "type": "iso-8601"},
}
def __init__(
self,
*,
force_update_tag: Optional[str] = None,
publisher: Optional[str] = None,
type_properties_extension_parameters_type: Optional[str] = None,
type_handler_version: Optional[str] = None,
auto_upgrade_minor_version: Optional[bool] = None,
settings: Optional[JSON] = None,
protected_settings: Optional[JSON] = None,
created_by: Optional[str] = None,
created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
created_at: Optional[datetime.datetime] = None,
last_modified_by: Optional[str] = None,
last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
last_modified_at: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword force_update_tag: How the extension handler should be forced to update even if the
extension configuration has not changed.
:paramtype force_update_tag: str
:keyword publisher: The name of the extension handler publisher.
:paramtype publisher: str
:keyword type_properties_extension_parameters_type: Specifies the type of the extension; an
example is "CustomScriptExtension".
:paramtype type_properties_extension_parameters_type: str
:keyword type_handler_version: Specifies the version of the script handler.
:paramtype type_handler_version: str
:keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor
version if one is available at deployment time. Once deployed, however, the extension will not
upgrade minor versions unless redeployed, even with this property set to true.
:paramtype auto_upgrade_minor_version: bool
:keyword settings: Json formatted public settings for the extension.
:paramtype settings: JSON
:keyword protected_settings: Protected settings (may contain secrets).
:paramtype protected_settings: JSON
:keyword created_by: The identity that created the resource.
:paramtype created_by: str
:keyword created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:paramtype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword created_at: The timestamp of resource creation (UTC).
:paramtype created_at: ~datetime.datetime
:keyword last_modified_by: The identity that last modified the resource.
:paramtype last_modified_by: str
:keyword last_modified_by_type: The type of identity that last modified the resource. Known
values are: "User", "Application", "ManagedIdentity", and "Key".
:paramtype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword last_modified_at: The timestamp of resource last modification (UTC).
:paramtype last_modified_at: ~datetime.datetime
"""
super().__init__(**kwargs)
self.provisioning_state = None
self.aggregate_state = None
self.per_node_extension_details = None
self.force_update_tag = force_update_tag
self.publisher = publisher
self.type_properties_extension_parameters_type = type_properties_extension_parameters_type
self.type_handler_version = type_handler_version
self.auto_upgrade_minor_version = auto_upgrade_minor_version
self.settings = settings
self.protected_settings = protected_settings
self.created_by = created_by
self.created_by_type = created_by_type
self.created_at = created_at
self.last_modified_by = last_modified_by
self.last_modified_by_type = last_modified_by_type
self.last_modified_at = last_modified_at
class ExtensionList(_serialization.Model):
"""List of Extensions in HCI cluster.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of Extensions in HCI cluster.
:vartype value: list[~azure.mgmt.azurestackhci.models.Extension]
:ivar next_link: Link to the next set of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[Extension]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class GalleryDiskImage(_serialization.Model):
"""This is the disk image base class.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar size_in_mb: This property indicates the size of the VHD to be created.
:vartype size_in_mb: int
"""
_validation = {
"size_in_mb": {"readonly": True},
}
_attribute_map = {
"size_in_mb": {"key": "sizeInMB", "type": "int"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.size_in_mb = None
class GalleryImageIdentifier(_serialization.Model):
"""This is the gallery image definition identifier.
All required parameters must be populated in order to send to Azure.
:ivar publisher: The name of the gallery image definition publisher. Required.
:vartype publisher: str
:ivar offer: The name of the gallery image definition offer. Required.
:vartype offer: str
:ivar sku: The name of the gallery image definition SKU. Required.
:vartype sku: str
"""
_validation = {
"publisher": {"required": True},
"offer": {"required": True},
"sku": {"required": True},
}
_attribute_map = {
"publisher": {"key": "publisher", "type": "str"},
"offer": {"key": "offer", "type": "str"},
"sku": {"key": "sku", "type": "str"},
}
def __init__(self, *, publisher: str, offer: str, sku: str, **kwargs):
"""
:keyword publisher: The name of the gallery image definition publisher. Required.
:paramtype publisher: str
:keyword offer: The name of the gallery image definition offer. Required.
:paramtype offer: str
:keyword sku: The name of the gallery image definition SKU. Required.
:paramtype sku: str
"""
super().__init__(**kwargs)
self.publisher = publisher
self.offer = offer
self.sku = sku
class Galleryimages(TrackedResource): # pylint: disable=too-many-instance-attributes
"""The gallery image resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar container_name: Container Name for storage container.
:vartype container_name: str
:ivar image_path: location of the image the gallery image should be created from.
:vartype image_path: str
:ivar os_type: operating system type that the gallery image uses. Expected to be linux or
windows. Known values are: "Windows" and "Linux".
:vartype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes
:ivar cloud_init_data_source: Datasource for the gallery image when provisioning with
cloud-init (Azure or NoCloud). Known values are: "NoCloud" and "Azure".
:vartype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource
:ivar hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known
values are: "V1" and "V2".
:vartype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration
:ivar identifier: This is the gallery image definition identifier.
:vartype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier
:ivar version: Specifies information about the gallery image version that you want to create or
update.
:vartype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion
:ivar provisioning_state: Provisioning state of the gallery image. Known values are:
"Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar status: GalleryImageStatus defines the observed state of galleryimages.
:vartype status: ~azure.mgmt.azurestackhci.models.GalleryImageStatus
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"system_data": {"key": "systemData", "type": "SystemData"},
"container_name": {"key": "properties.containerName", "type": "str"},
"image_path": {"key": "properties.imagePath", "type": "str"},
"os_type": {"key": "properties.osType", "type": "str"},
"cloud_init_data_source": {"key": "properties.cloudInitDataSource", "type": "str"},
"hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"},
"identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"},
"version": {"key": "properties.version", "type": "GalleryImageVersion"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"status": {"key": "properties.status", "type": "GalleryImageStatus"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
container_name: Optional[str] = None,
image_path: Optional[str] = None,
os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None,
cloud_init_data_source: Optional[Union[str, "_models.CloudInitDataSource"]] = None,
hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None,
identifier: Optional["_models.GalleryImageIdentifier"] = None,
version: Optional["_models.GalleryImageVersion"] = None,
resource_name: Optional[str] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:keyword container_name: Container Name for storage container.
:paramtype container_name: str
:keyword image_path: location of the image the gallery image should be created from.
:paramtype image_path: str
:keyword os_type: operating system type that the gallery image uses. Expected to be linux or
windows. Known values are: "Windows" and "Linux".
:paramtype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes
:keyword cloud_init_data_source: Datasource for the gallery image when provisioning with
cloud-init (Azure or NoCloud). Known values are: "NoCloud" and "Azure".
:paramtype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource
:keyword hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known
values are: "V1" and "V2".
:paramtype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration
:keyword identifier: This is the gallery image definition identifier.
:paramtype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier
:keyword version: Specifies information about the gallery image version that you want to create
or update.
:paramtype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.system_data = None
self.container_name = container_name
self.image_path = image_path
self.os_type = os_type
self.cloud_init_data_source = cloud_init_data_source
self.hyper_v_generation = hyper_v_generation
self.identifier = identifier
self.version = version
self.provisioning_state = None
self.resource_name = resource_name
self.status = None
class GalleryimagesListResult(_serialization.Model):
"""List of galleryimages.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value:
:vartype value: list[~azure.mgmt.azurestackhci.models.Galleryimages]
:ivar next_link: Link to the next set of results.
:vartype next_link: str
"""
_validation = {
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[Galleryimages]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, *, value: Optional[List["_models.Galleryimages"]] = None, **kwargs):
"""
:keyword value:
:paramtype value: list[~azure.mgmt.azurestackhci.models.Galleryimages]
"""
super().__init__(**kwargs)
self.value = value
self.next_link = None
class GalleryimagesPatch(_serialization.Model):
"""The gallery image resource patch definition.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class GalleryImageStatus(_serialization.Model):
"""GalleryImageStatus defines the observed state of galleryimages.
:ivar error_code: Gallery image provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar provisioning_status: The provisioning status of the gallery image.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.GalleryImageStatusProvisioningStatus
:ivar download_status: The download status of the gallery image.
:vartype download_status: ~azure.mgmt.azurestackhci.models.GalleryImageStatusDownloadStatus
:ivar progress_percentage: The progress of the operation in percentage.
:vartype progress_percentage: int
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"provisioning_status": {"key": "provisioningStatus", "type": "GalleryImageStatusProvisioningStatus"},
"download_status": {"key": "downloadStatus", "type": "GalleryImageStatusDownloadStatus"},
"progress_percentage": {"key": "progressPercentage", "type": "int"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
provisioning_status: Optional["_models.GalleryImageStatusProvisioningStatus"] = None,
download_status: Optional["_models.GalleryImageStatusDownloadStatus"] = None,
progress_percentage: Optional[int] = None,
**kwargs
):
"""
:keyword error_code: Gallery image provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword provisioning_status: The provisioning status of the gallery image.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.GalleryImageStatusProvisioningStatus
:keyword download_status: The download status of the gallery image.
:paramtype download_status: ~azure.mgmt.azurestackhci.models.GalleryImageStatusDownloadStatus
:keyword progress_percentage: The progress of the operation in percentage.
:paramtype progress_percentage: int
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.provisioning_status = provisioning_status
self.download_status = download_status
self.progress_percentage = progress_percentage
class GalleryImageStatusDownloadStatus(_serialization.Model):
"""The download status of the gallery image.
:ivar download_size_in_mb: The downloaded sized of the image in MB.
:vartype download_size_in_mb: int
"""
_attribute_map = {
"download_size_in_mb": {"key": "downloadSizeInMB", "type": "int"},
}
def __init__(self, *, download_size_in_mb: Optional[int] = None, **kwargs):
"""
:keyword download_size_in_mb: The downloaded sized of the image in MB.
:paramtype download_size_in_mb: int
"""
super().__init__(**kwargs)
self.download_size_in_mb = download_size_in_mb
class GalleryImageStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the gallery image.
:ivar operation_id: The ID of the operation performed on the gallery image.
:vartype operation_id: str
:ivar status: The status of the operation performed on the gallery image [Succeeded, Failed,
InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the gallery image.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the gallery image [Succeeded, Failed,
InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
class GalleryImageVersion(_serialization.Model):
"""Specifies information about the gallery image version that you want to create or update.
:ivar name: This is the version of the gallery image.
:vartype name: str
:ivar storage_profile: This is the storage profile of a Gallery Image Version.
:vartype storage_profile: ~azure.mgmt.azurestackhci.models.GalleryImageVersionStorageProfile
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"},
}
def __init__(
self,
*,
name: Optional[str] = None,
storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None,
**kwargs
):
"""
:keyword name: This is the version of the gallery image.
:paramtype name: str
:keyword storage_profile: This is the storage profile of a Gallery Image Version.
:paramtype storage_profile: ~azure.mgmt.azurestackhci.models.GalleryImageVersionStorageProfile
"""
super().__init__(**kwargs)
self.name = name
self.storage_profile = storage_profile
class GalleryImageVersionStorageProfile(_serialization.Model):
"""This is the storage profile of a Gallery Image Version.
:ivar os_disk_image: This is the OS disk image.
:vartype os_disk_image: ~azure.mgmt.azurestackhci.models.GalleryOSDiskImage
"""
_attribute_map = {
"os_disk_image": {"key": "osDiskImage", "type": "GalleryOSDiskImage"},
}
def __init__(self, *, os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, **kwargs):
"""
:keyword os_disk_image: This is the OS disk image.
:paramtype os_disk_image: ~azure.mgmt.azurestackhci.models.GalleryOSDiskImage
"""
super().__init__(**kwargs)
self.os_disk_image = os_disk_image
class GalleryOSDiskImage(GalleryDiskImage):
"""This is the OS disk image.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar size_in_mb: This property indicates the size of the VHD to be created.
:vartype size_in_mb: int
"""
_validation = {
"size_in_mb": {"readonly": True},
}
_attribute_map = {
"size_in_mb": {"key": "sizeInMB", "type": "int"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
class GuestAgent(ProxyResource):
"""Defines the GuestAgent.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: The system data.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar credentials: Username / Password Credentials to provision guest agent.
:vartype credentials: ~azure.mgmt.azurestackhci.models.GuestCredential
:ivar http_proxy_config: HTTP Proxy configuration for the VM.
:vartype http_proxy_config: ~azure.mgmt.azurestackhci.models.HttpProxyConfiguration
:ivar provisioning_action: The guest agent provisioning action. Known values are: "install",
"uninstall", and "repair".
:vartype provisioning_action: str or ~azure.mgmt.azurestackhci.models.ProvisioningAction
:ivar status: The guest agent status.
:vartype status: str
:ivar provisioning_state: The provisioning state.
:vartype provisioning_state: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"status": {"readonly": True},
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"credentials": {"key": "properties.credentials", "type": "GuestCredential"},
"http_proxy_config": {"key": "properties.httpProxyConfig", "type": "HttpProxyConfiguration"},
"provisioning_action": {"key": "properties.provisioningAction", "type": "str"},
"status": {"key": "properties.status", "type": "str"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
}
def __init__(
self,
*,
credentials: Optional["_models.GuestCredential"] = None,
http_proxy_config: Optional["_models.HttpProxyConfiguration"] = None,
provisioning_action: Optional[Union[str, "_models.ProvisioningAction"]] = None,
**kwargs
):
"""
:keyword credentials: Username / Password Credentials to provision guest agent.
:paramtype credentials: ~azure.mgmt.azurestackhci.models.GuestCredential
:keyword http_proxy_config: HTTP Proxy configuration for the VM.
:paramtype http_proxy_config: ~azure.mgmt.azurestackhci.models.HttpProxyConfiguration
:keyword provisioning_action: The guest agent provisioning action. Known values are: "install",
"uninstall", and "repair".
:paramtype provisioning_action: str or ~azure.mgmt.azurestackhci.models.ProvisioningAction
"""
super().__init__(**kwargs)
self.system_data = None
self.credentials = credentials
self.http_proxy_config = http_proxy_config
self.provisioning_action = provisioning_action
self.status = None
self.provisioning_state = None
class GuestAgentList(_serialization.Model):
"""List of GuestAgent.
All required parameters must be populated in order to send to Azure.
:ivar next_link: Url to follow for getting next page of GuestAgent.
:vartype next_link: str
:ivar value: Array of GuestAgent. Required.
:vartype value: list[~azure.mgmt.azurestackhci.models.GuestAgent]
"""
_validation = {
"value": {"required": True},
}
_attribute_map = {
"next_link": {"key": "nextLink", "type": "str"},
"value": {"key": "value", "type": "[GuestAgent]"},
}
def __init__(self, *, value: List["_models.GuestAgent"], next_link: Optional[str] = None, **kwargs):
"""
:keyword next_link: Url to follow for getting next page of GuestAgent.
:paramtype next_link: str
:keyword value: Array of GuestAgent. Required.
:paramtype value: list[~azure.mgmt.azurestackhci.models.GuestAgent]
"""
super().__init__(**kwargs)
self.next_link = next_link
self.value = value
class GuestAgentProfile(_serialization.Model):
"""Defines the resource properties.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar vm_uuid: Specifies the VM's unique SMBIOS ID.
:vartype vm_uuid: str
:ivar status: The status of the hybrid machine agent. Known values are: "Connected",
"Disconnected", and "Error".
:vartype status: str or ~azure.mgmt.azurestackhci.models.StatusTypes
:ivar last_status_change: The time of the last status change.
:vartype last_status_change: ~datetime.datetime
:ivar agent_version: The hybrid machine agent full version.
:vartype agent_version: str
:ivar error_details: Details about the error state.
:vartype error_details: list[~azure.mgmt.azurestackhci.models.ErrorDetail]
"""
_validation = {
"vm_uuid": {"readonly": True},
"status": {"readonly": True},
"last_status_change": {"readonly": True},
"agent_version": {"readonly": True},
"error_details": {"readonly": True},
}
_attribute_map = {
"vm_uuid": {"key": "vmUuid", "type": "str"},
"status": {"key": "status", "type": "str"},
"last_status_change": {"key": "lastStatusChange", "type": "iso-8601"},
"agent_version": {"key": "agentVersion", "type": "str"},
"error_details": {"key": "errorDetails", "type": "[ErrorDetail]"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.vm_uuid = None
self.status = None
self.last_status_change = None
self.agent_version = None
self.error_details = None
class GuestCredential(_serialization.Model):
"""Username / Password Credentials to connect to guest.
:ivar username: The username to connect with the guest.
:vartype username: str
:ivar password: The password to connect with the guest.
:vartype password: str
"""
_attribute_map = {
"username": {"key": "username", "type": "str"},
"password": {"key": "password", "type": "str"},
}
def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs):
"""
:keyword username: The username to connect with the guest.
:paramtype username: str
:keyword password: The password to connect with the guest.
:paramtype password: str
"""
super().__init__(**kwargs)
self.username = username
self.password = password
class HardwareProfileUpdate(_serialization.Model):
"""HardwareProfile - Specifies the hardware settings for the virtual machine.
:ivar vm_size: Known values are: "Default", "Standard_A2_v2", "Standard_A4_v2",
"Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3",
"Standard_D32s_v3", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2",
"Standard_DS13_v2", "Standard_K8S_v1", "Standard_K8S2_v1", "Standard_K8S3_v1",
"Standard_K8S4_v1", "Standard_NK6", "Standard_NK12", "Standard_NV6", "Standard_NV12",
"Standard_K8S5_v1", and "Custom".
:vartype vm_size: str or ~azure.mgmt.azurestackhci.models.VmSizeEnum
:ivar processors: number of processors for the virtual machine.
:vartype processors: int
:ivar memory_gb: RAM in gb for the virtual machine.
:vartype memory_gb: int
"""
_attribute_map = {
"vm_size": {"key": "vmSize", "type": "str"},
"processors": {"key": "processors", "type": "int"},
"memory_gb": {"key": "memoryGB", "type": "int"},
}
def __init__(
self,
*,
vm_size: Optional[Union[str, "_models.VmSizeEnum"]] = None,
processors: Optional[int] = None,
memory_gb: Optional[int] = None,
**kwargs
):
"""
:keyword vm_size: Known values are: "Default", "Standard_A2_v2", "Standard_A4_v2",
"Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3",
"Standard_D32s_v3", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2",
"Standard_DS13_v2", "Standard_K8S_v1", "Standard_K8S2_v1", "Standard_K8S3_v1",
"Standard_K8S4_v1", "Standard_NK6", "Standard_NK12", "Standard_NV6", "Standard_NV12",
"Standard_K8S5_v1", and "Custom".
:paramtype vm_size: str or ~azure.mgmt.azurestackhci.models.VmSizeEnum
:keyword processors: number of processors for the virtual machine.
:paramtype processors: int
:keyword memory_gb: RAM in gb for the virtual machine.
:paramtype memory_gb: int
"""
super().__init__(**kwargs)
self.vm_size = vm_size
self.processors = processors
self.memory_gb = memory_gb
class HttpProxyConfiguration(_serialization.Model):
"""HTTP Proxy configuration for the VM.
:ivar https_proxy: The httpsProxy url.
:vartype https_proxy: str
"""
_attribute_map = {
"https_proxy": {"key": "httpsProxy", "type": "str"},
}
def __init__(self, *, https_proxy: Optional[str] = None, **kwargs):
"""
:keyword https_proxy: The httpsProxy url.
:paramtype https_proxy: str
"""
super().__init__(**kwargs)
self.https_proxy = https_proxy
class HybridIdentityMetadata(ProxyResource):
"""Defines the HybridIdentityMetadata.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: The system data.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar resource_uid: The unique identifier for the resource.
:vartype resource_uid: str
:ivar public_key: The Public Key.
:vartype public_key: str
:ivar identity: Identity for the resource.
:vartype identity: ~azure.mgmt.azurestackhci.models.Identity
:ivar provisioning_state: The provisioning state.
:vartype provisioning_state: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"identity": {"readonly": True},
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"resource_uid": {"key": "properties.resourceUid", "type": "str"},
"public_key": {"key": "properties.publicKey", "type": "str"},
"identity": {"key": "properties.identity", "type": "Identity"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
}
def __init__(self, *, resource_uid: Optional[str] = None, public_key: Optional[str] = None, **kwargs):
"""
:keyword resource_uid: The unique identifier for the resource.
:paramtype resource_uid: str
:keyword public_key: The Public Key.
:paramtype public_key: str
"""
super().__init__(**kwargs)
self.system_data = None
self.resource_uid = resource_uid
self.public_key = public_key
self.identity = None
self.provisioning_state = None
class HybridIdentityMetadataList(_serialization.Model):
"""List of HybridIdentityMetadata.
All required parameters must be populated in order to send to Azure.
:ivar next_link: Url to follow for getting next page of HybridIdentityMetadata.
:vartype next_link: str
:ivar value: Array of HybridIdentityMetadata. Required.
:vartype value: list[~azure.mgmt.azurestackhci.models.HybridIdentityMetadata]
"""
_validation = {
"value": {"required": True},
}
_attribute_map = {
"next_link": {"key": "nextLink", "type": "str"},
"value": {"key": "value", "type": "[HybridIdentityMetadata]"},
}
def __init__(self, *, value: List["_models.HybridIdentityMetadata"], next_link: Optional[str] = None, **kwargs):
"""
:keyword next_link: Url to follow for getting next page of HybridIdentityMetadata.
:paramtype next_link: str
:keyword value: Array of HybridIdentityMetadata. Required.
:paramtype value: list[~azure.mgmt.azurestackhci.models.HybridIdentityMetadata]
"""
super().__init__(**kwargs)
self.next_link = next_link
self.value = value
class Identity(_serialization.Model):
"""Identity for the resource.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar principal_id: The principal ID of resource identity.
:vartype principal_id: str
:ivar tenant_id: The tenant ID of resource.
:vartype tenant_id: str
:ivar type: The identity type. Default value is "SystemAssigned".
:vartype type: str
"""
_validation = {
"principal_id": {"readonly": True},
"tenant_id": {"readonly": True},
}
_attribute_map = {
"principal_id": {"key": "principalId", "type": "str"},
"tenant_id": {"key": "tenantId", "type": "str"},
"type": {"key": "type", "type": "str"},
}
def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs):
"""
:keyword type: The identity type. Default value is "SystemAssigned".
:paramtype type: str
"""
super().__init__(**kwargs)
self.principal_id = None
self.tenant_id = None
self.type = type
class InterfaceDNSSettings(_serialization.Model):
"""InterfaceDNSSettings.
:ivar dns_servers: List of DNS server IP Addresses for the interface.
:vartype dns_servers: list[str]
"""
_attribute_map = {
"dns_servers": {"key": "dnsServers", "type": "[str]"},
}
def __init__(self, *, dns_servers: Optional[List[str]] = None, **kwargs):
"""
:keyword dns_servers: List of DNS server IP Addresses for the interface.
:paramtype dns_servers: list[str]
"""
super().__init__(**kwargs)
self.dns_servers = dns_servers
class IpConfiguration(_serialization.Model):
"""InterfaceIPConfiguration iPConfiguration in a network interface.
:ivar name: Name - The name of the resource that is unique within a resource group. This name
can be used to access the resource.
:vartype name: str
:ivar properties: InterfaceIPConfigurationPropertiesFormat properties of IP configuration.
:vartype properties: ~azure.mgmt.azurestackhci.models.IpConfigurationProperties
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"properties": {"key": "properties", "type": "IpConfigurationProperties"},
}
def __init__(
self, *, name: Optional[str] = None, properties: Optional["_models.IpConfigurationProperties"] = None, **kwargs
):
"""
:keyword name: Name - The name of the resource that is unique within a resource group. This
name can be used to access the resource.
:paramtype name: str
:keyword properties: InterfaceIPConfigurationPropertiesFormat properties of IP configuration.
:paramtype properties: ~azure.mgmt.azurestackhci.models.IpConfigurationProperties
"""
super().__init__(**kwargs)
self.name = name
self.properties = properties
class IpConfigurationProperties(_serialization.Model):
"""InterfaceIPConfigurationPropertiesFormat properties of IP configuration.
:ivar gateway: Gateway for network interface.
:vartype gateway: str
:ivar prefix_length: prefixLength for network interface.
:vartype prefix_length: str
:ivar private_ip_address: PrivateIPAddress - Private IP address of the IP configuration.
:vartype private_ip_address: str
:ivar private_ip_allocation_method: PrivateIPAllocationMethod - The private IP address
allocation method. Possible values include: 'Static', 'Dynamic'. Known values are: "Dynamic"
and "Static".
:vartype private_ip_allocation_method: str or
~azure.mgmt.azurestackhci.models.PrivateIPAllocationMethodEnum
:ivar subnet: Subnet - Name of Subnet bound to the IP configuration.
:vartype subnet: ~azure.mgmt.azurestackhci.models.IpConfigurationPropertiesSubnet
"""
_attribute_map = {
"gateway": {"key": "gateway", "type": "str"},
"prefix_length": {"key": "prefixLength", "type": "str"},
"private_ip_address": {"key": "privateIPAddress", "type": "str"},
"private_ip_allocation_method": {"key": "privateIPAllocationMethod", "type": "str"},
"subnet": {"key": "subnet", "type": "IpConfigurationPropertiesSubnet"},
}
def __init__(
self,
*,
gateway: Optional[str] = None,
prefix_length: Optional[str] = None,
private_ip_address: Optional[str] = None,
private_ip_allocation_method: Optional[Union[str, "_models.PrivateIPAllocationMethodEnum"]] = None,
subnet: Optional["_models.IpConfigurationPropertiesSubnet"] = None,
**kwargs
):
"""
:keyword gateway: Gateway for network interface.
:paramtype gateway: str
:keyword prefix_length: prefixLength for network interface.
:paramtype prefix_length: str
:keyword private_ip_address: PrivateIPAddress - Private IP address of the IP configuration.
:paramtype private_ip_address: str
:keyword private_ip_allocation_method: PrivateIPAllocationMethod - The private IP address
allocation method. Possible values include: 'Static', 'Dynamic'. Known values are: "Dynamic"
and "Static".
:paramtype private_ip_allocation_method: str or
~azure.mgmt.azurestackhci.models.PrivateIPAllocationMethodEnum
:keyword subnet: Subnet - Name of Subnet bound to the IP configuration.
:paramtype subnet: ~azure.mgmt.azurestackhci.models.IpConfigurationPropertiesSubnet
"""
super().__init__(**kwargs)
self.gateway = gateway
self.prefix_length = prefix_length
self.private_ip_address = private_ip_address
self.private_ip_allocation_method = private_ip_allocation_method
self.subnet = subnet
class IpConfigurationPropertiesSubnet(_serialization.Model):
"""Subnet - Name of Subnet bound to the IP configuration.
:ivar id: ID - The ARM resource id in the form of
/subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/...
:vartype id: str
"""
_attribute_map = {
"id": {"key": "id", "type": "str"},
}
def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin
"""
:keyword id: ID - The ARM resource id in the form of
/subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/...
:paramtype id: str
"""
super().__init__(**kwargs)
self.id = id
class IPPool(_serialization.Model):
"""IPPool.
:ivar ip_pool_type: ip pool type. Known values are: "vm" and "vippool".
:vartype ip_pool_type: str or ~azure.mgmt.azurestackhci.models.IPPoolTypeEnum
:ivar start: start of the ip address pool.
:vartype start: str
:ivar end: end of the ip address pool.
:vartype end: str
:ivar info:
:vartype info: ~azure.mgmt.azurestackhci.models.IPPoolInfo
"""
_attribute_map = {
"ip_pool_type": {"key": "ipPoolType", "type": "str"},
"start": {"key": "start", "type": "str"},
"end": {"key": "end", "type": "str"},
"info": {"key": "info", "type": "IPPoolInfo"},
}
def __init__(
self,
*,
ip_pool_type: Optional[Union[str, "_models.IPPoolTypeEnum"]] = None,
start: Optional[str] = None,
end: Optional[str] = None,
info: Optional["_models.IPPoolInfo"] = None,
**kwargs
):
"""
:keyword ip_pool_type: ip pool type. Known values are: "vm" and "vippool".
:paramtype ip_pool_type: str or ~azure.mgmt.azurestackhci.models.IPPoolTypeEnum
:keyword start: start of the ip address pool.
:paramtype start: str
:keyword end: end of the ip address pool.
:paramtype end: str
:keyword info:
:paramtype info: ~azure.mgmt.azurestackhci.models.IPPoolInfo
"""
super().__init__(**kwargs)
self.ip_pool_type = ip_pool_type
self.start = start
self.end = end
self.info = info
class IPPoolInfo(_serialization.Model):
"""IPPoolInfo.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar used: no. of ip addresses allocated from the ip pool.
:vartype used: str
:ivar available: no. of ip addresses available in the ip pool.
:vartype available: str
"""
_validation = {
"used": {"readonly": True},
"available": {"readonly": True},
}
_attribute_map = {
"used": {"key": "used", "type": "str"},
"available": {"key": "available", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.used = None
self.available = None
class MachineExtension(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""Describes a Machine Extension.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar location: The geo-location where the resource lives.
:vartype location: str
:ivar system_data: The system data.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar name: The name of the resource.
:vartype name: str
:ivar id: Fully qualified resource ID for the resource.
:vartype id: str
:ivar type: The type of the resource.
:vartype type: str
:ivar force_update_tag: How the extension handler should be forced to update even if the
extension configuration has not changed.
:vartype force_update_tag: str
:ivar publisher: The name of the extension handler publisher.
:vartype publisher: str
:ivar type_properties_type: Specifies the type of the extension; an example is
"CustomScriptExtension".
:vartype type_properties_type: str
:ivar type_handler_version: Specifies the version of the script handler.
:vartype type_handler_version: str
:ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor
version if one is available at deployment time. Once deployed, however, the extension will not
upgrade minor versions unless redeployed, even with this property set to true.
:vartype auto_upgrade_minor_version: bool
:ivar settings: Json formatted public settings for the extension.
:vartype settings: JSON
:ivar protected_settings: The extension can contain either protectedSettings or
protectedSettingsFromKeyVault or no protected settings at all.
:vartype protected_settings: JSON
:ivar provisioning_state: The provisioning state, which only appears in the response.
:vartype provisioning_state: str
:ivar instance_view: The machine extension instance view.
:vartype instance_view: ~azure.mgmt.azurestackhci.models.MachineExtensionPropertiesInstanceView
"""
_validation = {
"system_data": {"readonly": True},
"name": {"readonly": True},
"id": {"readonly": True},
"type": {"readonly": True},
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"location": {"key": "location", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"tags": {"key": "tags", "type": "{str}"},
"name": {"key": "name", "type": "str"},
"id": {"key": "id", "type": "str"},
"type": {"key": "type", "type": "str"},
"force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"},
"publisher": {"key": "properties.publisher", "type": "str"},
"type_properties_type": {"key": "properties.type", "type": "str"},
"type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"},
"auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"},
"settings": {"key": "properties.settings", "type": "object"},
"protected_settings": {"key": "properties.protectedSettings", "type": "object"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"instance_view": {"key": "properties.instanceView", "type": "MachineExtensionPropertiesInstanceView"},
}
def __init__(
self,
*,
location: Optional[str] = None,
tags: Optional[Dict[str, str]] = None,
force_update_tag: Optional[str] = None,
publisher: Optional[str] = None,
type_properties_type: Optional[str] = None,
type_handler_version: Optional[str] = None,
auto_upgrade_minor_version: Optional[bool] = None,
settings: Optional[JSON] = None,
protected_settings: Optional[JSON] = None,
instance_view: Optional["_models.MachineExtensionPropertiesInstanceView"] = None,
**kwargs
):
"""
:keyword location: The geo-location where the resource lives.
:paramtype location: str
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword force_update_tag: How the extension handler should be forced to update even if the
extension configuration has not changed.
:paramtype force_update_tag: str
:keyword publisher: The name of the extension handler publisher.
:paramtype publisher: str
:keyword type_properties_type: Specifies the type of the extension; an example is
"CustomScriptExtension".
:paramtype type_properties_type: str
:keyword type_handler_version: Specifies the version of the script handler.
:paramtype type_handler_version: str
:keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor
version if one is available at deployment time. Once deployed, however, the extension will not
upgrade minor versions unless redeployed, even with this property set to true.
:paramtype auto_upgrade_minor_version: bool
:keyword settings: Json formatted public settings for the extension.
:paramtype settings: JSON
:keyword protected_settings: The extension can contain either protectedSettings or
protectedSettingsFromKeyVault or no protected settings at all.
:paramtype protected_settings: JSON
:keyword instance_view: The machine extension instance view.
:paramtype instance_view:
~azure.mgmt.azurestackhci.models.MachineExtensionPropertiesInstanceView
"""
super().__init__(**kwargs)
self.location = location
self.system_data = None
self.tags = tags
self.name = None
self.id = None
self.type = None
self.force_update_tag = force_update_tag
self.publisher = publisher
self.type_properties_type = type_properties_type
self.type_handler_version = type_handler_version
self.auto_upgrade_minor_version = auto_upgrade_minor_version
self.settings = settings
self.protected_settings = protected_settings
self.provisioning_state = None
self.instance_view = instance_view
class MachineExtensionInstanceView(_serialization.Model):
"""Describes the Machine Extension Instance View.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: The machine extension name.
:vartype name: str
:ivar type: Specifies the type of the extension; an example is "CustomScriptExtension".
:vartype type: str
:ivar type_handler_version: Specifies the version of the script handler.
:vartype type_handler_version: str
:ivar status: Instance view status.
:vartype status: ~azure.mgmt.azurestackhci.models.MachineExtensionInstanceViewStatus
"""
_validation = {
"name": {"readonly": True},
"type": {"readonly": True},
"type_handler_version": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"type_handler_version": {"key": "typeHandlerVersion", "type": "str"},
"status": {"key": "status", "type": "MachineExtensionInstanceViewStatus"},
}
def __init__(self, *, status: Optional["_models.MachineExtensionInstanceViewStatus"] = None, **kwargs):
"""
:keyword status: Instance view status.
:paramtype status: ~azure.mgmt.azurestackhci.models.MachineExtensionInstanceViewStatus
"""
super().__init__(**kwargs)
self.name = None
self.type = None
self.type_handler_version = None
self.status = status
class MachineExtensionInstanceViewStatus(_serialization.Model):
"""Instance view status.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: The status code.
:vartype code: str
:ivar level: The level code. Known values are: "Info", "Warning", and "Error".
:vartype level: str or ~azure.mgmt.azurestackhci.models.StatusLevelTypes
:ivar display_status: The short localizable label for the status.
:vartype display_status: str
:ivar message: The detailed status message, including for alerts and error messages.
:vartype message: str
:ivar time: The time of the status.
:vartype time: ~datetime.datetime
"""
_validation = {
"code": {"readonly": True},
"level": {"readonly": True},
"display_status": {"readonly": True},
"message": {"readonly": True},
"time": {"readonly": True},
}
_attribute_map = {
"code": {"key": "code", "type": "str"},
"level": {"key": "level", "type": "str"},
"display_status": {"key": "displayStatus", "type": "str"},
"message": {"key": "message", "type": "str"},
"time": {"key": "time", "type": "iso-8601"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.code = None
self.level = None
self.display_status = None
self.message = None
self.time = None
class MachineExtensionPropertiesInstanceView(MachineExtensionInstanceView):
"""The machine extension instance view.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: The machine extension name.
:vartype name: str
:ivar type: Specifies the type of the extension; an example is "CustomScriptExtension".
:vartype type: str
:ivar type_handler_version: Specifies the version of the script handler.
:vartype type_handler_version: str
:ivar status: Instance view status.
:vartype status: ~azure.mgmt.azurestackhci.models.MachineExtensionInstanceViewStatus
"""
_validation = {
"name": {"readonly": True},
"type": {"readonly": True},
"type_handler_version": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"type_handler_version": {"key": "typeHandlerVersion", "type": "str"},
"status": {"key": "status", "type": "MachineExtensionInstanceViewStatus"},
}
def __init__(self, *, status: Optional["_models.MachineExtensionInstanceViewStatus"] = None, **kwargs):
"""
:keyword status: Instance view status.
:paramtype status: ~azure.mgmt.azurestackhci.models.MachineExtensionInstanceViewStatus
"""
super().__init__(status=status, **kwargs)
class MachineExtensionsListResult(_serialization.Model):
"""Describes the Machine Extensions List Result.
:ivar value: The list of extensions.
:vartype value: list[~azure.mgmt.azurestackhci.models.MachineExtension]
:ivar next_link: The uri to fetch the next page of machine extensions. Call ListNext() with
this to fetch the next page of extensions.
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[MachineExtension]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self, *, value: Optional[List["_models.MachineExtension"]] = None, next_link: Optional[str] = None, **kwargs
):
"""
:keyword value: The list of extensions.
:paramtype value: list[~azure.mgmt.azurestackhci.models.MachineExtension]
:keyword next_link: The uri to fetch the next page of machine extensions. Call ListNext() with
this to fetch the next page of extensions.
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class ResourcePatch(_serialization.Model):
"""Object containing updates for patch operations.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class MachineExtensionUpdate(ResourcePatch):
"""Describes a Machine Extension Update.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar force_update_tag: How the extension handler should be forced to update even if the
extension configuration has not changed.
:vartype force_update_tag: str
:ivar publisher: The name of the extension handler publisher.
:vartype publisher: str
:ivar type: Specifies the type of the extension; an example is "CustomScriptExtension".
:vartype type: str
:ivar type_handler_version: Specifies the version of the script handler.
:vartype type_handler_version: str
:ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor
version if one is available at deployment time. Once deployed, however, the extension will not
upgrade minor versions unless redeployed, even with this property set to true.
:vartype auto_upgrade_minor_version: bool
:ivar settings: Json formatted public settings for the extension.
:vartype settings: JSON
:ivar protected_settings: The extension can contain either protectedSettings or
protectedSettingsFromKeyVault or no protected settings at all.
:vartype protected_settings: JSON
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
"force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"},
"publisher": {"key": "properties.publisher", "type": "str"},
"type": {"key": "properties.type", "type": "str"},
"type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"},
"auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"},
"settings": {"key": "properties.settings", "type": "object"},
"protected_settings": {"key": "properties.protectedSettings", "type": "object"},
}
def __init__(
self,
*,
tags: Optional[Dict[str, str]] = None,
force_update_tag: Optional[str] = None,
publisher: Optional[str] = None,
type: Optional[str] = None,
type_handler_version: Optional[str] = None,
auto_upgrade_minor_version: Optional[bool] = None,
settings: Optional[JSON] = None,
protected_settings: Optional[JSON] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword force_update_tag: How the extension handler should be forced to update even if the
extension configuration has not changed.
:paramtype force_update_tag: str
:keyword publisher: The name of the extension handler publisher.
:paramtype publisher: str
:keyword type: Specifies the type of the extension; an example is "CustomScriptExtension".
:paramtype type: str
:keyword type_handler_version: Specifies the version of the script handler.
:paramtype type_handler_version: str
:keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor
version if one is available at deployment time. Once deployed, however, the extension will not
upgrade minor versions unless redeployed, even with this property set to true.
:paramtype auto_upgrade_minor_version: bool
:keyword settings: Json formatted public settings for the extension.
:paramtype settings: JSON
:keyword protected_settings: The extension can contain either protectedSettings or
protectedSettingsFromKeyVault or no protected settings at all.
:paramtype protected_settings: JSON
"""
super().__init__(tags=tags, **kwargs)
self.force_update_tag = force_update_tag
self.publisher = publisher
self.type = type
self.type_handler_version = type_handler_version
self.auto_upgrade_minor_version = auto_upgrade_minor_version
self.settings = settings
self.protected_settings = protected_settings
class Marketplacegalleryimages(TrackedResource): # pylint: disable=too-many-instance-attributes
"""The marketplace gallery image resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar container_name: Container Name for storage container.
:vartype container_name: str
:ivar os_type: operating system type that the gallery image uses. Expected to be linux or
windows. Known values are: "Windows" and "Linux".
:vartype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes
:ivar cloud_init_data_source: Datasource for the gallery image when provisioning with
cloud-init [Azure, NoCloud]. Known values are: "NoCloud" and "Azure".
:vartype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource
:ivar hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known
values are: "V1" and "V2".
:vartype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration
:ivar identifier: This is the gallery image definition identifier.
:vartype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier
:ivar version: Specifies information about the gallery image version that you want to create or
update.
:vartype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion
:ivar provisioning_state: Provisioning state of the gallery image. Known values are:
"Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar status: MarketplaceGalleryImageStatus defines the observed state of
marketplacegalleryimages.
:vartype status: ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatus
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"system_data": {"key": "systemData", "type": "SystemData"},
"container_name": {"key": "properties.containerName", "type": "str"},
"os_type": {"key": "properties.osType", "type": "str"},
"cloud_init_data_source": {"key": "properties.cloudInitDataSource", "type": "str"},
"hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"},
"identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"},
"version": {"key": "properties.version", "type": "GalleryImageVersion"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"status": {"key": "properties.status", "type": "MarketplaceGalleryImageStatus"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
container_name: Optional[str] = None,
os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None,
cloud_init_data_source: Optional[Union[str, "_models.CloudInitDataSource"]] = None,
hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None,
identifier: Optional["_models.GalleryImageIdentifier"] = None,
version: Optional["_models.GalleryImageVersion"] = None,
resource_name: Optional[str] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:keyword container_name: Container Name for storage container.
:paramtype container_name: str
:keyword os_type: operating system type that the gallery image uses. Expected to be linux or
windows. Known values are: "Windows" and "Linux".
:paramtype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes
:keyword cloud_init_data_source: Datasource for the gallery image when provisioning with
cloud-init [Azure, NoCloud]. Known values are: "NoCloud" and "Azure".
:paramtype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource
:keyword hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known
values are: "V1" and "V2".
:paramtype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration
:keyword identifier: This is the gallery image definition identifier.
:paramtype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier
:keyword version: Specifies information about the gallery image version that you want to create
or update.
:paramtype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.system_data = None
self.container_name = container_name
self.os_type = os_type
self.cloud_init_data_source = cloud_init_data_source
self.hyper_v_generation = hyper_v_generation
self.identifier = identifier
self.version = version
self.provisioning_state = None
self.resource_name = resource_name
self.status = None
class MarketplacegalleryimagesListResult(_serialization.Model):
"""List of marketplacegalleryimages.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: The itemed list of marketplacegalleryimages.
:vartype value: list[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:ivar next_link: Link to the next set of results.
:vartype next_link: str
"""
_validation = {
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[Marketplacegalleryimages]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, *, value: Optional[List["_models.Marketplacegalleryimages"]] = None, **kwargs):
"""
:keyword value: The itemed list of marketplacegalleryimages.
:paramtype value: list[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
"""
super().__init__(**kwargs)
self.value = value
self.next_link = None
class MarketplacegalleryimagesPatch(_serialization.Model):
"""The marketplace gallery image resource patch definition.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class MarketplaceGalleryImageStatus(_serialization.Model):
"""MarketplaceGalleryImageStatus defines the observed state of marketplacegalleryimages.
:ivar error_code: Marketplace gallery image provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar provisioning_status: The provisioning status of the marketplace gallery image.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusProvisioningStatus
:ivar download_status: The download status of the marketplace gallery image.
:vartype download_status:
~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusDownloadStatus
:ivar progress_percentage: The progress of the operation in percentage.
:vartype progress_percentage: int
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"provisioning_status": {"key": "provisioningStatus", "type": "MarketplaceGalleryImageStatusProvisioningStatus"},
"download_status": {"key": "downloadStatus", "type": "MarketplaceGalleryImageStatusDownloadStatus"},
"progress_percentage": {"key": "progressPercentage", "type": "int"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
provisioning_status: Optional["_models.MarketplaceGalleryImageStatusProvisioningStatus"] = None,
download_status: Optional["_models.MarketplaceGalleryImageStatusDownloadStatus"] = None,
progress_percentage: Optional[int] = None,
**kwargs
):
"""
:keyword error_code: Marketplace gallery image provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword provisioning_status: The provisioning status of the marketplace gallery image.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusProvisioningStatus
:keyword download_status: The download status of the marketplace gallery image.
:paramtype download_status:
~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusDownloadStatus
:keyword progress_percentage: The progress of the operation in percentage.
:paramtype progress_percentage: int
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.provisioning_status = provisioning_status
self.download_status = download_status
self.progress_percentage = progress_percentage
class MarketplaceGalleryImageStatusDownloadStatus(_serialization.Model):
"""The download status of the marketplace gallery image.
:ivar download_size_in_mb: The downloaded sized of the image in MB.
:vartype download_size_in_mb: int
"""
_attribute_map = {
"download_size_in_mb": {"key": "downloadSizeInMB", "type": "int"},
}
def __init__(self, *, download_size_in_mb: Optional[int] = None, **kwargs):
"""
:keyword download_size_in_mb: The downloaded sized of the image in MB.
:paramtype download_size_in_mb: int
"""
super().__init__(**kwargs)
self.download_size_in_mb = download_size_in_mb
class MarketplaceGalleryImageStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the marketplace gallery image.
:ivar operation_id: The ID of the operation performed on the marketplace gallery image.
:vartype operation_id: str
:ivar status: The status of the operation performed on the marketplace gallery image
[Succeeded, Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the marketplace gallery image.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the marketplace gallery image
[Succeeded, Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
class Networkinterfaces(TrackedResource): # pylint: disable=too-many-instance-attributes
"""The network interface resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar ip_configurations: IPConfigurations - A list of IPConfigurations of the network
interface.
:vartype ip_configurations: list[~azure.mgmt.azurestackhci.models.IpConfiguration]
:ivar mac_address: MacAddress - The MAC address of the network interface.
:vartype mac_address: str
:ivar dns_settings: DNS Settings for the interface.
:vartype dns_settings: ~azure.mgmt.azurestackhci.models.InterfaceDNSSettings
:ivar provisioning_state: Provisioning state of the gallery image. Known values are:
"Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar status: NetworkInterfaceStatus defines the observed state of network interfaces.
:vartype status: ~azure.mgmt.azurestackhci.models.NetworkInterfaceStatus
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"system_data": {"key": "systemData", "type": "SystemData"},
"ip_configurations": {"key": "properties.ipConfigurations", "type": "[IpConfiguration]"},
"mac_address": {"key": "properties.macAddress", "type": "str"},
"dns_settings": {"key": "properties.dnsSettings", "type": "InterfaceDNSSettings"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"status": {"key": "properties.status", "type": "NetworkInterfaceStatus"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
ip_configurations: Optional[List["_models.IpConfiguration"]] = None,
mac_address: Optional[str] = None,
dns_settings: Optional["_models.InterfaceDNSSettings"] = None,
resource_name: Optional[str] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:keyword ip_configurations: IPConfigurations - A list of IPConfigurations of the network
interface.
:paramtype ip_configurations: list[~azure.mgmt.azurestackhci.models.IpConfiguration]
:keyword mac_address: MacAddress - The MAC address of the network interface.
:paramtype mac_address: str
:keyword dns_settings: DNS Settings for the interface.
:paramtype dns_settings: ~azure.mgmt.azurestackhci.models.InterfaceDNSSettings
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.system_data = None
self.ip_configurations = ip_configurations
self.mac_address = mac_address
self.dns_settings = dns_settings
self.provisioning_state = None
self.resource_name = resource_name
self.status = None
class NetworkinterfacesListResult(_serialization.Model):
"""NetworkinterfacesListResult.
:ivar value:
:vartype value: list[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:ivar next_link:
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[Networkinterfaces]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self, *, value: Optional[List["_models.Networkinterfaces"]] = None, next_link: Optional[str] = None, **kwargs
):
"""
:keyword value:
:paramtype value: list[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:keyword next_link:
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class NetworkinterfacesPatch(_serialization.Model):
"""The network interface resource patch definition.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class NetworkInterfaceStatus(_serialization.Model):
"""NetworkInterfaceStatus defines the observed state of network interfaces.
:ivar error_code: NetworkInterface provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar provisioning_status: The provisioning status of the network interface.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.NetworkInterfaceStatusProvisioningStatus
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"provisioning_status": {"key": "provisioningStatus", "type": "NetworkInterfaceStatusProvisioningStatus"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
provisioning_status: Optional["_models.NetworkInterfaceStatusProvisioningStatus"] = None,
**kwargs
):
"""
:keyword error_code: NetworkInterface provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword provisioning_status: The provisioning status of the network interface.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.NetworkInterfaceStatusProvisioningStatus
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.provisioning_status = provisioning_status
class NetworkInterfaceStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the network interface.
:ivar operation_id: The ID of the operation performed on the network interface.
:vartype operation_id: str
:ivar status: The status of the operation performed on the network interface [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the network interface.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the network interface [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
class NetworkProfileUpdate(_serialization.Model):
"""NetworkProfile - describes the network update configuration the virtual machine.
:ivar network_interfaces: NetworkInterfaces - list of network interfaces to be attached to the
virtual machine.
:vartype network_interfaces:
list[~azure.mgmt.azurestackhci.models.NetworkProfileUpdateNetworkInterfacesItem]
"""
_attribute_map = {
"network_interfaces": {"key": "networkInterfaces", "type": "[NetworkProfileUpdateNetworkInterfacesItem]"},
}
def __init__(
self,
*,
network_interfaces: Optional[List["_models.NetworkProfileUpdateNetworkInterfacesItem"]] = None,
**kwargs
):
"""
:keyword network_interfaces: NetworkInterfaces - list of network interfaces to be attached to
the virtual machine.
:paramtype network_interfaces:
list[~azure.mgmt.azurestackhci.models.NetworkProfileUpdateNetworkInterfacesItem]
"""
super().__init__(**kwargs)
self.network_interfaces = network_interfaces
class NetworkProfileUpdateNetworkInterfacesItem(_serialization.Model):
"""NetworkProfileUpdateNetworkInterfacesItem.
:ivar id: ID - Resource ID of the network interface.
:vartype id: str
"""
_attribute_map = {
"id": {"key": "id", "type": "str"},
}
def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin
"""
:keyword id: ID - Resource ID of the network interface.
:paramtype id: str
"""
super().__init__(**kwargs)
self.id = id
class Operation(_serialization.Model):
"""Details of a REST API operation, returned from the Resource Provider Operations API.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples:
"Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action".
:vartype name: str
:ivar is_data_action: Whether the operation applies to data-plane. This is "true" for
data-plane operations and "false" for ARM/control-plane operations.
:vartype is_data_action: bool
:ivar display: Localized display information for this particular operation.
:vartype display: ~azure.mgmt.azurestackhci.models.OperationDisplay
:ivar origin: The intended executor of the operation; as in Resource Based Access Control
(RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system",
and "user,system".
:vartype origin: str or ~azure.mgmt.azurestackhci.models.Origin
:ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for
internal only APIs. "Internal"
:vartype action_type: str or ~azure.mgmt.azurestackhci.models.ActionType
"""
_validation = {
"name": {"readonly": True},
"is_data_action": {"readonly": True},
"origin": {"readonly": True},
"action_type": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"is_data_action": {"key": "isDataAction", "type": "bool"},
"display": {"key": "display", "type": "OperationDisplay"},
"origin": {"key": "origin", "type": "str"},
"action_type": {"key": "actionType", "type": "str"},
}
def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs):
"""
:keyword display: Localized display information for this particular operation.
:paramtype display: ~azure.mgmt.azurestackhci.models.OperationDisplay
"""
super().__init__(**kwargs)
self.name = None
self.is_data_action = None
self.display = display
self.origin = None
self.action_type = None
class OperationDisplay(_serialization.Model):
"""Localized display information for this particular operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft
Monitoring Insights" or "Microsoft Compute".
:vartype provider: str
:ivar resource: The localized friendly name of the resource type related to this operation.
E.g. "Virtual Machines" or "Job Schedule Collections".
:vartype resource: str
:ivar operation: The concise, localized friendly name for the operation; suitable for
dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine".
:vartype operation: str
:ivar description: The short, localized friendly description of the operation; suitable for
tool tips and detailed views.
:vartype description: str
"""
_validation = {
"provider": {"readonly": True},
"resource": {"readonly": True},
"operation": {"readonly": True},
"description": {"readonly": True},
}
_attribute_map = {
"provider": {"key": "provider", "type": "str"},
"resource": {"key": "resource", "type": "str"},
"operation": {"key": "operation", "type": "str"},
"description": {"key": "description", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.provider = None
self.resource = None
self.operation = None
self.description = None
class OperationListResult(_serialization.Model):
"""A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of operations supported by the resource provider.
:vartype value: list[~azure.mgmt.azurestackhci.models.Operation]
:ivar next_link: URL to get the next set of operation list results (if there are any).
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[Operation]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class PerNodeExtensionState(_serialization.Model):
"""Status of Arc Extension for a particular node in HCI Cluster.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Name of the node in HCI Cluster.
:vartype name: str
:ivar extension: Fully qualified resource ID for the particular Arc Extension on this node.
:vartype extension: str
:ivar state: State of Arc Extension in this node. Known values are: "NotSpecified", "Error",
"Succeeded", "Canceled", "Failed", "Connected", "Disconnected", "Deleted", "Creating",
"Updating", "Deleting", and "Moving".
:vartype state: str or ~azure.mgmt.azurestackhci.models.NodeExtensionState
"""
_validation = {
"name": {"readonly": True},
"extension": {"readonly": True},
"state": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"extension": {"key": "extension", "type": "str"},
"state": {"key": "state", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.name = None
self.extension = None
self.state = None
class PerNodeState(_serialization.Model):
"""Status of Arc agent for a particular node in HCI Cluster.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Name of the Node in HCI Cluster.
:vartype name: str
:ivar arc_instance: Fully qualified resource ID for the Arc agent of this node.
:vartype arc_instance: str
:ivar state: State of Arc agent in this node. Known values are: "NotSpecified", "Error",
"Succeeded", "Canceled", "Failed", "Connected", "Disconnected", "Deleted", "Creating",
"Updating", "Deleting", and "Moving".
:vartype state: str or ~azure.mgmt.azurestackhci.models.NodeArcState
"""
_validation = {
"name": {"readonly": True},
"arc_instance": {"readonly": True},
"state": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"arc_instance": {"key": "arcInstance", "type": "str"},
"state": {"key": "state", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.name = None
self.arc_instance = None
self.state = None
class Storagecontainers(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""The storage container resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Resource Id.
:vartype id: str
:ivar name: Resource Name.
:vartype name: str
:ivar type: Resource Type.
:vartype type: str
:ivar location: The resource location. Required.
:vartype location: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar extended_location:
:vartype extended_location: ~azure.mgmt.azurestackhci.models.StoragecontainersExtendedLocation
:ivar path: Path of the storage container on the disk.
:vartype path: str
:ivar provisioning_state:
:vartype provisioning_state: str
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar available_size_mb: Amount of space available on the disk in MB.
:vartype available_size_mb: int
:ivar container_size_mb: Total size of the disk in MB.
:vartype container_size_mb: int
:ivar status: storageContainerStatus defines the observed state of storagecontainers.
:vartype status: ~azure.mgmt.azurestackhci.models.StorageContainerStatus
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"available_size_mb": {"readonly": True},
"container_size_mb": {"readonly": True},
"status": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"location": {"key": "location", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"system_data": {"key": "systemData", "type": "SystemData"},
"extended_location": {"key": "extendedLocation", "type": "StoragecontainersExtendedLocation"},
"path": {"key": "properties.path", "type": "str"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"available_size_mb": {"key": "properties.availableSizeMB", "type": "int"},
"container_size_mb": {"key": "properties.containerSizeMB", "type": "int"},
"status": {"key": "properties.status", "type": "StorageContainerStatus"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.StoragecontainersExtendedLocation"] = None,
path: Optional[str] = None,
provisioning_state: Optional[str] = None,
resource_name: Optional[str] = None,
**kwargs
):
"""
:keyword location: The resource location. Required.
:paramtype location: str
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword extended_location:
:paramtype extended_location:
~azure.mgmt.azurestackhci.models.StoragecontainersExtendedLocation
:keyword path: Path of the storage container on the disk.
:paramtype path: str
:keyword provisioning_state:
:paramtype provisioning_state: str
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
"""
super().__init__(**kwargs)
self.id = None
self.name = None
self.type = None
self.location = location
self.tags = tags
self.system_data = None
self.extended_location = extended_location
self.path = path
self.provisioning_state = provisioning_state
self.resource_name = resource_name
self.available_size_mb = None
self.container_size_mb = None
self.status = None
class StoragecontainersExtendedLocation(_serialization.Model):
"""StoragecontainersExtendedLocation.
:ivar type: The extended location type.
:vartype type: str
:ivar name: The extended location name.
:vartype name: str
"""
_attribute_map = {
"type": {"key": "type", "type": "str"},
"name": {"key": "name", "type": "str"},
}
def __init__(self, *, type: Optional[str] = None, name: Optional[str] = None, **kwargs):
"""
:keyword type: The extended location type.
:paramtype type: str
:keyword name: The extended location name.
:paramtype name: str
"""
super().__init__(**kwargs)
self.type = type
self.name = name
class StoragecontainersListResult(_serialization.Model):
"""StoragecontainersListResult.
:ivar value:
:vartype value: list[~azure.mgmt.azurestackhci.models.Storagecontainers]
:ivar next_link:
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[Storagecontainers]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self, *, value: Optional[List["_models.Storagecontainers"]] = None, next_link: Optional[str] = None, **kwargs
):
"""
:keyword value:
:paramtype value: list[~azure.mgmt.azurestackhci.models.Storagecontainers]
:keyword next_link:
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class StoragecontainersPatch(_serialization.Model):
"""The storage container resource patch definition.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class StorageContainerStatus(_serialization.Model):
"""storageContainerStatus defines the observed state of storagecontainers.
:ivar error_code: StorageContainer provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar available_size_mb: Amount of space available on the disk in MB.
:vartype available_size_mb: int
:ivar container_size_mb: Total size of the disk in MB.
:vartype container_size_mb: int
:ivar provisioning_status: The provisioning status of the storage container.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.StorageContainerStatusProvisioningStatus
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"available_size_mb": {"key": "availableSizeMB", "type": "int"},
"container_size_mb": {"key": "containerSizeMB", "type": "int"},
"provisioning_status": {"key": "provisioningStatus", "type": "StorageContainerStatusProvisioningStatus"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
available_size_mb: Optional[int] = None,
container_size_mb: Optional[int] = None,
provisioning_status: Optional["_models.StorageContainerStatusProvisioningStatus"] = None,
**kwargs
):
"""
:keyword error_code: StorageContainer provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword available_size_mb: Amount of space available on the disk in MB.
:paramtype available_size_mb: int
:keyword container_size_mb: Total size of the disk in MB.
:paramtype container_size_mb: int
:keyword provisioning_status: The provisioning status of the storage container.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.StorageContainerStatusProvisioningStatus
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.available_size_mb = available_size_mb
self.container_size_mb = container_size_mb
self.provisioning_status = provisioning_status
class StorageContainerStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the storage container.
:ivar operation_id: The ID of the operation performed on the storage container.
:vartype operation_id: str
:ivar status: The status of the operation performed on the storage container [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the storage container.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the storage container [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
class StorageProfileUpdate(_serialization.Model):
"""StorageProfileUpdate.
:ivar data_disks: adds data disks to the virtual machine for the update call.
:vartype data_disks: list[~azure.mgmt.azurestackhci.models.StorageProfileUpdateDataDisksItem]
"""
_attribute_map = {
"data_disks": {"key": "dataDisks", "type": "[StorageProfileUpdateDataDisksItem]"},
}
def __init__(self, *, data_disks: Optional[List["_models.StorageProfileUpdateDataDisksItem"]] = None, **kwargs):
"""
:keyword data_disks: adds data disks to the virtual machine for the update call.
:paramtype data_disks: list[~azure.mgmt.azurestackhci.models.StorageProfileUpdateDataDisksItem]
"""
super().__init__(**kwargs)
self.data_disks = data_disks
class StorageProfileUpdateDataDisksItem(_serialization.Model):
"""StorageProfileUpdateDataDisksItem.
:ivar name:
:vartype name: str
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
}
def __init__(self, *, name: Optional[str] = None, **kwargs):
"""
:keyword name:
:paramtype name: str
"""
super().__init__(**kwargs)
self.name = name
class SystemData(_serialization.Model):
"""Metadata pertaining to creation and last modification of the resource.
:ivar created_by: The identity that created the resource.
:vartype created_by: str
:ivar created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:vartype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar created_at: The timestamp of resource creation (UTC).
:vartype created_at: ~datetime.datetime
:ivar last_modified_by: The identity that last modified the resource.
:vartype last_modified_by: str
:ivar last_modified_by_type: The type of identity that last modified the resource. Known values
are: "User", "Application", "ManagedIdentity", and "Key".
:vartype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar last_modified_at: The timestamp of resource last modification (UTC).
:vartype last_modified_at: ~datetime.datetime
"""
_attribute_map = {
"created_by": {"key": "createdBy", "type": "str"},
"created_by_type": {"key": "createdByType", "type": "str"},
"created_at": {"key": "createdAt", "type": "iso-8601"},
"last_modified_by": {"key": "lastModifiedBy", "type": "str"},
"last_modified_by_type": {"key": "lastModifiedByType", "type": "str"},
"last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"},
}
def __init__(
self,
*,
created_by: Optional[str] = None,
created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
created_at: Optional[datetime.datetime] = None,
last_modified_by: Optional[str] = None,
last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
last_modified_at: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword created_by: The identity that created the resource.
:paramtype created_by: str
:keyword created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:paramtype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword created_at: The timestamp of resource creation (UTC).
:paramtype created_at: ~datetime.datetime
:keyword last_modified_by: The identity that last modified the resource.
:paramtype last_modified_by: str
:keyword last_modified_by_type: The type of identity that last modified the resource. Known
values are: "User", "Application", "ManagedIdentity", and "Key".
:paramtype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword last_modified_at: The timestamp of resource last modification (UTC).
:paramtype last_modified_at: ~datetime.datetime
"""
super().__init__(**kwargs)
self.created_by = created_by
self.created_by_type = created_by_type
self.created_at = created_at
self.last_modified_by = last_modified_by
self.last_modified_by_type = last_modified_by_type
self.last_modified_at = last_modified_at
class Virtualharddisks(TrackedResource): # pylint: disable=too-many-instance-attributes
"""The virtual hard disk resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar block_size_bytes:
:vartype block_size_bytes: int
:ivar disk_size_bytes: diskSizeBytes - size of the disk in GB.
:vartype disk_size_bytes: int
:ivar dynamic: Boolean for enabling dynamic sizing on the virtual hard disk.
:vartype dynamic: bool
:ivar logical_sector_bytes:
:vartype logical_sector_bytes: int
:ivar physical_sector_bytes:
:vartype physical_sector_bytes: int
:ivar hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known
values are: "V1" and "V2".
:vartype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration
:ivar disk_file_format: The format of the actual VHD file [vhd, vhdx]. Known values are: "vhdx"
and "vhd".
:vartype disk_file_format: str or ~azure.mgmt.azurestackhci.models.DiskFileFormat
:ivar provisioning_state: Provisioning state of the gallery image. Known values are:
"Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum
:ivar container_id: Storage ContainerID of the storage container to be used for VHD.
:vartype container_id: str
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar status: VirtualHardDiskStatus defines the observed state of virtualharddisks.
:vartype status: ~azure.mgmt.azurestackhci.models.VirtualHardDiskStatus
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"system_data": {"key": "systemData", "type": "SystemData"},
"block_size_bytes": {"key": "properties.blockSizeBytes", "type": "int"},
"disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"},
"dynamic": {"key": "properties.dynamic", "type": "bool"},
"logical_sector_bytes": {"key": "properties.logicalSectorBytes", "type": "int"},
"physical_sector_bytes": {"key": "properties.physicalSectorBytes", "type": "int"},
"hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"},
"disk_file_format": {"key": "properties.diskFileFormat", "type": "str"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"container_id": {"key": "properties.containerId", "type": "str"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"status": {"key": "properties.status", "type": "VirtualHardDiskStatus"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
block_size_bytes: Optional[int] = None,
disk_size_bytes: Optional[int] = None,
dynamic: Optional[bool] = None,
logical_sector_bytes: Optional[int] = None,
physical_sector_bytes: Optional[int] = None,
hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None,
disk_file_format: Optional[Union[str, "_models.DiskFileFormat"]] = None,
container_id: Optional[str] = None,
resource_name: Optional[str] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:keyword block_size_bytes:
:paramtype block_size_bytes: int
:keyword disk_size_bytes: diskSizeBytes - size of the disk in GB.
:paramtype disk_size_bytes: int
:keyword dynamic: Boolean for enabling dynamic sizing on the virtual hard disk.
:paramtype dynamic: bool
:keyword logical_sector_bytes:
:paramtype logical_sector_bytes: int
:keyword physical_sector_bytes:
:paramtype physical_sector_bytes: int
:keyword hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known
values are: "V1" and "V2".
:paramtype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration
:keyword disk_file_format: The format of the actual VHD file [vhd, vhdx]. Known values are:
"vhdx" and "vhd".
:paramtype disk_file_format: str or ~azure.mgmt.azurestackhci.models.DiskFileFormat
:keyword container_id: Storage ContainerID of the storage container to be used for VHD.
:paramtype container_id: str
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.system_data = None
self.block_size_bytes = block_size_bytes
self.disk_size_bytes = disk_size_bytes
self.dynamic = dynamic
self.logical_sector_bytes = logical_sector_bytes
self.physical_sector_bytes = physical_sector_bytes
self.hyper_v_generation = hyper_v_generation
self.disk_file_format = disk_file_format
self.provisioning_state = None
self.container_id = container_id
self.resource_name = resource_name
self.status = None
class VirtualharddisksListResult(_serialization.Model):
"""VirtualharddisksListResult.
:ivar value:
:vartype value: list[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:ivar next_link:
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[Virtualharddisks]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self, *, value: Optional[List["_models.Virtualharddisks"]] = None, next_link: Optional[str] = None, **kwargs
):
"""
:keyword value:
:paramtype value: list[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:keyword next_link:
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class VirtualharddisksPatch(_serialization.Model):
"""The virtual hard disk resource patch definition.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class VirtualHardDiskStatus(_serialization.Model):
"""VirtualHardDiskStatus defines the observed state of virtualharddisks.
:ivar error_code: VirtualHardDisk provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar provisioning_status: The provisioning status of the virtual hard disk.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.VirtualHardDiskStatusProvisioningStatus
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"provisioning_status": {"key": "provisioningStatus", "type": "VirtualHardDiskStatusProvisioningStatus"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
provisioning_status: Optional["_models.VirtualHardDiskStatusProvisioningStatus"] = None,
**kwargs
):
"""
:keyword error_code: VirtualHardDisk provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword provisioning_status: The provisioning status of the virtual hard disk.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.VirtualHardDiskStatusProvisioningStatus
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.provisioning_status = provisioning_status
class VirtualHardDiskStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the virtual hard disk.
:ivar operation_id: The ID of the operation performed on the virtual hard disk.
:vartype operation_id: str
:ivar status: The status of the operation performed on the virtual hard disk [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the virtual hard disk.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the virtual hard disk [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
class Virtualmachines(TrackedResource): # pylint: disable=too-many-instance-attributes
"""The virtual machine resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:ivar identity: Identity for the resource.
:vartype identity: ~azure.mgmt.azurestackhci.models.Identity
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar hardware_profile: HardwareProfile - Specifies the hardware settings for the virtual
machine.
:vartype hardware_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesHardwareProfile
:ivar network_profile: NetworkProfile - describes the network configuration the virtual
machine.
:vartype network_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesNetworkProfile
:ivar os_profile: OsProfile - describes the configuration of the operating system and sets
login data.
:vartype os_profile: ~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfile
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar security_profile: SecurityProfile - Specifies the security settings for the virtual
machine.
:vartype security_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesSecurityProfile
:ivar storage_profile: StorageProfile - contains information about the disks and storage
information for the virtual machine.
:vartype storage_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfile
:ivar provisioning_state: Provisioning state of the gallery image. Known values are:
"Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum
:ivar status: VirtualMachineStatus defines the observed state of virtualmachines.
:vartype status: ~azure.mgmt.azurestackhci.models.VirtualMachineStatus
:ivar guest_agent_profile: Guest agent status properties.
:vartype guest_agent_profile: ~azure.mgmt.azurestackhci.models.GuestAgentProfile
:ivar vm_id: Unique identifier for the vm resource.
:vartype vm_id: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
"vm_id": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"identity": {"key": "identity", "type": "Identity"},
"system_data": {"key": "systemData", "type": "SystemData"},
"hardware_profile": {"key": "properties.hardwareProfile", "type": "VirtualmachinesPropertiesHardwareProfile"},
"network_profile": {"key": "properties.networkProfile", "type": "VirtualmachinesPropertiesNetworkProfile"},
"os_profile": {"key": "properties.osProfile", "type": "VirtualmachinesPropertiesOsProfile"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"security_profile": {"key": "properties.securityProfile", "type": "VirtualmachinesPropertiesSecurityProfile"},
"storage_profile": {"key": "properties.storageProfile", "type": "VirtualmachinesPropertiesStorageProfile"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"status": {"key": "properties.status", "type": "VirtualMachineStatus"},
"guest_agent_profile": {"key": "properties.guestAgentProfile", "type": "GuestAgentProfile"},
"vm_id": {"key": "properties.vmId", "type": "str"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
identity: Optional["_models.Identity"] = None,
hardware_profile: Optional["_models.VirtualmachinesPropertiesHardwareProfile"] = None,
network_profile: Optional["_models.VirtualmachinesPropertiesNetworkProfile"] = None,
os_profile: Optional["_models.VirtualmachinesPropertiesOsProfile"] = None,
resource_name: Optional[str] = None,
security_profile: Optional["_models.VirtualmachinesPropertiesSecurityProfile"] = None,
storage_profile: Optional["_models.VirtualmachinesPropertiesStorageProfile"] = None,
guest_agent_profile: Optional["_models.GuestAgentProfile"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:keyword identity: Identity for the resource.
:paramtype identity: ~azure.mgmt.azurestackhci.models.Identity
:keyword hardware_profile: HardwareProfile - Specifies the hardware settings for the virtual
machine.
:paramtype hardware_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesHardwareProfile
:keyword network_profile: NetworkProfile - describes the network configuration the virtual
machine.
:paramtype network_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesNetworkProfile
:keyword os_profile: OsProfile - describes the configuration of the operating system and sets
login data.
:paramtype os_profile: ~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfile
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
:keyword security_profile: SecurityProfile - Specifies the security settings for the virtual
machine.
:paramtype security_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesSecurityProfile
:keyword storage_profile: StorageProfile - contains information about the disks and storage
information for the virtual machine.
:paramtype storage_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfile
:keyword guest_agent_profile: Guest agent status properties.
:paramtype guest_agent_profile: ~azure.mgmt.azurestackhci.models.GuestAgentProfile
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.identity = identity
self.system_data = None
self.hardware_profile = hardware_profile
self.network_profile = network_profile
self.os_profile = os_profile
self.resource_name = resource_name
self.security_profile = security_profile
self.storage_profile = storage_profile
self.provisioning_state = None
self.status = None
self.guest_agent_profile = guest_agent_profile
self.vm_id = None
class VirtualmachinesListResult(_serialization.Model):
"""VirtualmachinesListResult.
:ivar value:
:vartype value: list[~azure.mgmt.azurestackhci.models.Virtualmachines]
:ivar next_link:
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[Virtualmachines]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self, *, value: Optional[List["_models.Virtualmachines"]] = None, next_link: Optional[str] = None, **kwargs
):
"""
:keyword value:
:paramtype value: list[~azure.mgmt.azurestackhci.models.Virtualmachines]
:keyword next_link:
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class VirtualmachinesPatch(_serialization.Model):
"""The virtual machine resource patch definition.
:ivar properties: Defines the resource properties for the update.
:vartype properties: ~azure.mgmt.azurestackhci.models.VirtualMachineUpdateProperties
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"properties": {"key": "properties", "type": "VirtualMachineUpdateProperties"},
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(
self,
*,
properties: Optional["_models.VirtualMachineUpdateProperties"] = None,
tags: Optional[Dict[str, str]] = None,
**kwargs
):
"""
:keyword properties: Defines the resource properties for the update.
:paramtype properties: ~azure.mgmt.azurestackhci.models.VirtualMachineUpdateProperties
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.properties = properties
self.tags = tags
class VirtualmachinesPropertiesHardwareProfile(_serialization.Model):
"""HardwareProfile - Specifies the hardware settings for the virtual machine.
:ivar vm_size:
:vartype vm_size: str
:ivar processors: number of processors for the virtual machine.
:vartype processors: int
:ivar memory_gb: RAM in gb for the virtual machine.
:vartype memory_gb: int
:ivar dynamic_memory_config:
:vartype dynamic_memory_config:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig
"""
_attribute_map = {
"vm_size": {"key": "vmSize", "type": "str"},
"processors": {"key": "processors", "type": "int"},
"memory_gb": {"key": "memoryGB", "type": "int"},
"dynamic_memory_config": {
"key": "dynamicMemoryConfig",
"type": "VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig",
},
}
def __init__(
self,
*,
vm_size: Optional[str] = None,
processors: Optional[int] = None,
memory_gb: Optional[int] = None,
dynamic_memory_config: Optional["_models.VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig"] = None,
**kwargs
):
"""
:keyword vm_size:
:paramtype vm_size: str
:keyword processors: number of processors for the virtual machine.
:paramtype processors: int
:keyword memory_gb: RAM in gb for the virtual machine.
:paramtype memory_gb: int
:keyword dynamic_memory_config:
:paramtype dynamic_memory_config:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig
"""
super().__init__(**kwargs)
self.vm_size = vm_size
self.processors = processors
self.memory_gb = memory_gb
self.dynamic_memory_config = dynamic_memory_config
class VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig(_serialization.Model):
"""VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig.
:ivar maximum_memory_gb:
:vartype maximum_memory_gb: int
:ivar minimum_memory_gb:
:vartype minimum_memory_gb: int
:ivar target_memory_buffer:
:vartype target_memory_buffer: int
"""
_attribute_map = {
"maximum_memory_gb": {"key": "maximumMemoryGB", "type": "int"},
"minimum_memory_gb": {"key": "minimumMemoryGB", "type": "int"},
"target_memory_buffer": {"key": "targetMemoryBuffer", "type": "int"},
}
def __init__(
self,
*,
maximum_memory_gb: Optional[int] = None,
minimum_memory_gb: Optional[int] = None,
target_memory_buffer: Optional[int] = None,
**kwargs
):
"""
:keyword maximum_memory_gb:
:paramtype maximum_memory_gb: int
:keyword minimum_memory_gb:
:paramtype minimum_memory_gb: int
:keyword target_memory_buffer:
:paramtype target_memory_buffer: int
"""
super().__init__(**kwargs)
self.maximum_memory_gb = maximum_memory_gb
self.minimum_memory_gb = minimum_memory_gb
self.target_memory_buffer = target_memory_buffer
class VirtualmachinesPropertiesNetworkProfile(_serialization.Model):
"""NetworkProfile - describes the network configuration the virtual machine.
:ivar network_interfaces: NetworkInterfaces - list of network interfaces to be attached to the
virtual machine.
:vartype network_interfaces:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem]
"""
_attribute_map = {
"network_interfaces": {
"key": "networkInterfaces",
"type": "[VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem]",
},
}
def __init__(
self,
*,
network_interfaces: Optional[
List["_models.VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem"]
] = None,
**kwargs
):
"""
:keyword network_interfaces: NetworkInterfaces - list of network interfaces to be attached to
the virtual machine.
:paramtype network_interfaces:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem]
"""
super().__init__(**kwargs)
self.network_interfaces = network_interfaces
class VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem(_serialization.Model):
"""VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem.
:ivar id: ID - Resource Id of the network interface.
:vartype id: str
"""
_attribute_map = {
"id": {"key": "id", "type": "str"},
}
def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin
"""
:keyword id: ID - Resource Id of the network interface.
:paramtype id: str
"""
super().__init__(**kwargs)
self.id = id
class VirtualmachinesPropertiesOsProfile(_serialization.Model):
"""OsProfile - describes the configuration of the operating system and sets login data.
:ivar admin_password: AdminPassword - admin password.
:vartype admin_password: str
:ivar admin_username: AdminUsername - admin username.
:vartype admin_username: str
:ivar computer_name: ComputerName - name of the compute.
:vartype computer_name: str
:ivar linux_configuration: LinuxConfiguration - linux specific configuration values for the
virtual machine.
:vartype linux_configuration:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileLinuxConfiguration
:ivar os_type: OsType - string specifying whether the OS is Linux or Windows. Known values are:
"Linux" and "Windows".
:vartype os_type: str or ~azure.mgmt.azurestackhci.models.OsTypeEnum
:ivar windows_configuration: Windows Configuration for the virtual machine.
:vartype windows_configuration:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileWindowsConfiguration
"""
_attribute_map = {
"admin_password": {"key": "adminPassword", "type": "str"},
"admin_username": {"key": "adminUsername", "type": "str"},
"computer_name": {"key": "computerName", "type": "str"},
"linux_configuration": {
"key": "linuxConfiguration",
"type": "VirtualmachinesPropertiesOsProfileLinuxConfiguration",
},
"os_type": {"key": "osType", "type": "str"},
"windows_configuration": {
"key": "windowsConfiguration",
"type": "VirtualmachinesPropertiesOsProfileWindowsConfiguration",
},
}
def __init__(
self,
*,
admin_password: Optional[str] = None,
admin_username: Optional[str] = None,
computer_name: Optional[str] = None,
linux_configuration: Optional["_models.VirtualmachinesPropertiesOsProfileLinuxConfiguration"] = None,
os_type: Optional[Union[str, "_models.OsTypeEnum"]] = None,
windows_configuration: Optional["_models.VirtualmachinesPropertiesOsProfileWindowsConfiguration"] = None,
**kwargs
):
"""
:keyword admin_password: AdminPassword - admin password.
:paramtype admin_password: str
:keyword admin_username: AdminUsername - admin username.
:paramtype admin_username: str
:keyword computer_name: ComputerName - name of the compute.
:paramtype computer_name: str
:keyword linux_configuration: LinuxConfiguration - linux specific configuration values for the
virtual machine.
:paramtype linux_configuration:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileLinuxConfiguration
:keyword os_type: OsType - string specifying whether the OS is Linux or Windows. Known values
are: "Linux" and "Windows".
:paramtype os_type: str or ~azure.mgmt.azurestackhci.models.OsTypeEnum
:keyword windows_configuration: Windows Configuration for the virtual machine.
:paramtype windows_configuration:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileWindowsConfiguration
"""
super().__init__(**kwargs)
self.admin_password = admin_password
self.admin_username = admin_username
self.computer_name = computer_name
self.linux_configuration = linux_configuration
self.os_type = os_type
self.windows_configuration = windows_configuration
class VirtualmachinesPropertiesOsProfileLinuxConfiguration(_serialization.Model):
"""LinuxConfiguration - linux specific configuration values for the virtual machine.
:ivar disable_password_authentication: DisablePasswordAuthentication - whether password
authentication should be disabled.
:vartype disable_password_authentication: bool
:ivar ssh: SSH - contains settings related to ssh configuration.
:vartype ssh:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh
:ivar provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should be
triggered during the virtual machine creation process.
:vartype provision_vm_agent: bool
"""
_attribute_map = {
"disable_password_authentication": {"key": "disablePasswordAuthentication", "type": "bool"},
"ssh": {"key": "ssh", "type": "VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh"},
"provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"},
}
def __init__(
self,
*,
disable_password_authentication: Optional[bool] = None,
ssh: Optional["_models.VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh"] = None,
provision_vm_agent: Optional[bool] = None,
**kwargs
):
"""
:keyword disable_password_authentication: DisablePasswordAuthentication - whether password
authentication should be disabled.
:paramtype disable_password_authentication: bool
:keyword ssh: SSH - contains settings related to ssh configuration.
:paramtype ssh:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh
:keyword provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should
be triggered during the virtual machine creation process.
:paramtype provision_vm_agent: bool
"""
super().__init__(**kwargs)
self.disable_password_authentication = disable_password_authentication
self.ssh = ssh
self.provision_vm_agent = provision_vm_agent
class VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh(_serialization.Model):
"""SSH - contains settings related to ssh configuration.
:ivar public_keys: PublicKeys - The list of SSH public keys used to authenticate with linux
based VMs.
:vartype public_keys:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem]
"""
_attribute_map = {
"public_keys": {
"key": "publicKeys",
"type": "[VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem]",
},
}
def __init__(
self,
*,
public_keys: Optional[
List["_models.VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem"]
] = None,
**kwargs
):
"""
:keyword public_keys: PublicKeys - The list of SSH public keys used to authenticate with linux
based VMs.
:paramtype public_keys:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem]
"""
super().__init__(**kwargs)
self.public_keys = public_keys
class VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem(_serialization.Model):
"""VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem.
:ivar key_data: KeyData - SSH public key certificate used to authenticate with the VM through
ssh. The key needs to be at least 2048-bit and in ssh-rsa format. :code:`<br>`:code:`<br>` For
creating ssh keys, see `Create SSH keys on Linux and Mac for Li nux VMs in Azure
<https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-mac-create-ssh-keys?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json>`_.
:vartype key_data: str
:ivar path: Path - Specifies the full path on the created VM where ssh public key is stored. If
the file already exists, the specified key is appended to the file. Example:
/home/user/.ssh/authorized_keys.
:vartype path: str
"""
_attribute_map = {
"key_data": {"key": "keyData", "type": "str"},
"path": {"key": "path", "type": "str"},
}
def __init__(self, *, key_data: Optional[str] = None, path: Optional[str] = None, **kwargs):
"""
:keyword key_data: KeyData - SSH public key certificate used to authenticate with the VM
through ssh. The key needs to be at least 2048-bit and in ssh-rsa format.
:code:`<br>`:code:`<br>` For creating ssh keys, see `Create SSH keys on Linux and Mac for Li
nux VMs in Azure
<https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-mac-create-ssh-keys?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json>`_.
:paramtype key_data: str
:keyword path: Path - Specifies the full path on the created VM where ssh public key is stored.
If the file already exists, the specified key is appended to the file. Example:
/home/user/.ssh/authorized_keys.
:paramtype path: str
"""
super().__init__(**kwargs)
self.key_data = key_data
self.path = path
class VirtualmachinesPropertiesOsProfileWindowsConfiguration(_serialization.Model):
"""Windows Configuration for the virtual machine.
:ivar enable_automatic_updates: Whether to EnableAutomaticUpdates on the machine.
:vartype enable_automatic_updates: bool
:ivar ssh: SSH Configuration.
:vartype ssh:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh
:ivar time_zone: TimeZone for the virtual machine.
:vartype time_zone: str
:ivar provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should be
triggered during the virtual machine creation process.
:vartype provision_vm_agent: bool
"""
_attribute_map = {
"enable_automatic_updates": {"key": "enableAutomaticUpdates", "type": "bool"},
"ssh": {"key": "ssh", "type": "VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh"},
"time_zone": {"key": "timeZone", "type": "str"},
"provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"},
}
def __init__(
self,
*,
enable_automatic_updates: Optional[bool] = None,
ssh: Optional["_models.VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh"] = None,
time_zone: Optional[str] = None,
provision_vm_agent: Optional[bool] = None,
**kwargs
):
"""
:keyword enable_automatic_updates: Whether to EnableAutomaticUpdates on the machine.
:paramtype enable_automatic_updates: bool
:keyword ssh: SSH Configuration.
:paramtype ssh:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh
:keyword time_zone: TimeZone for the virtual machine.
:paramtype time_zone: str
:keyword provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should
be triggered during the virtual machine creation process.
:paramtype provision_vm_agent: bool
"""
super().__init__(**kwargs)
self.enable_automatic_updates = enable_automatic_updates
self.ssh = ssh
self.time_zone = time_zone
self.provision_vm_agent = provision_vm_agent
class VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh(_serialization.Model):
"""SSH Configuration.
:ivar public_keys: PublicKeys - The list of SSH public keys used to authenticate with linux
based VMs.
:vartype public_keys:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem]
"""
_attribute_map = {
"public_keys": {
"key": "publicKeys",
"type": "[VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem]",
},
}
def __init__(
self,
*,
public_keys: Optional[
List["_models.VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem"]
] = None,
**kwargs
):
"""
:keyword public_keys: PublicKeys - The list of SSH public keys used to authenticate with linux
based VMs.
:paramtype public_keys:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem]
"""
super().__init__(**kwargs)
self.public_keys = public_keys
class VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem(_serialization.Model):
"""VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem.
:ivar key_data: KeyData - SSH public key certificate used to authenticate with the VM through
ssh. The key needs to be at least 2048-bit and in ssh-rsa format. :code:`<br>`:code:`<br>` For
creating ssh keys, see `Create SSH keys on Linux and Mac for Li nux VMs in Azure
<https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-mac-create-ssh-keys?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json>`_.
:vartype key_data: str
:ivar path: Path - Specifies the full path on the created VM where ssh public key is stored. If
the file already exists, the specified key is appended to the file. Example:
/home/user/.ssh/authorized_keys.
:vartype path: str
"""
_attribute_map = {
"key_data": {"key": "keyData", "type": "str"},
"path": {"key": "path", "type": "str"},
}
def __init__(self, *, key_data: Optional[str] = None, path: Optional[str] = None, **kwargs):
"""
:keyword key_data: KeyData - SSH public key certificate used to authenticate with the VM
through ssh. The key needs to be at least 2048-bit and in ssh-rsa format.
:code:`<br>`:code:`<br>` For creating ssh keys, see `Create SSH keys on Linux and Mac for Li
nux VMs in Azure
<https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-mac-create-ssh-keys?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json>`_.
:paramtype key_data: str
:keyword path: Path - Specifies the full path on the created VM where ssh public key is stored.
If the file already exists, the specified key is appended to the file. Example:
/home/user/.ssh/authorized_keys.
:paramtype path: str
"""
super().__init__(**kwargs)
self.key_data = key_data
self.path = path
class VirtualmachinesPropertiesSecurityProfile(_serialization.Model):
"""SecurityProfile - Specifies the security settings for the virtual machine.
:ivar enable_tpm:
:vartype enable_tpm: bool
:ivar uefi_settings:
:vartype uefi_settings:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesSecurityProfileUefiSettings
"""
_attribute_map = {
"enable_tpm": {"key": "enableTPM", "type": "bool"},
"uefi_settings": {"key": "uefiSettings", "type": "VirtualmachinesPropertiesSecurityProfileUefiSettings"},
}
def __init__(
self,
*,
enable_tpm: Optional[bool] = None,
uefi_settings: Optional["_models.VirtualmachinesPropertiesSecurityProfileUefiSettings"] = None,
**kwargs
):
"""
:keyword enable_tpm:
:paramtype enable_tpm: bool
:keyword uefi_settings:
:paramtype uefi_settings:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesSecurityProfileUefiSettings
"""
super().__init__(**kwargs)
self.enable_tpm = enable_tpm
self.uefi_settings = uefi_settings
class VirtualmachinesPropertiesSecurityProfileUefiSettings(_serialization.Model):
"""VirtualmachinesPropertiesSecurityProfileUefiSettings.
:ivar secure_boot_enabled: Specifies whether secure boot should be enabled on the virtual
machine.
:vartype secure_boot_enabled: bool
"""
_attribute_map = {
"secure_boot_enabled": {"key": "secureBootEnabled", "type": "bool"},
}
def __init__(self, *, secure_boot_enabled: Optional[bool] = None, **kwargs):
"""
:keyword secure_boot_enabled: Specifies whether secure boot should be enabled on the virtual
machine.
:paramtype secure_boot_enabled: bool
"""
super().__init__(**kwargs)
self.secure_boot_enabled = secure_boot_enabled
class VirtualmachinesPropertiesStorageProfile(_serialization.Model):
"""StorageProfile - contains information about the disks and storage information for the virtual machine.
:ivar data_disks: adds data disks to the virtual machine.
:vartype data_disks:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfileDataDisksItem]
:ivar image_reference: Which Image to use for the virtual machine.
:vartype image_reference:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfileImageReference
:ivar os_disk: VHD to attach as OS disk.
:vartype os_disk:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfileOsDisk
:ivar vm_config_container_name: Name of the storage container that hosts the VM configuration
file.
:vartype vm_config_container_name: str
"""
_attribute_map = {
"data_disks": {"key": "dataDisks", "type": "[VirtualmachinesPropertiesStorageProfileDataDisksItem]"},
"image_reference": {"key": "imageReference", "type": "VirtualmachinesPropertiesStorageProfileImageReference"},
"os_disk": {"key": "osDisk", "type": "VirtualmachinesPropertiesStorageProfileOsDisk"},
"vm_config_container_name": {"key": "vmConfigContainerName", "type": "str"},
}
def __init__(
self,
*,
data_disks: Optional[List["_models.VirtualmachinesPropertiesStorageProfileDataDisksItem"]] = None,
image_reference: Optional["_models.VirtualmachinesPropertiesStorageProfileImageReference"] = None,
os_disk: Optional["_models.VirtualmachinesPropertiesStorageProfileOsDisk"] = None,
vm_config_container_name: Optional[str] = None,
**kwargs
):
"""
:keyword data_disks: adds data disks to the virtual machine.
:paramtype data_disks:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfileDataDisksItem]
:keyword image_reference: Which Image to use for the virtual machine.
:paramtype image_reference:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfileImageReference
:keyword os_disk: VHD to attach as OS disk.
:paramtype os_disk:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfileOsDisk
:keyword vm_config_container_name: Name of the storage container that hosts the VM
configuration file.
:paramtype vm_config_container_name: str
"""
super().__init__(**kwargs)
self.data_disks = data_disks
self.image_reference = image_reference
self.os_disk = os_disk
self.vm_config_container_name = vm_config_container_name
class VirtualmachinesPropertiesStorageProfileDataDisksItem(_serialization.Model):
"""VirtualmachinesPropertiesStorageProfileDataDisksItem.
:ivar name:
:vartype name: str
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
}
def __init__(self, *, name: Optional[str] = None, **kwargs):
"""
:keyword name:
:paramtype name: str
"""
super().__init__(**kwargs)
self.name = name
class VirtualmachinesPropertiesStorageProfileImageReference(_serialization.Model):
"""Which Image to use for the virtual machine.
:ivar name: Name - Name of the image.
:vartype name: str
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
}
def __init__(self, *, name: Optional[str] = None, **kwargs):
"""
:keyword name: Name - Name of the image.
:paramtype name: str
"""
super().__init__(**kwargs)
self.name = name
class VirtualmachinesPropertiesStorageProfileOsDisk(_serialization.Model):
"""VHD to attach as OS disk.
:ivar id: Specifies the virtual hard disk's ID.
:vartype id: str
"""
_attribute_map = {
"id": {"key": "id", "type": "str"},
}
def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin
"""
:keyword id: Specifies the virtual hard disk's ID.
:paramtype id: str
"""
super().__init__(**kwargs)
self.id = id
class VirtualMachineStatus(_serialization.Model):
"""VirtualMachineStatus defines the observed state of virtualmachines.
:ivar error_code: VirtualMachine provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar power_state: The power state of the virtual machine. Known values are: "Deallocated",
"Deallocating", "Running", "Starting", "Stopped", "Stopping", and "Unknown".
:vartype power_state: str or ~azure.mgmt.azurestackhci.models.PowerStateEnum
:ivar provisioning_status: The provisioning status of the virtual machine.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.VirtualMachineStatusProvisioningStatus
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"power_state": {"key": "powerState", "type": "str"},
"provisioning_status": {"key": "provisioningStatus", "type": "VirtualMachineStatusProvisioningStatus"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
power_state: Optional[Union[str, "_models.PowerStateEnum"]] = None,
provisioning_status: Optional["_models.VirtualMachineStatusProvisioningStatus"] = None,
**kwargs
):
"""
:keyword error_code: VirtualMachine provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword power_state: The power state of the virtual machine. Known values are: "Deallocated",
"Deallocating", "Running", "Starting", "Stopped", "Stopping", and "Unknown".
:paramtype power_state: str or ~azure.mgmt.azurestackhci.models.PowerStateEnum
:keyword provisioning_status: The provisioning status of the virtual machine.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.VirtualMachineStatusProvisioningStatus
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.power_state = power_state
self.provisioning_status = provisioning_status
class VirtualMachineStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the virtual machine.
:ivar operation_id: The ID of the operation performed on the virtual machine.
:vartype operation_id: str
:ivar status: The status of the operation performed on the virtual machine [Succeeded, Failed,
InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the virtual machine.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the virtual machine [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
class VirtualMachineUpdateProperties(_serialization.Model):
"""Defines the resource properties for the update.
:ivar hardware_profile: HardwareProfile - Specifies the hardware settings for the virtual
machine.
:vartype hardware_profile: ~azure.mgmt.azurestackhci.models.HardwareProfileUpdate
:ivar storage_profile:
:vartype storage_profile: ~azure.mgmt.azurestackhci.models.StorageProfileUpdate
:ivar network_profile: NetworkProfile - describes the network update configuration the virtual
machine.
:vartype network_profile: ~azure.mgmt.azurestackhci.models.NetworkProfileUpdate
"""
_attribute_map = {
"hardware_profile": {"key": "hardwareProfile", "type": "HardwareProfileUpdate"},
"storage_profile": {"key": "storageProfile", "type": "StorageProfileUpdate"},
"network_profile": {"key": "networkProfile", "type": "NetworkProfileUpdate"},
}
def __init__(
self,
*,
hardware_profile: Optional["_models.HardwareProfileUpdate"] = None,
storage_profile: Optional["_models.StorageProfileUpdate"] = None,
network_profile: Optional["_models.NetworkProfileUpdate"] = None,
**kwargs
):
"""
:keyword hardware_profile: HardwareProfile - Specifies the hardware settings for the virtual
machine.
:paramtype hardware_profile: ~azure.mgmt.azurestackhci.models.HardwareProfileUpdate
:keyword storage_profile:
:paramtype storage_profile: ~azure.mgmt.azurestackhci.models.StorageProfileUpdate
:keyword network_profile: NetworkProfile - describes the network update configuration the
virtual machine.
:paramtype network_profile: ~azure.mgmt.azurestackhci.models.NetworkProfileUpdate
"""
super().__init__(**kwargs)
self.hardware_profile = hardware_profile
self.storage_profile = storage_profile
self.network_profile = network_profile
class Virtualnetworks(TrackedResource): # pylint: disable=too-many-instance-attributes
"""The virtual network resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar network_type: Type of the network. Known values are: "NAT", "Transparent", "L2Bridge",
"L2Tunnel", "ICS", "Private", "Overlay", "Internal", and "Mirrored".
:vartype network_type: str or ~azure.mgmt.azurestackhci.models.NetworkTypeEnum
:ivar subnets: Subnet - list of subnets under the virtual network.
:vartype subnets: list[~azure.mgmt.azurestackhci.models.VirtualnetworksPropertiesSubnetsItem]
:ivar provisioning_state: Provisioning state of the gallery image. Known values are:
"Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar status: VirtualNetworkStatus defines the observed state of virtual networks.
:vartype status: ~azure.mgmt.azurestackhci.models.VirtualNetworkStatus
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"system_data": {"key": "systemData", "type": "SystemData"},
"network_type": {"key": "properties.networkType", "type": "str"},
"subnets": {"key": "properties.subnets", "type": "[VirtualnetworksPropertiesSubnetsItem]"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"status": {"key": "properties.status", "type": "VirtualNetworkStatus"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
network_type: Optional[Union[str, "_models.NetworkTypeEnum"]] = None,
subnets: Optional[List["_models.VirtualnetworksPropertiesSubnetsItem"]] = None,
resource_name: Optional[str] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:keyword network_type: Type of the network. Known values are: "NAT", "Transparent", "L2Bridge",
"L2Tunnel", "ICS", "Private", "Overlay", "Internal", and "Mirrored".
:paramtype network_type: str or ~azure.mgmt.azurestackhci.models.NetworkTypeEnum
:keyword subnets: Subnet - list of subnets under the virtual network.
:paramtype subnets: list[~azure.mgmt.azurestackhci.models.VirtualnetworksPropertiesSubnetsItem]
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.system_data = None
self.network_type = network_type
self.subnets = subnets
self.provisioning_state = None
self.resource_name = resource_name
self.status = None
class VirtualnetworksListResult(_serialization.Model):
"""VirtualnetworksListResult.
:ivar value:
:vartype value: list[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:ivar next_link:
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[Virtualnetworks]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self, *, value: Optional[List["_models.Virtualnetworks"]] = None, next_link: Optional[str] = None, **kwargs
):
"""
:keyword value:
:paramtype value: list[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:keyword next_link:
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class VirtualnetworksPatch(_serialization.Model):
"""The virtual network resource patch definition.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class VirtualnetworksPropertiesSubnetsItem(_serialization.Model):
"""Subnet subnet in a virtual network resource.
:ivar name: Name - The name of the resource that is unique within a resource group. This name
can be used to access the resource.
:vartype name: str
:ivar address_prefix: Cidr for this subnet - IPv4, IPv6.
:vartype address_prefix: str
:ivar address_prefixes: AddressPrefixes - List of address prefixes for the subnet.
:vartype address_prefixes: list[str]
:ivar ip_allocation_method: IPAllocationMethod - The IP address allocation method. Possible
values include: 'Static', 'Dynamic'. Known values are: "Dynamic" and "Static".
:vartype ip_allocation_method: str or ~azure.mgmt.azurestackhci.models.IpAllocationMethodEnum
:ivar ip_configuration_references: IPConfigurationReferences - list of
IPConfigurationReferences.
:vartype ip_configuration_references:
list[~azure.mgmt.azurestackhci.models.ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems]
:ivar route_table: RouteTable for the subnet.
:vartype route_table:
~azure.mgmt.azurestackhci.models.ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable
:ivar ip_pools: network associated pool of IP Addresses.
:vartype ip_pools: list[~azure.mgmt.azurestackhci.models.IPPool]
:ivar vlan: Vlan to use for the subnet.
:vartype vlan: int
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"address_prefix": {"key": "properties.addressPrefix", "type": "str"},
"address_prefixes": {"key": "properties.addressPrefixes", "type": "[str]"},
"ip_allocation_method": {"key": "properties.ipAllocationMethod", "type": "str"},
"ip_configuration_references": {
"key": "properties.ipConfigurationReferences",
"type": "[ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems]",
},
"route_table": {
"key": "properties.routeTable",
"type": "ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable",
},
"ip_pools": {"key": "properties.ipPools", "type": "[IPPool]"},
"vlan": {"key": "properties.vlan", "type": "int"},
}
def __init__(
self,
*,
name: Optional[str] = None,
address_prefix: Optional[str] = None,
address_prefixes: Optional[List[str]] = None,
ip_allocation_method: Optional[Union[str, "_models.IpAllocationMethodEnum"]] = None,
ip_configuration_references: Optional[
List[
"_models.ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems"
]
] = None,
route_table: Optional[
"_models.ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable"
] = None,
ip_pools: Optional[List["_models.IPPool"]] = None,
vlan: Optional[int] = None,
**kwargs
):
"""
:keyword name: Name - The name of the resource that is unique within a resource group. This
name can be used to access the resource.
:paramtype name: str
:keyword address_prefix: Cidr for this subnet - IPv4, IPv6.
:paramtype address_prefix: str
:keyword address_prefixes: AddressPrefixes - List of address prefixes for the subnet.
:paramtype address_prefixes: list[str]
:keyword ip_allocation_method: IPAllocationMethod - The IP address allocation method. Possible
values include: 'Static', 'Dynamic'. Known values are: "Dynamic" and "Static".
:paramtype ip_allocation_method: str or ~azure.mgmt.azurestackhci.models.IpAllocationMethodEnum
:keyword ip_configuration_references: IPConfigurationReferences - list of
IPConfigurationReferences.
:paramtype ip_configuration_references:
list[~azure.mgmt.azurestackhci.models.ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems]
:keyword route_table: RouteTable for the subnet.
:paramtype route_table:
~azure.mgmt.azurestackhci.models.ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable
:keyword ip_pools: network associated pool of IP Addresses.
:paramtype ip_pools: list[~azure.mgmt.azurestackhci.models.IPPool]
:keyword vlan: Vlan to use for the subnet.
:paramtype vlan: int
"""
super().__init__(**kwargs)
self.name = name
self.address_prefix = address_prefix
self.address_prefixes = address_prefixes
self.ip_allocation_method = ip_allocation_method
self.ip_configuration_references = ip_configuration_references
self.route_table = route_table
self.ip_pools = ip_pools
self.vlan = vlan
class VirtualnetworksPropertiesSubnetsPropertiesItemsItem(_serialization.Model):
"""Route is associated with a subnet.
:ivar name: Name - name of the subnet.
:vartype name: str
:ivar address_prefix: AddressPrefix - The destination CIDR to which the route applies.
:vartype address_prefix: str
:ivar next_hop_ip_address: NextHopIPAddress - The IP address packets should be forwarded to.
Next hop values are only allowed in routes where the next hop type is VirtualAppliance.
:vartype next_hop_ip_address: str
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"address_prefix": {"key": "properties.addressPrefix", "type": "str"},
"next_hop_ip_address": {"key": "properties.nextHopIpAddress", "type": "str"},
}
def __init__(
self,
*,
name: Optional[str] = None,
address_prefix: Optional[str] = None,
next_hop_ip_address: Optional[str] = None,
**kwargs
):
"""
:keyword name: Name - name of the subnet.
:paramtype name: str
:keyword address_prefix: AddressPrefix - The destination CIDR to which the route applies.
:paramtype address_prefix: str
:keyword next_hop_ip_address: NextHopIPAddress - The IP address packets should be forwarded to.
Next hop values are only allowed in routes where the next hop type is VirtualAppliance.
:paramtype next_hop_ip_address: str
"""
super().__init__(**kwargs)
self.name = name
self.address_prefix = address_prefix
self.next_hop_ip_address = next_hop_ip_address
class VirtualNetworkStatus(_serialization.Model):
"""VirtualNetworkStatus defines the observed state of virtual networks.
:ivar error_code: VirtualNetwork provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar provisioning_status: The provisioning status of the virtual network.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.VirtualNetworkStatusProvisioningStatus
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"provisioning_status": {"key": "provisioningStatus", "type": "VirtualNetworkStatusProvisioningStatus"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
provisioning_status: Optional["_models.VirtualNetworkStatusProvisioningStatus"] = None,
**kwargs
):
"""
:keyword error_code: VirtualNetwork provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword provisioning_status: The provisioning status of the virtual network.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.VirtualNetworkStatusProvisioningStatus
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.provisioning_status = provisioning_status
class VirtualNetworkStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the virtual network.
:ivar operation_id: The ID of the operation performed on the virtual network.
:vartype operation_id: str
:ivar status: The status of the operation performed on the virtual network [Succeeded, Failed,
InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the virtual network.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the virtual network [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/models/_models_py3.py
|
_models_py3.py
|
import datetime
import sys
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union
from .. import _serialization
if sys.version_info >= (3, 9):
from collections.abc import MutableMapping
else:
from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from .. import models as _models
JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object
class Resource(_serialization.Model):
"""Common fields that are returned in the response for all Azure Resource Manager resources.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.id = None
self.name = None
self.type = None
class ProxyResource(Resource):
"""The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
class ArcSetting(ProxyResource): # pylint: disable=too-many-instance-attributes
"""ArcSetting details.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar provisioning_state: Provisioning state of the ArcSetting proxy resource. Known values
are: "Succeeded", "Failed", "Canceled", "Accepted", and "Provisioning".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState
:ivar arc_instance_resource_group: The resource group that hosts the Arc agents, ie. Hybrid
Compute Machine resources.
:vartype arc_instance_resource_group: str
:ivar aggregate_state: Aggregate state of Arc agent across the nodes in this HCI cluster. Known
values are: "NotSpecified", "Error", "Succeeded", "Canceled", "Failed", "Connected",
"Disconnected", "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded",
"PartiallyConnected", and "InProgress".
:vartype aggregate_state: str or ~azure.mgmt.azurestackhci.models.ArcSettingAggregateState
:ivar per_node_details: State of Arc agent in each of the nodes.
:vartype per_node_details: list[~azure.mgmt.azurestackhci.models.PerNodeState]
:ivar created_by: The identity that created the resource.
:vartype created_by: str
:ivar created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:vartype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar created_at: The timestamp of resource creation (UTC).
:vartype created_at: ~datetime.datetime
:ivar last_modified_by: The identity that last modified the resource.
:vartype last_modified_by: str
:ivar last_modified_by_type: The type of identity that last modified the resource. Known values
are: "User", "Application", "ManagedIdentity", and "Key".
:vartype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar last_modified_at: The timestamp of resource last modification (UTC).
:vartype last_modified_at: ~datetime.datetime
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"provisioning_state": {"readonly": True},
"arc_instance_resource_group": {"readonly": True},
"aggregate_state": {"readonly": True},
"per_node_details": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"arc_instance_resource_group": {"key": "properties.arcInstanceResourceGroup", "type": "str"},
"aggregate_state": {"key": "properties.aggregateState", "type": "str"},
"per_node_details": {"key": "properties.perNodeDetails", "type": "[PerNodeState]"},
"created_by": {"key": "systemData.createdBy", "type": "str"},
"created_by_type": {"key": "systemData.createdByType", "type": "str"},
"created_at": {"key": "systemData.createdAt", "type": "iso-8601"},
"last_modified_by": {"key": "systemData.lastModifiedBy", "type": "str"},
"last_modified_by_type": {"key": "systemData.lastModifiedByType", "type": "str"},
"last_modified_at": {"key": "systemData.lastModifiedAt", "type": "iso-8601"},
}
def __init__(
self,
*,
created_by: Optional[str] = None,
created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
created_at: Optional[datetime.datetime] = None,
last_modified_by: Optional[str] = None,
last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
last_modified_at: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword created_by: The identity that created the resource.
:paramtype created_by: str
:keyword created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:paramtype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword created_at: The timestamp of resource creation (UTC).
:paramtype created_at: ~datetime.datetime
:keyword last_modified_by: The identity that last modified the resource.
:paramtype last_modified_by: str
:keyword last_modified_by_type: The type of identity that last modified the resource. Known
values are: "User", "Application", "ManagedIdentity", and "Key".
:paramtype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword last_modified_at: The timestamp of resource last modification (UTC).
:paramtype last_modified_at: ~datetime.datetime
"""
super().__init__(**kwargs)
self.provisioning_state = None
self.arc_instance_resource_group = None
self.aggregate_state = None
self.per_node_details = None
self.created_by = created_by
self.created_by_type = created_by_type
self.created_at = created_at
self.last_modified_by = last_modified_by
self.last_modified_by_type = last_modified_by_type
self.last_modified_at = last_modified_at
class ArcSettingList(_serialization.Model):
"""List of ArcSetting proxy resources for the HCI cluster.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of ArcSetting proxy resources.
:vartype value: list[~azure.mgmt.azurestackhci.models.ArcSetting]
:ivar next_link: Link to the next set of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[ArcSetting]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class TrackedResource(Resource):
"""The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
}
def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
"""
super().__init__(**kwargs)
self.tags = tags
self.location = location
class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes
"""Cluster details.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar provisioning_state: Provisioning state. Known values are: "Succeeded", "Failed",
"Canceled", "Accepted", and "Provisioning".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState
:ivar status: Status of the cluster agent. Known values are: "NotYetRegistered",
"ConnectedRecently", "NotConnectedRecently", "Disconnected", and "Error".
:vartype status: str or ~azure.mgmt.azurestackhci.models.Status
:ivar cloud_id: Unique, immutable resource id.
:vartype cloud_id: str
:ivar cloud_management_endpoint: Endpoint configured for management from the Azure portal.
:vartype cloud_management_endpoint: str
:ivar aad_client_id: App id of cluster AAD identity.
:vartype aad_client_id: str
:ivar aad_tenant_id: Tenant id of cluster AAD identity.
:vartype aad_tenant_id: str
:ivar desired_properties: Desired properties of the cluster.
:vartype desired_properties: ~azure.mgmt.azurestackhci.models.ClusterDesiredProperties
:ivar reported_properties: Properties reported by cluster agent.
:vartype reported_properties: ~azure.mgmt.azurestackhci.models.ClusterReportedProperties
:ivar trial_days_remaining: Number of days remaining in the trial period.
:vartype trial_days_remaining: float
:ivar billing_model: Type of billing applied to the resource.
:vartype billing_model: str
:ivar registration_timestamp: First cluster sync timestamp.
:vartype registration_timestamp: ~datetime.datetime
:ivar last_sync_timestamp: Most recent cluster sync timestamp.
:vartype last_sync_timestamp: ~datetime.datetime
:ivar last_billing_timestamp: Most recent billing meter timestamp.
:vartype last_billing_timestamp: ~datetime.datetime
:ivar created_by: The identity that created the resource.
:vartype created_by: str
:ivar created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:vartype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar created_at: The timestamp of resource creation (UTC).
:vartype created_at: ~datetime.datetime
:ivar last_modified_by: The identity that last modified the resource.
:vartype last_modified_by: str
:ivar last_modified_by_type: The type of identity that last modified the resource. Known values
are: "User", "Application", "ManagedIdentity", and "Key".
:vartype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar last_modified_at: The timestamp of resource last modification (UTC).
:vartype last_modified_at: ~datetime.datetime
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
"cloud_id": {"readonly": True},
"reported_properties": {"readonly": True},
"trial_days_remaining": {"readonly": True},
"billing_model": {"readonly": True},
"registration_timestamp": {"readonly": True},
"last_sync_timestamp": {"readonly": True},
"last_billing_timestamp": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"status": {"key": "properties.status", "type": "str"},
"cloud_id": {"key": "properties.cloudId", "type": "str"},
"cloud_management_endpoint": {"key": "properties.cloudManagementEndpoint", "type": "str"},
"aad_client_id": {"key": "properties.aadClientId", "type": "str"},
"aad_tenant_id": {"key": "properties.aadTenantId", "type": "str"},
"desired_properties": {"key": "properties.desiredProperties", "type": "ClusterDesiredProperties"},
"reported_properties": {"key": "properties.reportedProperties", "type": "ClusterReportedProperties"},
"trial_days_remaining": {"key": "properties.trialDaysRemaining", "type": "float"},
"billing_model": {"key": "properties.billingModel", "type": "str"},
"registration_timestamp": {"key": "properties.registrationTimestamp", "type": "iso-8601"},
"last_sync_timestamp": {"key": "properties.lastSyncTimestamp", "type": "iso-8601"},
"last_billing_timestamp": {"key": "properties.lastBillingTimestamp", "type": "iso-8601"},
"created_by": {"key": "systemData.createdBy", "type": "str"},
"created_by_type": {"key": "systemData.createdByType", "type": "str"},
"created_at": {"key": "systemData.createdAt", "type": "iso-8601"},
"last_modified_by": {"key": "systemData.lastModifiedBy", "type": "str"},
"last_modified_by_type": {"key": "systemData.lastModifiedByType", "type": "str"},
"last_modified_at": {"key": "systemData.lastModifiedAt", "type": "iso-8601"},
}
def __init__( # pylint: disable=too-many-locals
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
cloud_management_endpoint: Optional[str] = None,
aad_client_id: Optional[str] = None,
aad_tenant_id: Optional[str] = None,
desired_properties: Optional["_models.ClusterDesiredProperties"] = None,
created_by: Optional[str] = None,
created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
created_at: Optional[datetime.datetime] = None,
last_modified_by: Optional[str] = None,
last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
last_modified_at: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword cloud_management_endpoint: Endpoint configured for management from the Azure portal.
:paramtype cloud_management_endpoint: str
:keyword aad_client_id: App id of cluster AAD identity.
:paramtype aad_client_id: str
:keyword aad_tenant_id: Tenant id of cluster AAD identity.
:paramtype aad_tenant_id: str
:keyword desired_properties: Desired properties of the cluster.
:paramtype desired_properties: ~azure.mgmt.azurestackhci.models.ClusterDesiredProperties
:keyword created_by: The identity that created the resource.
:paramtype created_by: str
:keyword created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:paramtype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword created_at: The timestamp of resource creation (UTC).
:paramtype created_at: ~datetime.datetime
:keyword last_modified_by: The identity that last modified the resource.
:paramtype last_modified_by: str
:keyword last_modified_by_type: The type of identity that last modified the resource. Known
values are: "User", "Application", "ManagedIdentity", and "Key".
:paramtype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword last_modified_at: The timestamp of resource last modification (UTC).
:paramtype last_modified_at: ~datetime.datetime
"""
super().__init__(tags=tags, location=location, **kwargs)
self.provisioning_state = None
self.status = None
self.cloud_id = None
self.cloud_management_endpoint = cloud_management_endpoint
self.aad_client_id = aad_client_id
self.aad_tenant_id = aad_tenant_id
self.desired_properties = desired_properties
self.reported_properties = None
self.trial_days_remaining = None
self.billing_model = None
self.registration_timestamp = None
self.last_sync_timestamp = None
self.last_billing_timestamp = None
self.created_by = created_by
self.created_by_type = created_by_type
self.created_at = created_at
self.last_modified_by = last_modified_by
self.last_modified_by_type = last_modified_by_type
self.last_modified_at = last_modified_at
class ClusterDesiredProperties(_serialization.Model):
"""Desired properties of the cluster.
:ivar windows_server_subscription: Desired state of Windows Server Subscription. Known values
are: "Disabled" and "Enabled".
:vartype windows_server_subscription: str or
~azure.mgmt.azurestackhci.models.WindowsServerSubscription
:ivar diagnostic_level: Desired level of diagnostic data emitted by the cluster. Known values
are: "Off", "Basic", and "Enhanced".
:vartype diagnostic_level: str or ~azure.mgmt.azurestackhci.models.DiagnosticLevel
"""
_attribute_map = {
"windows_server_subscription": {"key": "windowsServerSubscription", "type": "str"},
"diagnostic_level": {"key": "diagnosticLevel", "type": "str"},
}
def __init__(
self,
*,
windows_server_subscription: Optional[Union[str, "_models.WindowsServerSubscription"]] = None,
diagnostic_level: Optional[Union[str, "_models.DiagnosticLevel"]] = None,
**kwargs
):
"""
:keyword windows_server_subscription: Desired state of Windows Server Subscription. Known
values are: "Disabled" and "Enabled".
:paramtype windows_server_subscription: str or
~azure.mgmt.azurestackhci.models.WindowsServerSubscription
:keyword diagnostic_level: Desired level of diagnostic data emitted by the cluster. Known
values are: "Off", "Basic", and "Enhanced".
:paramtype diagnostic_level: str or ~azure.mgmt.azurestackhci.models.DiagnosticLevel
"""
super().__init__(**kwargs)
self.windows_server_subscription = windows_server_subscription
self.diagnostic_level = diagnostic_level
class ClusterList(_serialization.Model):
"""List of clusters.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of clusters.
:vartype value: list[~azure.mgmt.azurestackhci.models.Cluster]
:ivar next_link: Link to the next set of results.
:vartype next_link: str
"""
_validation = {
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[Cluster]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, *, value: Optional[List["_models.Cluster"]] = None, **kwargs):
"""
:keyword value: List of clusters.
:paramtype value: list[~azure.mgmt.azurestackhci.models.Cluster]
"""
super().__init__(**kwargs)
self.value = value
self.next_link = None
class ClusterNode(_serialization.Model):
"""Cluster node details.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Name of the cluster node.
:vartype name: str
:ivar id: Id of the node in the cluster.
:vartype id: float
:ivar windows_server_subscription: State of Windows Server Subscription. Known values are:
"Disabled" and "Enabled".
:vartype windows_server_subscription: str or
~azure.mgmt.azurestackhci.models.WindowsServerSubscription
:ivar manufacturer: Manufacturer of the cluster node hardware.
:vartype manufacturer: str
:ivar model: Model name of the cluster node hardware.
:vartype model: str
:ivar os_name: Operating system running on the cluster node.
:vartype os_name: str
:ivar os_version: Version of the operating system running on the cluster node.
:vartype os_version: str
:ivar serial_number: Immutable id of the cluster node.
:vartype serial_number: str
:ivar core_count: Number of physical cores on the cluster node.
:vartype core_count: float
:ivar memory_in_gi_b: Total available memory on the cluster node (in GiB).
:vartype memory_in_gi_b: float
"""
_validation = {
"name": {"readonly": True},
"id": {"readonly": True},
"windows_server_subscription": {"readonly": True},
"manufacturer": {"readonly": True},
"model": {"readonly": True},
"os_name": {"readonly": True},
"os_version": {"readonly": True},
"serial_number": {"readonly": True},
"core_count": {"readonly": True},
"memory_in_gi_b": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"id": {"key": "id", "type": "float"},
"windows_server_subscription": {"key": "windowsServerSubscription", "type": "str"},
"manufacturer": {"key": "manufacturer", "type": "str"},
"model": {"key": "model", "type": "str"},
"os_name": {"key": "osName", "type": "str"},
"os_version": {"key": "osVersion", "type": "str"},
"serial_number": {"key": "serialNumber", "type": "str"},
"core_count": {"key": "coreCount", "type": "float"},
"memory_in_gi_b": {"key": "memoryInGiB", "type": "float"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.name = None
self.id = None
self.windows_server_subscription = None
self.manufacturer = None
self.model = None
self.os_name = None
self.os_version = None
self.serial_number = None
self.core_count = None
self.memory_in_gi_b = None
class ClusterPatch(_serialization.Model):
"""Cluster details to update.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar cloud_management_endpoint: Endpoint configured for management from the Azure portal.
:vartype cloud_management_endpoint: str
:ivar aad_client_id: App id of cluster AAD identity.
:vartype aad_client_id: str
:ivar aad_tenant_id: Tenant id of cluster AAD identity.
:vartype aad_tenant_id: str
:ivar desired_properties: Desired properties of the cluster.
:vartype desired_properties: ~azure.mgmt.azurestackhci.models.ClusterDesiredProperties
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
"cloud_management_endpoint": {"key": "properties.cloudManagementEndpoint", "type": "str"},
"aad_client_id": {"key": "properties.aadClientId", "type": "str"},
"aad_tenant_id": {"key": "properties.aadTenantId", "type": "str"},
"desired_properties": {"key": "properties.desiredProperties", "type": "ClusterDesiredProperties"},
}
def __init__(
self,
*,
tags: Optional[Dict[str, str]] = None,
cloud_management_endpoint: Optional[str] = None,
aad_client_id: Optional[str] = None,
aad_tenant_id: Optional[str] = None,
desired_properties: Optional["_models.ClusterDesiredProperties"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword cloud_management_endpoint: Endpoint configured for management from the Azure portal.
:paramtype cloud_management_endpoint: str
:keyword aad_client_id: App id of cluster AAD identity.
:paramtype aad_client_id: str
:keyword aad_tenant_id: Tenant id of cluster AAD identity.
:paramtype aad_tenant_id: str
:keyword desired_properties: Desired properties of the cluster.
:paramtype desired_properties: ~azure.mgmt.azurestackhci.models.ClusterDesiredProperties
"""
super().__init__(**kwargs)
self.tags = tags
self.cloud_management_endpoint = cloud_management_endpoint
self.aad_client_id = aad_client_id
self.aad_tenant_id = aad_tenant_id
self.desired_properties = desired_properties
class ClusterReportedProperties(_serialization.Model):
"""Properties reported by cluster agent.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar cluster_name: Name of the on-prem cluster connected to this resource.
:vartype cluster_name: str
:ivar cluster_id: Unique id generated by the on-prem cluster.
:vartype cluster_id: str
:ivar cluster_version: Version of the cluster software.
:vartype cluster_version: str
:ivar nodes: List of nodes reported by the cluster.
:vartype nodes: list[~azure.mgmt.azurestackhci.models.ClusterNode]
:ivar last_updated: Last time the cluster reported the data.
:vartype last_updated: ~datetime.datetime
:ivar imds_attestation: IMDS attestation status of the cluster. Known values are: "Disabled"
and "Enabled".
:vartype imds_attestation: str or ~azure.mgmt.azurestackhci.models.ImdsAttestation
:ivar diagnostic_level: Level of diagnostic data emitted by the cluster. Known values are:
"Off", "Basic", and "Enhanced".
:vartype diagnostic_level: str or ~azure.mgmt.azurestackhci.models.DiagnosticLevel
"""
_validation = {
"cluster_name": {"readonly": True},
"cluster_id": {"readonly": True},
"cluster_version": {"readonly": True},
"nodes": {"readonly": True},
"last_updated": {"readonly": True},
"imds_attestation": {"readonly": True},
}
_attribute_map = {
"cluster_name": {"key": "clusterName", "type": "str"},
"cluster_id": {"key": "clusterId", "type": "str"},
"cluster_version": {"key": "clusterVersion", "type": "str"},
"nodes": {"key": "nodes", "type": "[ClusterNode]"},
"last_updated": {"key": "lastUpdated", "type": "iso-8601"},
"imds_attestation": {"key": "imdsAttestation", "type": "str"},
"diagnostic_level": {"key": "diagnosticLevel", "type": "str"},
}
def __init__(self, *, diagnostic_level: Optional[Union[str, "_models.DiagnosticLevel"]] = None, **kwargs):
"""
:keyword diagnostic_level: Level of diagnostic data emitted by the cluster. Known values are:
"Off", "Basic", and "Enhanced".
:paramtype diagnostic_level: str or ~azure.mgmt.azurestackhci.models.DiagnosticLevel
"""
super().__init__(**kwargs)
self.cluster_name = None
self.cluster_id = None
self.cluster_version = None
self.nodes = None
self.last_updated = None
self.imds_attestation = None
self.diagnostic_level = diagnostic_level
class ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable(_serialization.Model):
"""RouteTable for the subnet.
:ivar id: Etag - Gets a unique read-only string that changes whenever the resource is updated.
:vartype id: str
:ivar name: Name - READ-ONLY; Resource name.
:vartype name: str
:ivar type: Type - READ-ONLY; Resource type.
:vartype type: str
:ivar routes: Routes - Collection of routes contained within a route table.
:vartype routes:
list[~azure.mgmt.azurestackhci.models.VirtualnetworksPropertiesSubnetsPropertiesItemsItem]
"""
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"routes": {"key": "properties.routes", "type": "[VirtualnetworksPropertiesSubnetsPropertiesItemsItem]"},
}
def __init__(
self,
*,
id: Optional[str] = None, # pylint: disable=redefined-builtin
name: Optional[str] = None,
type: Optional[str] = None,
routes: Optional[List["_models.VirtualnetworksPropertiesSubnetsPropertiesItemsItem"]] = None,
**kwargs
):
"""
:keyword id: Etag - Gets a unique read-only string that changes whenever the resource is
updated.
:paramtype id: str
:keyword name: Name - READ-ONLY; Resource name.
:paramtype name: str
:keyword type: Type - READ-ONLY; Resource type.
:paramtype type: str
:keyword routes: Routes - Collection of routes contained within a route table.
:paramtype routes:
list[~azure.mgmt.azurestackhci.models.VirtualnetworksPropertiesSubnetsPropertiesItemsItem]
"""
super().__init__(**kwargs)
self.id = id
self.name = name
self.type = type
self.routes = routes
class ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems(
_serialization.Model
):
"""IPConfigurationReference - Describes a IPConfiguration under the virtual network.
:ivar id: IPConfigurationID.
:vartype id: str
"""
_attribute_map = {
"id": {"key": "ID", "type": "str"},
}
def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin
"""
:keyword id: IPConfigurationID.
:paramtype id: str
"""
super().__init__(**kwargs)
self.id = id
class ErrorAdditionalInfo(_serialization.Model):
"""The resource management error additional info.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar type: The additional info type.
:vartype type: str
:ivar info: The additional info.
:vartype info: JSON
"""
_validation = {
"type": {"readonly": True},
"info": {"readonly": True},
}
_attribute_map = {
"type": {"key": "type", "type": "str"},
"info": {"key": "info", "type": "object"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.type = None
self.info = None
class ErrorDetail(_serialization.Model):
"""The error detail.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: The error code.
:vartype code: str
:ivar message: The error message.
:vartype message: str
:ivar target: The error target.
:vartype target: str
:ivar details: The error details.
:vartype details: list[~azure.mgmt.azurestackhci.models.ErrorDetail]
:ivar additional_info: The error additional info.
:vartype additional_info: list[~azure.mgmt.azurestackhci.models.ErrorAdditionalInfo]
"""
_validation = {
"code": {"readonly": True},
"message": {"readonly": True},
"target": {"readonly": True},
"details": {"readonly": True},
"additional_info": {"readonly": True},
}
_attribute_map = {
"code": {"key": "code", "type": "str"},
"message": {"key": "message", "type": "str"},
"target": {"key": "target", "type": "str"},
"details": {"key": "details", "type": "[ErrorDetail]"},
"additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.code = None
self.message = None
self.target = None
self.details = None
self.additional_info = None
class ErrorResponse(_serialization.Model):
"""Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).
:ivar error: The error object.
:vartype error: ~azure.mgmt.azurestackhci.models.ErrorDetail
"""
_attribute_map = {
"error": {"key": "error", "type": "ErrorDetail"},
}
def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs):
"""
:keyword error: The error object.
:paramtype error: ~azure.mgmt.azurestackhci.models.ErrorDetail
"""
super().__init__(**kwargs)
self.error = error
class ExtendedLocation(_serialization.Model):
"""The complex type of the extended location.
:ivar name: The name of the extended location.
:vartype name: str
:ivar type: The type of the extended location. "CustomLocation"
:vartype type: str or ~azure.mgmt.azurestackhci.models.ExtendedLocationTypes
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
}
def __init__(
self,
*,
name: Optional[str] = None,
type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None,
**kwargs
):
"""
:keyword name: The name of the extended location.
:paramtype name: str
:keyword type: The type of the extended location. "CustomLocation"
:paramtype type: str or ~azure.mgmt.azurestackhci.models.ExtendedLocationTypes
"""
super().__init__(**kwargs)
self.name = name
self.type = type
class Extension(ProxyResource): # pylint: disable=too-many-instance-attributes
"""Details of a particular extension in HCI Cluster.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar provisioning_state: Provisioning state of the Extension proxy resource. Known values are:
"Succeeded", "Failed", "Canceled", "Accepted", and "Provisioning".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState
:ivar aggregate_state: Aggregate state of Arc Extensions across the nodes in this HCI cluster.
Known values are: "NotSpecified", "Error", "Succeeded", "Canceled", "Failed", "Connected",
"Disconnected", "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded",
"PartiallyConnected", and "InProgress".
:vartype aggregate_state: str or ~azure.mgmt.azurestackhci.models.ExtensionAggregateState
:ivar per_node_extension_details: State of Arc Extension in each of the nodes.
:vartype per_node_extension_details:
list[~azure.mgmt.azurestackhci.models.PerNodeExtensionState]
:ivar force_update_tag: How the extension handler should be forced to update even if the
extension configuration has not changed.
:vartype force_update_tag: str
:ivar publisher: The name of the extension handler publisher.
:vartype publisher: str
:ivar type_properties_extension_parameters_type: Specifies the type of the extension; an
example is "CustomScriptExtension".
:vartype type_properties_extension_parameters_type: str
:ivar type_handler_version: Specifies the version of the script handler.
:vartype type_handler_version: str
:ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor
version if one is available at deployment time. Once deployed, however, the extension will not
upgrade minor versions unless redeployed, even with this property set to true.
:vartype auto_upgrade_minor_version: bool
:ivar settings: Json formatted public settings for the extension.
:vartype settings: JSON
:ivar protected_settings: Protected settings (may contain secrets).
:vartype protected_settings: JSON
:ivar created_by: The identity that created the resource.
:vartype created_by: str
:ivar created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:vartype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar created_at: The timestamp of resource creation (UTC).
:vartype created_at: ~datetime.datetime
:ivar last_modified_by: The identity that last modified the resource.
:vartype last_modified_by: str
:ivar last_modified_by_type: The type of identity that last modified the resource. Known values
are: "User", "Application", "ManagedIdentity", and "Key".
:vartype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar last_modified_at: The timestamp of resource last modification (UTC).
:vartype last_modified_at: ~datetime.datetime
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"provisioning_state": {"readonly": True},
"aggregate_state": {"readonly": True},
"per_node_extension_details": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"aggregate_state": {"key": "properties.aggregateState", "type": "str"},
"per_node_extension_details": {"key": "properties.perNodeExtensionDetails", "type": "[PerNodeExtensionState]"},
"force_update_tag": {"key": "properties.extensionParameters.forceUpdateTag", "type": "str"},
"publisher": {"key": "properties.extensionParameters.publisher", "type": "str"},
"type_properties_extension_parameters_type": {"key": "properties.extensionParameters.type", "type": "str"},
"type_handler_version": {"key": "properties.extensionParameters.typeHandlerVersion", "type": "str"},
"auto_upgrade_minor_version": {"key": "properties.extensionParameters.autoUpgradeMinorVersion", "type": "bool"},
"settings": {"key": "properties.extensionParameters.settings", "type": "object"},
"protected_settings": {"key": "properties.extensionParameters.protectedSettings", "type": "object"},
"created_by": {"key": "systemData.createdBy", "type": "str"},
"created_by_type": {"key": "systemData.createdByType", "type": "str"},
"created_at": {"key": "systemData.createdAt", "type": "iso-8601"},
"last_modified_by": {"key": "systemData.lastModifiedBy", "type": "str"},
"last_modified_by_type": {"key": "systemData.lastModifiedByType", "type": "str"},
"last_modified_at": {"key": "systemData.lastModifiedAt", "type": "iso-8601"},
}
def __init__(
self,
*,
force_update_tag: Optional[str] = None,
publisher: Optional[str] = None,
type_properties_extension_parameters_type: Optional[str] = None,
type_handler_version: Optional[str] = None,
auto_upgrade_minor_version: Optional[bool] = None,
settings: Optional[JSON] = None,
protected_settings: Optional[JSON] = None,
created_by: Optional[str] = None,
created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
created_at: Optional[datetime.datetime] = None,
last_modified_by: Optional[str] = None,
last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
last_modified_at: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword force_update_tag: How the extension handler should be forced to update even if the
extension configuration has not changed.
:paramtype force_update_tag: str
:keyword publisher: The name of the extension handler publisher.
:paramtype publisher: str
:keyword type_properties_extension_parameters_type: Specifies the type of the extension; an
example is "CustomScriptExtension".
:paramtype type_properties_extension_parameters_type: str
:keyword type_handler_version: Specifies the version of the script handler.
:paramtype type_handler_version: str
:keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor
version if one is available at deployment time. Once deployed, however, the extension will not
upgrade minor versions unless redeployed, even with this property set to true.
:paramtype auto_upgrade_minor_version: bool
:keyword settings: Json formatted public settings for the extension.
:paramtype settings: JSON
:keyword protected_settings: Protected settings (may contain secrets).
:paramtype protected_settings: JSON
:keyword created_by: The identity that created the resource.
:paramtype created_by: str
:keyword created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:paramtype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword created_at: The timestamp of resource creation (UTC).
:paramtype created_at: ~datetime.datetime
:keyword last_modified_by: The identity that last modified the resource.
:paramtype last_modified_by: str
:keyword last_modified_by_type: The type of identity that last modified the resource. Known
values are: "User", "Application", "ManagedIdentity", and "Key".
:paramtype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword last_modified_at: The timestamp of resource last modification (UTC).
:paramtype last_modified_at: ~datetime.datetime
"""
super().__init__(**kwargs)
self.provisioning_state = None
self.aggregate_state = None
self.per_node_extension_details = None
self.force_update_tag = force_update_tag
self.publisher = publisher
self.type_properties_extension_parameters_type = type_properties_extension_parameters_type
self.type_handler_version = type_handler_version
self.auto_upgrade_minor_version = auto_upgrade_minor_version
self.settings = settings
self.protected_settings = protected_settings
self.created_by = created_by
self.created_by_type = created_by_type
self.created_at = created_at
self.last_modified_by = last_modified_by
self.last_modified_by_type = last_modified_by_type
self.last_modified_at = last_modified_at
class ExtensionList(_serialization.Model):
"""List of Extensions in HCI cluster.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of Extensions in HCI cluster.
:vartype value: list[~azure.mgmt.azurestackhci.models.Extension]
:ivar next_link: Link to the next set of results.
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[Extension]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class GalleryDiskImage(_serialization.Model):
"""This is the disk image base class.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar size_in_mb: This property indicates the size of the VHD to be created.
:vartype size_in_mb: int
"""
_validation = {
"size_in_mb": {"readonly": True},
}
_attribute_map = {
"size_in_mb": {"key": "sizeInMB", "type": "int"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.size_in_mb = None
class GalleryImageIdentifier(_serialization.Model):
"""This is the gallery image definition identifier.
All required parameters must be populated in order to send to Azure.
:ivar publisher: The name of the gallery image definition publisher. Required.
:vartype publisher: str
:ivar offer: The name of the gallery image definition offer. Required.
:vartype offer: str
:ivar sku: The name of the gallery image definition SKU. Required.
:vartype sku: str
"""
_validation = {
"publisher": {"required": True},
"offer": {"required": True},
"sku": {"required": True},
}
_attribute_map = {
"publisher": {"key": "publisher", "type": "str"},
"offer": {"key": "offer", "type": "str"},
"sku": {"key": "sku", "type": "str"},
}
def __init__(self, *, publisher: str, offer: str, sku: str, **kwargs):
"""
:keyword publisher: The name of the gallery image definition publisher. Required.
:paramtype publisher: str
:keyword offer: The name of the gallery image definition offer. Required.
:paramtype offer: str
:keyword sku: The name of the gallery image definition SKU. Required.
:paramtype sku: str
"""
super().__init__(**kwargs)
self.publisher = publisher
self.offer = offer
self.sku = sku
class Galleryimages(TrackedResource): # pylint: disable=too-many-instance-attributes
"""The gallery image resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar container_name: Container Name for storage container.
:vartype container_name: str
:ivar image_path: location of the image the gallery image should be created from.
:vartype image_path: str
:ivar os_type: operating system type that the gallery image uses. Expected to be linux or
windows. Known values are: "Windows" and "Linux".
:vartype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes
:ivar cloud_init_data_source: Datasource for the gallery image when provisioning with
cloud-init (Azure or NoCloud). Known values are: "NoCloud" and "Azure".
:vartype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource
:ivar hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known
values are: "V1" and "V2".
:vartype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration
:ivar identifier: This is the gallery image definition identifier.
:vartype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier
:ivar version: Specifies information about the gallery image version that you want to create or
update.
:vartype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion
:ivar provisioning_state: Provisioning state of the gallery image. Known values are:
"Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar status: GalleryImageStatus defines the observed state of galleryimages.
:vartype status: ~azure.mgmt.azurestackhci.models.GalleryImageStatus
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"system_data": {"key": "systemData", "type": "SystemData"},
"container_name": {"key": "properties.containerName", "type": "str"},
"image_path": {"key": "properties.imagePath", "type": "str"},
"os_type": {"key": "properties.osType", "type": "str"},
"cloud_init_data_source": {"key": "properties.cloudInitDataSource", "type": "str"},
"hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"},
"identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"},
"version": {"key": "properties.version", "type": "GalleryImageVersion"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"status": {"key": "properties.status", "type": "GalleryImageStatus"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
container_name: Optional[str] = None,
image_path: Optional[str] = None,
os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None,
cloud_init_data_source: Optional[Union[str, "_models.CloudInitDataSource"]] = None,
hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None,
identifier: Optional["_models.GalleryImageIdentifier"] = None,
version: Optional["_models.GalleryImageVersion"] = None,
resource_name: Optional[str] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:keyword container_name: Container Name for storage container.
:paramtype container_name: str
:keyword image_path: location of the image the gallery image should be created from.
:paramtype image_path: str
:keyword os_type: operating system type that the gallery image uses. Expected to be linux or
windows. Known values are: "Windows" and "Linux".
:paramtype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes
:keyword cloud_init_data_source: Datasource for the gallery image when provisioning with
cloud-init (Azure or NoCloud). Known values are: "NoCloud" and "Azure".
:paramtype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource
:keyword hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known
values are: "V1" and "V2".
:paramtype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration
:keyword identifier: This is the gallery image definition identifier.
:paramtype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier
:keyword version: Specifies information about the gallery image version that you want to create
or update.
:paramtype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.system_data = None
self.container_name = container_name
self.image_path = image_path
self.os_type = os_type
self.cloud_init_data_source = cloud_init_data_source
self.hyper_v_generation = hyper_v_generation
self.identifier = identifier
self.version = version
self.provisioning_state = None
self.resource_name = resource_name
self.status = None
class GalleryimagesListResult(_serialization.Model):
"""List of galleryimages.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value:
:vartype value: list[~azure.mgmt.azurestackhci.models.Galleryimages]
:ivar next_link: Link to the next set of results.
:vartype next_link: str
"""
_validation = {
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[Galleryimages]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, *, value: Optional[List["_models.Galleryimages"]] = None, **kwargs):
"""
:keyword value:
:paramtype value: list[~azure.mgmt.azurestackhci.models.Galleryimages]
"""
super().__init__(**kwargs)
self.value = value
self.next_link = None
class GalleryimagesPatch(_serialization.Model):
"""The gallery image resource patch definition.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class GalleryImageStatus(_serialization.Model):
"""GalleryImageStatus defines the observed state of galleryimages.
:ivar error_code: Gallery image provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar provisioning_status: The provisioning status of the gallery image.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.GalleryImageStatusProvisioningStatus
:ivar download_status: The download status of the gallery image.
:vartype download_status: ~azure.mgmt.azurestackhci.models.GalleryImageStatusDownloadStatus
:ivar progress_percentage: The progress of the operation in percentage.
:vartype progress_percentage: int
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"provisioning_status": {"key": "provisioningStatus", "type": "GalleryImageStatusProvisioningStatus"},
"download_status": {"key": "downloadStatus", "type": "GalleryImageStatusDownloadStatus"},
"progress_percentage": {"key": "progressPercentage", "type": "int"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
provisioning_status: Optional["_models.GalleryImageStatusProvisioningStatus"] = None,
download_status: Optional["_models.GalleryImageStatusDownloadStatus"] = None,
progress_percentage: Optional[int] = None,
**kwargs
):
"""
:keyword error_code: Gallery image provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword provisioning_status: The provisioning status of the gallery image.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.GalleryImageStatusProvisioningStatus
:keyword download_status: The download status of the gallery image.
:paramtype download_status: ~azure.mgmt.azurestackhci.models.GalleryImageStatusDownloadStatus
:keyword progress_percentage: The progress of the operation in percentage.
:paramtype progress_percentage: int
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.provisioning_status = provisioning_status
self.download_status = download_status
self.progress_percentage = progress_percentage
class GalleryImageStatusDownloadStatus(_serialization.Model):
"""The download status of the gallery image.
:ivar download_size_in_mb: The downloaded sized of the image in MB.
:vartype download_size_in_mb: int
"""
_attribute_map = {
"download_size_in_mb": {"key": "downloadSizeInMB", "type": "int"},
}
def __init__(self, *, download_size_in_mb: Optional[int] = None, **kwargs):
"""
:keyword download_size_in_mb: The downloaded sized of the image in MB.
:paramtype download_size_in_mb: int
"""
super().__init__(**kwargs)
self.download_size_in_mb = download_size_in_mb
class GalleryImageStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the gallery image.
:ivar operation_id: The ID of the operation performed on the gallery image.
:vartype operation_id: str
:ivar status: The status of the operation performed on the gallery image [Succeeded, Failed,
InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the gallery image.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the gallery image [Succeeded, Failed,
InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
class GalleryImageVersion(_serialization.Model):
"""Specifies information about the gallery image version that you want to create or update.
:ivar name: This is the version of the gallery image.
:vartype name: str
:ivar storage_profile: This is the storage profile of a Gallery Image Version.
:vartype storage_profile: ~azure.mgmt.azurestackhci.models.GalleryImageVersionStorageProfile
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"},
}
def __init__(
self,
*,
name: Optional[str] = None,
storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None,
**kwargs
):
"""
:keyword name: This is the version of the gallery image.
:paramtype name: str
:keyword storage_profile: This is the storage profile of a Gallery Image Version.
:paramtype storage_profile: ~azure.mgmt.azurestackhci.models.GalleryImageVersionStorageProfile
"""
super().__init__(**kwargs)
self.name = name
self.storage_profile = storage_profile
class GalleryImageVersionStorageProfile(_serialization.Model):
"""This is the storage profile of a Gallery Image Version.
:ivar os_disk_image: This is the OS disk image.
:vartype os_disk_image: ~azure.mgmt.azurestackhci.models.GalleryOSDiskImage
"""
_attribute_map = {
"os_disk_image": {"key": "osDiskImage", "type": "GalleryOSDiskImage"},
}
def __init__(self, *, os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, **kwargs):
"""
:keyword os_disk_image: This is the OS disk image.
:paramtype os_disk_image: ~azure.mgmt.azurestackhci.models.GalleryOSDiskImage
"""
super().__init__(**kwargs)
self.os_disk_image = os_disk_image
class GalleryOSDiskImage(GalleryDiskImage):
"""This is the OS disk image.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar size_in_mb: This property indicates the size of the VHD to be created.
:vartype size_in_mb: int
"""
_validation = {
"size_in_mb": {"readonly": True},
}
_attribute_map = {
"size_in_mb": {"key": "sizeInMB", "type": "int"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
class GuestAgent(ProxyResource):
"""Defines the GuestAgent.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: The system data.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar credentials: Username / Password Credentials to provision guest agent.
:vartype credentials: ~azure.mgmt.azurestackhci.models.GuestCredential
:ivar http_proxy_config: HTTP Proxy configuration for the VM.
:vartype http_proxy_config: ~azure.mgmt.azurestackhci.models.HttpProxyConfiguration
:ivar provisioning_action: The guest agent provisioning action. Known values are: "install",
"uninstall", and "repair".
:vartype provisioning_action: str or ~azure.mgmt.azurestackhci.models.ProvisioningAction
:ivar status: The guest agent status.
:vartype status: str
:ivar provisioning_state: The provisioning state.
:vartype provisioning_state: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"status": {"readonly": True},
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"credentials": {"key": "properties.credentials", "type": "GuestCredential"},
"http_proxy_config": {"key": "properties.httpProxyConfig", "type": "HttpProxyConfiguration"},
"provisioning_action": {"key": "properties.provisioningAction", "type": "str"},
"status": {"key": "properties.status", "type": "str"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
}
def __init__(
self,
*,
credentials: Optional["_models.GuestCredential"] = None,
http_proxy_config: Optional["_models.HttpProxyConfiguration"] = None,
provisioning_action: Optional[Union[str, "_models.ProvisioningAction"]] = None,
**kwargs
):
"""
:keyword credentials: Username / Password Credentials to provision guest agent.
:paramtype credentials: ~azure.mgmt.azurestackhci.models.GuestCredential
:keyword http_proxy_config: HTTP Proxy configuration for the VM.
:paramtype http_proxy_config: ~azure.mgmt.azurestackhci.models.HttpProxyConfiguration
:keyword provisioning_action: The guest agent provisioning action. Known values are: "install",
"uninstall", and "repair".
:paramtype provisioning_action: str or ~azure.mgmt.azurestackhci.models.ProvisioningAction
"""
super().__init__(**kwargs)
self.system_data = None
self.credentials = credentials
self.http_proxy_config = http_proxy_config
self.provisioning_action = provisioning_action
self.status = None
self.provisioning_state = None
class GuestAgentList(_serialization.Model):
"""List of GuestAgent.
All required parameters must be populated in order to send to Azure.
:ivar next_link: Url to follow for getting next page of GuestAgent.
:vartype next_link: str
:ivar value: Array of GuestAgent. Required.
:vartype value: list[~azure.mgmt.azurestackhci.models.GuestAgent]
"""
_validation = {
"value": {"required": True},
}
_attribute_map = {
"next_link": {"key": "nextLink", "type": "str"},
"value": {"key": "value", "type": "[GuestAgent]"},
}
def __init__(self, *, value: List["_models.GuestAgent"], next_link: Optional[str] = None, **kwargs):
"""
:keyword next_link: Url to follow for getting next page of GuestAgent.
:paramtype next_link: str
:keyword value: Array of GuestAgent. Required.
:paramtype value: list[~azure.mgmt.azurestackhci.models.GuestAgent]
"""
super().__init__(**kwargs)
self.next_link = next_link
self.value = value
class GuestAgentProfile(_serialization.Model):
"""Defines the resource properties.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar vm_uuid: Specifies the VM's unique SMBIOS ID.
:vartype vm_uuid: str
:ivar status: The status of the hybrid machine agent. Known values are: "Connected",
"Disconnected", and "Error".
:vartype status: str or ~azure.mgmt.azurestackhci.models.StatusTypes
:ivar last_status_change: The time of the last status change.
:vartype last_status_change: ~datetime.datetime
:ivar agent_version: The hybrid machine agent full version.
:vartype agent_version: str
:ivar error_details: Details about the error state.
:vartype error_details: list[~azure.mgmt.azurestackhci.models.ErrorDetail]
"""
_validation = {
"vm_uuid": {"readonly": True},
"status": {"readonly": True},
"last_status_change": {"readonly": True},
"agent_version": {"readonly": True},
"error_details": {"readonly": True},
}
_attribute_map = {
"vm_uuid": {"key": "vmUuid", "type": "str"},
"status": {"key": "status", "type": "str"},
"last_status_change": {"key": "lastStatusChange", "type": "iso-8601"},
"agent_version": {"key": "agentVersion", "type": "str"},
"error_details": {"key": "errorDetails", "type": "[ErrorDetail]"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.vm_uuid = None
self.status = None
self.last_status_change = None
self.agent_version = None
self.error_details = None
class GuestCredential(_serialization.Model):
"""Username / Password Credentials to connect to guest.
:ivar username: The username to connect with the guest.
:vartype username: str
:ivar password: The password to connect with the guest.
:vartype password: str
"""
_attribute_map = {
"username": {"key": "username", "type": "str"},
"password": {"key": "password", "type": "str"},
}
def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs):
"""
:keyword username: The username to connect with the guest.
:paramtype username: str
:keyword password: The password to connect with the guest.
:paramtype password: str
"""
super().__init__(**kwargs)
self.username = username
self.password = password
class HardwareProfileUpdate(_serialization.Model):
"""HardwareProfile - Specifies the hardware settings for the virtual machine.
:ivar vm_size: Known values are: "Default", "Standard_A2_v2", "Standard_A4_v2",
"Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3",
"Standard_D32s_v3", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2",
"Standard_DS13_v2", "Standard_K8S_v1", "Standard_K8S2_v1", "Standard_K8S3_v1",
"Standard_K8S4_v1", "Standard_NK6", "Standard_NK12", "Standard_NV6", "Standard_NV12",
"Standard_K8S5_v1", and "Custom".
:vartype vm_size: str or ~azure.mgmt.azurestackhci.models.VmSizeEnum
:ivar processors: number of processors for the virtual machine.
:vartype processors: int
:ivar memory_gb: RAM in gb for the virtual machine.
:vartype memory_gb: int
"""
_attribute_map = {
"vm_size": {"key": "vmSize", "type": "str"},
"processors": {"key": "processors", "type": "int"},
"memory_gb": {"key": "memoryGB", "type": "int"},
}
def __init__(
self,
*,
vm_size: Optional[Union[str, "_models.VmSizeEnum"]] = None,
processors: Optional[int] = None,
memory_gb: Optional[int] = None,
**kwargs
):
"""
:keyword vm_size: Known values are: "Default", "Standard_A2_v2", "Standard_A4_v2",
"Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3",
"Standard_D32s_v3", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2",
"Standard_DS13_v2", "Standard_K8S_v1", "Standard_K8S2_v1", "Standard_K8S3_v1",
"Standard_K8S4_v1", "Standard_NK6", "Standard_NK12", "Standard_NV6", "Standard_NV12",
"Standard_K8S5_v1", and "Custom".
:paramtype vm_size: str or ~azure.mgmt.azurestackhci.models.VmSizeEnum
:keyword processors: number of processors for the virtual machine.
:paramtype processors: int
:keyword memory_gb: RAM in gb for the virtual machine.
:paramtype memory_gb: int
"""
super().__init__(**kwargs)
self.vm_size = vm_size
self.processors = processors
self.memory_gb = memory_gb
class HttpProxyConfiguration(_serialization.Model):
"""HTTP Proxy configuration for the VM.
:ivar https_proxy: The httpsProxy url.
:vartype https_proxy: str
"""
_attribute_map = {
"https_proxy": {"key": "httpsProxy", "type": "str"},
}
def __init__(self, *, https_proxy: Optional[str] = None, **kwargs):
"""
:keyword https_proxy: The httpsProxy url.
:paramtype https_proxy: str
"""
super().__init__(**kwargs)
self.https_proxy = https_proxy
class HybridIdentityMetadata(ProxyResource):
"""Defines the HybridIdentityMetadata.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar system_data: The system data.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar resource_uid: The unique identifier for the resource.
:vartype resource_uid: str
:ivar public_key: The Public Key.
:vartype public_key: str
:ivar identity: Identity for the resource.
:vartype identity: ~azure.mgmt.azurestackhci.models.Identity
:ivar provisioning_state: The provisioning state.
:vartype provisioning_state: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"system_data": {"readonly": True},
"identity": {"readonly": True},
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"resource_uid": {"key": "properties.resourceUid", "type": "str"},
"public_key": {"key": "properties.publicKey", "type": "str"},
"identity": {"key": "properties.identity", "type": "Identity"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
}
def __init__(self, *, resource_uid: Optional[str] = None, public_key: Optional[str] = None, **kwargs):
"""
:keyword resource_uid: The unique identifier for the resource.
:paramtype resource_uid: str
:keyword public_key: The Public Key.
:paramtype public_key: str
"""
super().__init__(**kwargs)
self.system_data = None
self.resource_uid = resource_uid
self.public_key = public_key
self.identity = None
self.provisioning_state = None
class HybridIdentityMetadataList(_serialization.Model):
"""List of HybridIdentityMetadata.
All required parameters must be populated in order to send to Azure.
:ivar next_link: Url to follow for getting next page of HybridIdentityMetadata.
:vartype next_link: str
:ivar value: Array of HybridIdentityMetadata. Required.
:vartype value: list[~azure.mgmt.azurestackhci.models.HybridIdentityMetadata]
"""
_validation = {
"value": {"required": True},
}
_attribute_map = {
"next_link": {"key": "nextLink", "type": "str"},
"value": {"key": "value", "type": "[HybridIdentityMetadata]"},
}
def __init__(self, *, value: List["_models.HybridIdentityMetadata"], next_link: Optional[str] = None, **kwargs):
"""
:keyword next_link: Url to follow for getting next page of HybridIdentityMetadata.
:paramtype next_link: str
:keyword value: Array of HybridIdentityMetadata. Required.
:paramtype value: list[~azure.mgmt.azurestackhci.models.HybridIdentityMetadata]
"""
super().__init__(**kwargs)
self.next_link = next_link
self.value = value
class Identity(_serialization.Model):
"""Identity for the resource.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar principal_id: The principal ID of resource identity.
:vartype principal_id: str
:ivar tenant_id: The tenant ID of resource.
:vartype tenant_id: str
:ivar type: The identity type. Default value is "SystemAssigned".
:vartype type: str
"""
_validation = {
"principal_id": {"readonly": True},
"tenant_id": {"readonly": True},
}
_attribute_map = {
"principal_id": {"key": "principalId", "type": "str"},
"tenant_id": {"key": "tenantId", "type": "str"},
"type": {"key": "type", "type": "str"},
}
def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs):
"""
:keyword type: The identity type. Default value is "SystemAssigned".
:paramtype type: str
"""
super().__init__(**kwargs)
self.principal_id = None
self.tenant_id = None
self.type = type
class InterfaceDNSSettings(_serialization.Model):
"""InterfaceDNSSettings.
:ivar dns_servers: List of DNS server IP Addresses for the interface.
:vartype dns_servers: list[str]
"""
_attribute_map = {
"dns_servers": {"key": "dnsServers", "type": "[str]"},
}
def __init__(self, *, dns_servers: Optional[List[str]] = None, **kwargs):
"""
:keyword dns_servers: List of DNS server IP Addresses for the interface.
:paramtype dns_servers: list[str]
"""
super().__init__(**kwargs)
self.dns_servers = dns_servers
class IpConfiguration(_serialization.Model):
"""InterfaceIPConfiguration iPConfiguration in a network interface.
:ivar name: Name - The name of the resource that is unique within a resource group. This name
can be used to access the resource.
:vartype name: str
:ivar properties: InterfaceIPConfigurationPropertiesFormat properties of IP configuration.
:vartype properties: ~azure.mgmt.azurestackhci.models.IpConfigurationProperties
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"properties": {"key": "properties", "type": "IpConfigurationProperties"},
}
def __init__(
self, *, name: Optional[str] = None, properties: Optional["_models.IpConfigurationProperties"] = None, **kwargs
):
"""
:keyword name: Name - The name of the resource that is unique within a resource group. This
name can be used to access the resource.
:paramtype name: str
:keyword properties: InterfaceIPConfigurationPropertiesFormat properties of IP configuration.
:paramtype properties: ~azure.mgmt.azurestackhci.models.IpConfigurationProperties
"""
super().__init__(**kwargs)
self.name = name
self.properties = properties
class IpConfigurationProperties(_serialization.Model):
"""InterfaceIPConfigurationPropertiesFormat properties of IP configuration.
:ivar gateway: Gateway for network interface.
:vartype gateway: str
:ivar prefix_length: prefixLength for network interface.
:vartype prefix_length: str
:ivar private_ip_address: PrivateIPAddress - Private IP address of the IP configuration.
:vartype private_ip_address: str
:ivar private_ip_allocation_method: PrivateIPAllocationMethod - The private IP address
allocation method. Possible values include: 'Static', 'Dynamic'. Known values are: "Dynamic"
and "Static".
:vartype private_ip_allocation_method: str or
~azure.mgmt.azurestackhci.models.PrivateIPAllocationMethodEnum
:ivar subnet: Subnet - Name of Subnet bound to the IP configuration.
:vartype subnet: ~azure.mgmt.azurestackhci.models.IpConfigurationPropertiesSubnet
"""
_attribute_map = {
"gateway": {"key": "gateway", "type": "str"},
"prefix_length": {"key": "prefixLength", "type": "str"},
"private_ip_address": {"key": "privateIPAddress", "type": "str"},
"private_ip_allocation_method": {"key": "privateIPAllocationMethod", "type": "str"},
"subnet": {"key": "subnet", "type": "IpConfigurationPropertiesSubnet"},
}
def __init__(
self,
*,
gateway: Optional[str] = None,
prefix_length: Optional[str] = None,
private_ip_address: Optional[str] = None,
private_ip_allocation_method: Optional[Union[str, "_models.PrivateIPAllocationMethodEnum"]] = None,
subnet: Optional["_models.IpConfigurationPropertiesSubnet"] = None,
**kwargs
):
"""
:keyword gateway: Gateway for network interface.
:paramtype gateway: str
:keyword prefix_length: prefixLength for network interface.
:paramtype prefix_length: str
:keyword private_ip_address: PrivateIPAddress - Private IP address of the IP configuration.
:paramtype private_ip_address: str
:keyword private_ip_allocation_method: PrivateIPAllocationMethod - The private IP address
allocation method. Possible values include: 'Static', 'Dynamic'. Known values are: "Dynamic"
and "Static".
:paramtype private_ip_allocation_method: str or
~azure.mgmt.azurestackhci.models.PrivateIPAllocationMethodEnum
:keyword subnet: Subnet - Name of Subnet bound to the IP configuration.
:paramtype subnet: ~azure.mgmt.azurestackhci.models.IpConfigurationPropertiesSubnet
"""
super().__init__(**kwargs)
self.gateway = gateway
self.prefix_length = prefix_length
self.private_ip_address = private_ip_address
self.private_ip_allocation_method = private_ip_allocation_method
self.subnet = subnet
class IpConfigurationPropertiesSubnet(_serialization.Model):
"""Subnet - Name of Subnet bound to the IP configuration.
:ivar id: ID - The ARM resource id in the form of
/subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/...
:vartype id: str
"""
_attribute_map = {
"id": {"key": "id", "type": "str"},
}
def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin
"""
:keyword id: ID - The ARM resource id in the form of
/subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/...
:paramtype id: str
"""
super().__init__(**kwargs)
self.id = id
class IPPool(_serialization.Model):
"""IPPool.
:ivar ip_pool_type: ip pool type. Known values are: "vm" and "vippool".
:vartype ip_pool_type: str or ~azure.mgmt.azurestackhci.models.IPPoolTypeEnum
:ivar start: start of the ip address pool.
:vartype start: str
:ivar end: end of the ip address pool.
:vartype end: str
:ivar info:
:vartype info: ~azure.mgmt.azurestackhci.models.IPPoolInfo
"""
_attribute_map = {
"ip_pool_type": {"key": "ipPoolType", "type": "str"},
"start": {"key": "start", "type": "str"},
"end": {"key": "end", "type": "str"},
"info": {"key": "info", "type": "IPPoolInfo"},
}
def __init__(
self,
*,
ip_pool_type: Optional[Union[str, "_models.IPPoolTypeEnum"]] = None,
start: Optional[str] = None,
end: Optional[str] = None,
info: Optional["_models.IPPoolInfo"] = None,
**kwargs
):
"""
:keyword ip_pool_type: ip pool type. Known values are: "vm" and "vippool".
:paramtype ip_pool_type: str or ~azure.mgmt.azurestackhci.models.IPPoolTypeEnum
:keyword start: start of the ip address pool.
:paramtype start: str
:keyword end: end of the ip address pool.
:paramtype end: str
:keyword info:
:paramtype info: ~azure.mgmt.azurestackhci.models.IPPoolInfo
"""
super().__init__(**kwargs)
self.ip_pool_type = ip_pool_type
self.start = start
self.end = end
self.info = info
class IPPoolInfo(_serialization.Model):
"""IPPoolInfo.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar used: no. of ip addresses allocated from the ip pool.
:vartype used: str
:ivar available: no. of ip addresses available in the ip pool.
:vartype available: str
"""
_validation = {
"used": {"readonly": True},
"available": {"readonly": True},
}
_attribute_map = {
"used": {"key": "used", "type": "str"},
"available": {"key": "available", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.used = None
self.available = None
class MachineExtension(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""Describes a Machine Extension.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar location: The geo-location where the resource lives.
:vartype location: str
:ivar system_data: The system data.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar name: The name of the resource.
:vartype name: str
:ivar id: Fully qualified resource ID for the resource.
:vartype id: str
:ivar type: The type of the resource.
:vartype type: str
:ivar force_update_tag: How the extension handler should be forced to update even if the
extension configuration has not changed.
:vartype force_update_tag: str
:ivar publisher: The name of the extension handler publisher.
:vartype publisher: str
:ivar type_properties_type: Specifies the type of the extension; an example is
"CustomScriptExtension".
:vartype type_properties_type: str
:ivar type_handler_version: Specifies the version of the script handler.
:vartype type_handler_version: str
:ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor
version if one is available at deployment time. Once deployed, however, the extension will not
upgrade minor versions unless redeployed, even with this property set to true.
:vartype auto_upgrade_minor_version: bool
:ivar settings: Json formatted public settings for the extension.
:vartype settings: JSON
:ivar protected_settings: The extension can contain either protectedSettings or
protectedSettingsFromKeyVault or no protected settings at all.
:vartype protected_settings: JSON
:ivar provisioning_state: The provisioning state, which only appears in the response.
:vartype provisioning_state: str
:ivar instance_view: The machine extension instance view.
:vartype instance_view: ~azure.mgmt.azurestackhci.models.MachineExtensionPropertiesInstanceView
"""
_validation = {
"system_data": {"readonly": True},
"name": {"readonly": True},
"id": {"readonly": True},
"type": {"readonly": True},
"provisioning_state": {"readonly": True},
}
_attribute_map = {
"location": {"key": "location", "type": "str"},
"system_data": {"key": "systemData", "type": "SystemData"},
"tags": {"key": "tags", "type": "{str}"},
"name": {"key": "name", "type": "str"},
"id": {"key": "id", "type": "str"},
"type": {"key": "type", "type": "str"},
"force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"},
"publisher": {"key": "properties.publisher", "type": "str"},
"type_properties_type": {"key": "properties.type", "type": "str"},
"type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"},
"auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"},
"settings": {"key": "properties.settings", "type": "object"},
"protected_settings": {"key": "properties.protectedSettings", "type": "object"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"instance_view": {"key": "properties.instanceView", "type": "MachineExtensionPropertiesInstanceView"},
}
def __init__(
self,
*,
location: Optional[str] = None,
tags: Optional[Dict[str, str]] = None,
force_update_tag: Optional[str] = None,
publisher: Optional[str] = None,
type_properties_type: Optional[str] = None,
type_handler_version: Optional[str] = None,
auto_upgrade_minor_version: Optional[bool] = None,
settings: Optional[JSON] = None,
protected_settings: Optional[JSON] = None,
instance_view: Optional["_models.MachineExtensionPropertiesInstanceView"] = None,
**kwargs
):
"""
:keyword location: The geo-location where the resource lives.
:paramtype location: str
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword force_update_tag: How the extension handler should be forced to update even if the
extension configuration has not changed.
:paramtype force_update_tag: str
:keyword publisher: The name of the extension handler publisher.
:paramtype publisher: str
:keyword type_properties_type: Specifies the type of the extension; an example is
"CustomScriptExtension".
:paramtype type_properties_type: str
:keyword type_handler_version: Specifies the version of the script handler.
:paramtype type_handler_version: str
:keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor
version if one is available at deployment time. Once deployed, however, the extension will not
upgrade minor versions unless redeployed, even with this property set to true.
:paramtype auto_upgrade_minor_version: bool
:keyword settings: Json formatted public settings for the extension.
:paramtype settings: JSON
:keyword protected_settings: The extension can contain either protectedSettings or
protectedSettingsFromKeyVault or no protected settings at all.
:paramtype protected_settings: JSON
:keyword instance_view: The machine extension instance view.
:paramtype instance_view:
~azure.mgmt.azurestackhci.models.MachineExtensionPropertiesInstanceView
"""
super().__init__(**kwargs)
self.location = location
self.system_data = None
self.tags = tags
self.name = None
self.id = None
self.type = None
self.force_update_tag = force_update_tag
self.publisher = publisher
self.type_properties_type = type_properties_type
self.type_handler_version = type_handler_version
self.auto_upgrade_minor_version = auto_upgrade_minor_version
self.settings = settings
self.protected_settings = protected_settings
self.provisioning_state = None
self.instance_view = instance_view
class MachineExtensionInstanceView(_serialization.Model):
"""Describes the Machine Extension Instance View.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: The machine extension name.
:vartype name: str
:ivar type: Specifies the type of the extension; an example is "CustomScriptExtension".
:vartype type: str
:ivar type_handler_version: Specifies the version of the script handler.
:vartype type_handler_version: str
:ivar status: Instance view status.
:vartype status: ~azure.mgmt.azurestackhci.models.MachineExtensionInstanceViewStatus
"""
_validation = {
"name": {"readonly": True},
"type": {"readonly": True},
"type_handler_version": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"type_handler_version": {"key": "typeHandlerVersion", "type": "str"},
"status": {"key": "status", "type": "MachineExtensionInstanceViewStatus"},
}
def __init__(self, *, status: Optional["_models.MachineExtensionInstanceViewStatus"] = None, **kwargs):
"""
:keyword status: Instance view status.
:paramtype status: ~azure.mgmt.azurestackhci.models.MachineExtensionInstanceViewStatus
"""
super().__init__(**kwargs)
self.name = None
self.type = None
self.type_handler_version = None
self.status = status
class MachineExtensionInstanceViewStatus(_serialization.Model):
"""Instance view status.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar code: The status code.
:vartype code: str
:ivar level: The level code. Known values are: "Info", "Warning", and "Error".
:vartype level: str or ~azure.mgmt.azurestackhci.models.StatusLevelTypes
:ivar display_status: The short localizable label for the status.
:vartype display_status: str
:ivar message: The detailed status message, including for alerts and error messages.
:vartype message: str
:ivar time: The time of the status.
:vartype time: ~datetime.datetime
"""
_validation = {
"code": {"readonly": True},
"level": {"readonly": True},
"display_status": {"readonly": True},
"message": {"readonly": True},
"time": {"readonly": True},
}
_attribute_map = {
"code": {"key": "code", "type": "str"},
"level": {"key": "level", "type": "str"},
"display_status": {"key": "displayStatus", "type": "str"},
"message": {"key": "message", "type": "str"},
"time": {"key": "time", "type": "iso-8601"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.code = None
self.level = None
self.display_status = None
self.message = None
self.time = None
class MachineExtensionPropertiesInstanceView(MachineExtensionInstanceView):
"""The machine extension instance view.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: The machine extension name.
:vartype name: str
:ivar type: Specifies the type of the extension; an example is "CustomScriptExtension".
:vartype type: str
:ivar type_handler_version: Specifies the version of the script handler.
:vartype type_handler_version: str
:ivar status: Instance view status.
:vartype status: ~azure.mgmt.azurestackhci.models.MachineExtensionInstanceViewStatus
"""
_validation = {
"name": {"readonly": True},
"type": {"readonly": True},
"type_handler_version": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"type_handler_version": {"key": "typeHandlerVersion", "type": "str"},
"status": {"key": "status", "type": "MachineExtensionInstanceViewStatus"},
}
def __init__(self, *, status: Optional["_models.MachineExtensionInstanceViewStatus"] = None, **kwargs):
"""
:keyword status: Instance view status.
:paramtype status: ~azure.mgmt.azurestackhci.models.MachineExtensionInstanceViewStatus
"""
super().__init__(status=status, **kwargs)
class MachineExtensionsListResult(_serialization.Model):
"""Describes the Machine Extensions List Result.
:ivar value: The list of extensions.
:vartype value: list[~azure.mgmt.azurestackhci.models.MachineExtension]
:ivar next_link: The uri to fetch the next page of machine extensions. Call ListNext() with
this to fetch the next page of extensions.
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[MachineExtension]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self, *, value: Optional[List["_models.MachineExtension"]] = None, next_link: Optional[str] = None, **kwargs
):
"""
:keyword value: The list of extensions.
:paramtype value: list[~azure.mgmt.azurestackhci.models.MachineExtension]
:keyword next_link: The uri to fetch the next page of machine extensions. Call ListNext() with
this to fetch the next page of extensions.
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class ResourcePatch(_serialization.Model):
"""Object containing updates for patch operations.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class MachineExtensionUpdate(ResourcePatch):
"""Describes a Machine Extension Update.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar force_update_tag: How the extension handler should be forced to update even if the
extension configuration has not changed.
:vartype force_update_tag: str
:ivar publisher: The name of the extension handler publisher.
:vartype publisher: str
:ivar type: Specifies the type of the extension; an example is "CustomScriptExtension".
:vartype type: str
:ivar type_handler_version: Specifies the version of the script handler.
:vartype type_handler_version: str
:ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor
version if one is available at deployment time. Once deployed, however, the extension will not
upgrade minor versions unless redeployed, even with this property set to true.
:vartype auto_upgrade_minor_version: bool
:ivar settings: Json formatted public settings for the extension.
:vartype settings: JSON
:ivar protected_settings: The extension can contain either protectedSettings or
protectedSettingsFromKeyVault or no protected settings at all.
:vartype protected_settings: JSON
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
"force_update_tag": {"key": "properties.forceUpdateTag", "type": "str"},
"publisher": {"key": "properties.publisher", "type": "str"},
"type": {"key": "properties.type", "type": "str"},
"type_handler_version": {"key": "properties.typeHandlerVersion", "type": "str"},
"auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"},
"settings": {"key": "properties.settings", "type": "object"},
"protected_settings": {"key": "properties.protectedSettings", "type": "object"},
}
def __init__(
self,
*,
tags: Optional[Dict[str, str]] = None,
force_update_tag: Optional[str] = None,
publisher: Optional[str] = None,
type: Optional[str] = None,
type_handler_version: Optional[str] = None,
auto_upgrade_minor_version: Optional[bool] = None,
settings: Optional[JSON] = None,
protected_settings: Optional[JSON] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword force_update_tag: How the extension handler should be forced to update even if the
extension configuration has not changed.
:paramtype force_update_tag: str
:keyword publisher: The name of the extension handler publisher.
:paramtype publisher: str
:keyword type: Specifies the type of the extension; an example is "CustomScriptExtension".
:paramtype type: str
:keyword type_handler_version: Specifies the version of the script handler.
:paramtype type_handler_version: str
:keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor
version if one is available at deployment time. Once deployed, however, the extension will not
upgrade minor versions unless redeployed, even with this property set to true.
:paramtype auto_upgrade_minor_version: bool
:keyword settings: Json formatted public settings for the extension.
:paramtype settings: JSON
:keyword protected_settings: The extension can contain either protectedSettings or
protectedSettingsFromKeyVault or no protected settings at all.
:paramtype protected_settings: JSON
"""
super().__init__(tags=tags, **kwargs)
self.force_update_tag = force_update_tag
self.publisher = publisher
self.type = type
self.type_handler_version = type_handler_version
self.auto_upgrade_minor_version = auto_upgrade_minor_version
self.settings = settings
self.protected_settings = protected_settings
class Marketplacegalleryimages(TrackedResource): # pylint: disable=too-many-instance-attributes
"""The marketplace gallery image resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar container_name: Container Name for storage container.
:vartype container_name: str
:ivar os_type: operating system type that the gallery image uses. Expected to be linux or
windows. Known values are: "Windows" and "Linux".
:vartype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes
:ivar cloud_init_data_source: Datasource for the gallery image when provisioning with
cloud-init [Azure, NoCloud]. Known values are: "NoCloud" and "Azure".
:vartype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource
:ivar hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known
values are: "V1" and "V2".
:vartype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration
:ivar identifier: This is the gallery image definition identifier.
:vartype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier
:ivar version: Specifies information about the gallery image version that you want to create or
update.
:vartype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion
:ivar provisioning_state: Provisioning state of the gallery image. Known values are:
"Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar status: MarketplaceGalleryImageStatus defines the observed state of
marketplacegalleryimages.
:vartype status: ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatus
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"system_data": {"key": "systemData", "type": "SystemData"},
"container_name": {"key": "properties.containerName", "type": "str"},
"os_type": {"key": "properties.osType", "type": "str"},
"cloud_init_data_source": {"key": "properties.cloudInitDataSource", "type": "str"},
"hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"},
"identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"},
"version": {"key": "properties.version", "type": "GalleryImageVersion"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"status": {"key": "properties.status", "type": "MarketplaceGalleryImageStatus"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
container_name: Optional[str] = None,
os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None,
cloud_init_data_source: Optional[Union[str, "_models.CloudInitDataSource"]] = None,
hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None,
identifier: Optional["_models.GalleryImageIdentifier"] = None,
version: Optional["_models.GalleryImageVersion"] = None,
resource_name: Optional[str] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:keyword container_name: Container Name for storage container.
:paramtype container_name: str
:keyword os_type: operating system type that the gallery image uses. Expected to be linux or
windows. Known values are: "Windows" and "Linux".
:paramtype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes
:keyword cloud_init_data_source: Datasource for the gallery image when provisioning with
cloud-init [Azure, NoCloud]. Known values are: "NoCloud" and "Azure".
:paramtype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource
:keyword hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known
values are: "V1" and "V2".
:paramtype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration
:keyword identifier: This is the gallery image definition identifier.
:paramtype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier
:keyword version: Specifies information about the gallery image version that you want to create
or update.
:paramtype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.system_data = None
self.container_name = container_name
self.os_type = os_type
self.cloud_init_data_source = cloud_init_data_source
self.hyper_v_generation = hyper_v_generation
self.identifier = identifier
self.version = version
self.provisioning_state = None
self.resource_name = resource_name
self.status = None
class MarketplacegalleryimagesListResult(_serialization.Model):
"""List of marketplacegalleryimages.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: The itemed list of marketplacegalleryimages.
:vartype value: list[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
:ivar next_link: Link to the next set of results.
:vartype next_link: str
"""
_validation = {
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[Marketplacegalleryimages]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, *, value: Optional[List["_models.Marketplacegalleryimages"]] = None, **kwargs):
"""
:keyword value: The itemed list of marketplacegalleryimages.
:paramtype value: list[~azure.mgmt.azurestackhci.models.Marketplacegalleryimages]
"""
super().__init__(**kwargs)
self.value = value
self.next_link = None
class MarketplacegalleryimagesPatch(_serialization.Model):
"""The marketplace gallery image resource patch definition.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class MarketplaceGalleryImageStatus(_serialization.Model):
"""MarketplaceGalleryImageStatus defines the observed state of marketplacegalleryimages.
:ivar error_code: Marketplace gallery image provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar provisioning_status: The provisioning status of the marketplace gallery image.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusProvisioningStatus
:ivar download_status: The download status of the marketplace gallery image.
:vartype download_status:
~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusDownloadStatus
:ivar progress_percentage: The progress of the operation in percentage.
:vartype progress_percentage: int
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"provisioning_status": {"key": "provisioningStatus", "type": "MarketplaceGalleryImageStatusProvisioningStatus"},
"download_status": {"key": "downloadStatus", "type": "MarketplaceGalleryImageStatusDownloadStatus"},
"progress_percentage": {"key": "progressPercentage", "type": "int"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
provisioning_status: Optional["_models.MarketplaceGalleryImageStatusProvisioningStatus"] = None,
download_status: Optional["_models.MarketplaceGalleryImageStatusDownloadStatus"] = None,
progress_percentage: Optional[int] = None,
**kwargs
):
"""
:keyword error_code: Marketplace gallery image provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword provisioning_status: The provisioning status of the marketplace gallery image.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusProvisioningStatus
:keyword download_status: The download status of the marketplace gallery image.
:paramtype download_status:
~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusDownloadStatus
:keyword progress_percentage: The progress of the operation in percentage.
:paramtype progress_percentage: int
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.provisioning_status = provisioning_status
self.download_status = download_status
self.progress_percentage = progress_percentage
class MarketplaceGalleryImageStatusDownloadStatus(_serialization.Model):
"""The download status of the marketplace gallery image.
:ivar download_size_in_mb: The downloaded sized of the image in MB.
:vartype download_size_in_mb: int
"""
_attribute_map = {
"download_size_in_mb": {"key": "downloadSizeInMB", "type": "int"},
}
def __init__(self, *, download_size_in_mb: Optional[int] = None, **kwargs):
"""
:keyword download_size_in_mb: The downloaded sized of the image in MB.
:paramtype download_size_in_mb: int
"""
super().__init__(**kwargs)
self.download_size_in_mb = download_size_in_mb
class MarketplaceGalleryImageStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the marketplace gallery image.
:ivar operation_id: The ID of the operation performed on the marketplace gallery image.
:vartype operation_id: str
:ivar status: The status of the operation performed on the marketplace gallery image
[Succeeded, Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the marketplace gallery image.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the marketplace gallery image
[Succeeded, Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
class Networkinterfaces(TrackedResource): # pylint: disable=too-many-instance-attributes
"""The network interface resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar ip_configurations: IPConfigurations - A list of IPConfigurations of the network
interface.
:vartype ip_configurations: list[~azure.mgmt.azurestackhci.models.IpConfiguration]
:ivar mac_address: MacAddress - The MAC address of the network interface.
:vartype mac_address: str
:ivar dns_settings: DNS Settings for the interface.
:vartype dns_settings: ~azure.mgmt.azurestackhci.models.InterfaceDNSSettings
:ivar provisioning_state: Provisioning state of the gallery image. Known values are:
"Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar status: NetworkInterfaceStatus defines the observed state of network interfaces.
:vartype status: ~azure.mgmt.azurestackhci.models.NetworkInterfaceStatus
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"system_data": {"key": "systemData", "type": "SystemData"},
"ip_configurations": {"key": "properties.ipConfigurations", "type": "[IpConfiguration]"},
"mac_address": {"key": "properties.macAddress", "type": "str"},
"dns_settings": {"key": "properties.dnsSettings", "type": "InterfaceDNSSettings"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"status": {"key": "properties.status", "type": "NetworkInterfaceStatus"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
ip_configurations: Optional[List["_models.IpConfiguration"]] = None,
mac_address: Optional[str] = None,
dns_settings: Optional["_models.InterfaceDNSSettings"] = None,
resource_name: Optional[str] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:keyword ip_configurations: IPConfigurations - A list of IPConfigurations of the network
interface.
:paramtype ip_configurations: list[~azure.mgmt.azurestackhci.models.IpConfiguration]
:keyword mac_address: MacAddress - The MAC address of the network interface.
:paramtype mac_address: str
:keyword dns_settings: DNS Settings for the interface.
:paramtype dns_settings: ~azure.mgmt.azurestackhci.models.InterfaceDNSSettings
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.system_data = None
self.ip_configurations = ip_configurations
self.mac_address = mac_address
self.dns_settings = dns_settings
self.provisioning_state = None
self.resource_name = resource_name
self.status = None
class NetworkinterfacesListResult(_serialization.Model):
"""NetworkinterfacesListResult.
:ivar value:
:vartype value: list[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:ivar next_link:
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[Networkinterfaces]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self, *, value: Optional[List["_models.Networkinterfaces"]] = None, next_link: Optional[str] = None, **kwargs
):
"""
:keyword value:
:paramtype value: list[~azure.mgmt.azurestackhci.models.Networkinterfaces]
:keyword next_link:
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class NetworkinterfacesPatch(_serialization.Model):
"""The network interface resource patch definition.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class NetworkInterfaceStatus(_serialization.Model):
"""NetworkInterfaceStatus defines the observed state of network interfaces.
:ivar error_code: NetworkInterface provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar provisioning_status: The provisioning status of the network interface.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.NetworkInterfaceStatusProvisioningStatus
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"provisioning_status": {"key": "provisioningStatus", "type": "NetworkInterfaceStatusProvisioningStatus"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
provisioning_status: Optional["_models.NetworkInterfaceStatusProvisioningStatus"] = None,
**kwargs
):
"""
:keyword error_code: NetworkInterface provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword provisioning_status: The provisioning status of the network interface.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.NetworkInterfaceStatusProvisioningStatus
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.provisioning_status = provisioning_status
class NetworkInterfaceStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the network interface.
:ivar operation_id: The ID of the operation performed on the network interface.
:vartype operation_id: str
:ivar status: The status of the operation performed on the network interface [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the network interface.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the network interface [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
class NetworkProfileUpdate(_serialization.Model):
"""NetworkProfile - describes the network update configuration the virtual machine.
:ivar network_interfaces: NetworkInterfaces - list of network interfaces to be attached to the
virtual machine.
:vartype network_interfaces:
list[~azure.mgmt.azurestackhci.models.NetworkProfileUpdateNetworkInterfacesItem]
"""
_attribute_map = {
"network_interfaces": {"key": "networkInterfaces", "type": "[NetworkProfileUpdateNetworkInterfacesItem]"},
}
def __init__(
self,
*,
network_interfaces: Optional[List["_models.NetworkProfileUpdateNetworkInterfacesItem"]] = None,
**kwargs
):
"""
:keyword network_interfaces: NetworkInterfaces - list of network interfaces to be attached to
the virtual machine.
:paramtype network_interfaces:
list[~azure.mgmt.azurestackhci.models.NetworkProfileUpdateNetworkInterfacesItem]
"""
super().__init__(**kwargs)
self.network_interfaces = network_interfaces
class NetworkProfileUpdateNetworkInterfacesItem(_serialization.Model):
"""NetworkProfileUpdateNetworkInterfacesItem.
:ivar id: ID - Resource ID of the network interface.
:vartype id: str
"""
_attribute_map = {
"id": {"key": "id", "type": "str"},
}
def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin
"""
:keyword id: ID - Resource ID of the network interface.
:paramtype id: str
"""
super().__init__(**kwargs)
self.id = id
class Operation(_serialization.Model):
"""Details of a REST API operation, returned from the Resource Provider Operations API.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples:
"Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action".
:vartype name: str
:ivar is_data_action: Whether the operation applies to data-plane. This is "true" for
data-plane operations and "false" for ARM/control-plane operations.
:vartype is_data_action: bool
:ivar display: Localized display information for this particular operation.
:vartype display: ~azure.mgmt.azurestackhci.models.OperationDisplay
:ivar origin: The intended executor of the operation; as in Resource Based Access Control
(RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system",
and "user,system".
:vartype origin: str or ~azure.mgmt.azurestackhci.models.Origin
:ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for
internal only APIs. "Internal"
:vartype action_type: str or ~azure.mgmt.azurestackhci.models.ActionType
"""
_validation = {
"name": {"readonly": True},
"is_data_action": {"readonly": True},
"origin": {"readonly": True},
"action_type": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"is_data_action": {"key": "isDataAction", "type": "bool"},
"display": {"key": "display", "type": "OperationDisplay"},
"origin": {"key": "origin", "type": "str"},
"action_type": {"key": "actionType", "type": "str"},
}
def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs):
"""
:keyword display: Localized display information for this particular operation.
:paramtype display: ~azure.mgmt.azurestackhci.models.OperationDisplay
"""
super().__init__(**kwargs)
self.name = None
self.is_data_action = None
self.display = display
self.origin = None
self.action_type = None
class OperationDisplay(_serialization.Model):
"""Localized display information for this particular operation.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft
Monitoring Insights" or "Microsoft Compute".
:vartype provider: str
:ivar resource: The localized friendly name of the resource type related to this operation.
E.g. "Virtual Machines" or "Job Schedule Collections".
:vartype resource: str
:ivar operation: The concise, localized friendly name for the operation; suitable for
dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine".
:vartype operation: str
:ivar description: The short, localized friendly description of the operation; suitable for
tool tips and detailed views.
:vartype description: str
"""
_validation = {
"provider": {"readonly": True},
"resource": {"readonly": True},
"operation": {"readonly": True},
"description": {"readonly": True},
}
_attribute_map = {
"provider": {"key": "provider", "type": "str"},
"resource": {"key": "resource", "type": "str"},
"operation": {"key": "operation", "type": "str"},
"description": {"key": "description", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.provider = None
self.resource = None
self.operation = None
self.description = None
class OperationListResult(_serialization.Model):
"""A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar value: List of operations supported by the resource provider.
:vartype value: list[~azure.mgmt.azurestackhci.models.Operation]
:ivar next_link: URL to get the next set of operation list results (if there are any).
:vartype next_link: str
"""
_validation = {
"value": {"readonly": True},
"next_link": {"readonly": True},
}
_attribute_map = {
"value": {"key": "value", "type": "[Operation]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.value = None
self.next_link = None
class PerNodeExtensionState(_serialization.Model):
"""Status of Arc Extension for a particular node in HCI Cluster.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Name of the node in HCI Cluster.
:vartype name: str
:ivar extension: Fully qualified resource ID for the particular Arc Extension on this node.
:vartype extension: str
:ivar state: State of Arc Extension in this node. Known values are: "NotSpecified", "Error",
"Succeeded", "Canceled", "Failed", "Connected", "Disconnected", "Deleted", "Creating",
"Updating", "Deleting", and "Moving".
:vartype state: str or ~azure.mgmt.azurestackhci.models.NodeExtensionState
"""
_validation = {
"name": {"readonly": True},
"extension": {"readonly": True},
"state": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"extension": {"key": "extension", "type": "str"},
"state": {"key": "state", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.name = None
self.extension = None
self.state = None
class PerNodeState(_serialization.Model):
"""Status of Arc agent for a particular node in HCI Cluster.
Variables are only populated by the server, and will be ignored when sending a request.
:ivar name: Name of the Node in HCI Cluster.
:vartype name: str
:ivar arc_instance: Fully qualified resource ID for the Arc agent of this node.
:vartype arc_instance: str
:ivar state: State of Arc agent in this node. Known values are: "NotSpecified", "Error",
"Succeeded", "Canceled", "Failed", "Connected", "Disconnected", "Deleted", "Creating",
"Updating", "Deleting", and "Moving".
:vartype state: str or ~azure.mgmt.azurestackhci.models.NodeArcState
"""
_validation = {
"name": {"readonly": True},
"arc_instance": {"readonly": True},
"state": {"readonly": True},
}
_attribute_map = {
"name": {"key": "name", "type": "str"},
"arc_instance": {"key": "arcInstance", "type": "str"},
"state": {"key": "state", "type": "str"},
}
def __init__(self, **kwargs):
""" """
super().__init__(**kwargs)
self.name = None
self.arc_instance = None
self.state = None
class Storagecontainers(_serialization.Model): # pylint: disable=too-many-instance-attributes
"""The storage container resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Resource Id.
:vartype id: str
:ivar name: Resource Name.
:vartype name: str
:ivar type: Resource Type.
:vartype type: str
:ivar location: The resource location. Required.
:vartype location: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar extended_location:
:vartype extended_location: ~azure.mgmt.azurestackhci.models.StoragecontainersExtendedLocation
:ivar path: Path of the storage container on the disk.
:vartype path: str
:ivar provisioning_state:
:vartype provisioning_state: str
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar available_size_mb: Amount of space available on the disk in MB.
:vartype available_size_mb: int
:ivar container_size_mb: Total size of the disk in MB.
:vartype container_size_mb: int
:ivar status: storageContainerStatus defines the observed state of storagecontainers.
:vartype status: ~azure.mgmt.azurestackhci.models.StorageContainerStatus
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"available_size_mb": {"readonly": True},
"container_size_mb": {"readonly": True},
"status": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"location": {"key": "location", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"system_data": {"key": "systemData", "type": "SystemData"},
"extended_location": {"key": "extendedLocation", "type": "StoragecontainersExtendedLocation"},
"path": {"key": "properties.path", "type": "str"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"available_size_mb": {"key": "properties.availableSizeMB", "type": "int"},
"container_size_mb": {"key": "properties.containerSizeMB", "type": "int"},
"status": {"key": "properties.status", "type": "StorageContainerStatus"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.StoragecontainersExtendedLocation"] = None,
path: Optional[str] = None,
provisioning_state: Optional[str] = None,
resource_name: Optional[str] = None,
**kwargs
):
"""
:keyword location: The resource location. Required.
:paramtype location: str
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword extended_location:
:paramtype extended_location:
~azure.mgmt.azurestackhci.models.StoragecontainersExtendedLocation
:keyword path: Path of the storage container on the disk.
:paramtype path: str
:keyword provisioning_state:
:paramtype provisioning_state: str
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
"""
super().__init__(**kwargs)
self.id = None
self.name = None
self.type = None
self.location = location
self.tags = tags
self.system_data = None
self.extended_location = extended_location
self.path = path
self.provisioning_state = provisioning_state
self.resource_name = resource_name
self.available_size_mb = None
self.container_size_mb = None
self.status = None
class StoragecontainersExtendedLocation(_serialization.Model):
"""StoragecontainersExtendedLocation.
:ivar type: The extended location type.
:vartype type: str
:ivar name: The extended location name.
:vartype name: str
"""
_attribute_map = {
"type": {"key": "type", "type": "str"},
"name": {"key": "name", "type": "str"},
}
def __init__(self, *, type: Optional[str] = None, name: Optional[str] = None, **kwargs):
"""
:keyword type: The extended location type.
:paramtype type: str
:keyword name: The extended location name.
:paramtype name: str
"""
super().__init__(**kwargs)
self.type = type
self.name = name
class StoragecontainersListResult(_serialization.Model):
"""StoragecontainersListResult.
:ivar value:
:vartype value: list[~azure.mgmt.azurestackhci.models.Storagecontainers]
:ivar next_link:
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[Storagecontainers]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self, *, value: Optional[List["_models.Storagecontainers"]] = None, next_link: Optional[str] = None, **kwargs
):
"""
:keyword value:
:paramtype value: list[~azure.mgmt.azurestackhci.models.Storagecontainers]
:keyword next_link:
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class StoragecontainersPatch(_serialization.Model):
"""The storage container resource patch definition.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class StorageContainerStatus(_serialization.Model):
"""storageContainerStatus defines the observed state of storagecontainers.
:ivar error_code: StorageContainer provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar available_size_mb: Amount of space available on the disk in MB.
:vartype available_size_mb: int
:ivar container_size_mb: Total size of the disk in MB.
:vartype container_size_mb: int
:ivar provisioning_status: The provisioning status of the storage container.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.StorageContainerStatusProvisioningStatus
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"available_size_mb": {"key": "availableSizeMB", "type": "int"},
"container_size_mb": {"key": "containerSizeMB", "type": "int"},
"provisioning_status": {"key": "provisioningStatus", "type": "StorageContainerStatusProvisioningStatus"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
available_size_mb: Optional[int] = None,
container_size_mb: Optional[int] = None,
provisioning_status: Optional["_models.StorageContainerStatusProvisioningStatus"] = None,
**kwargs
):
"""
:keyword error_code: StorageContainer provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword available_size_mb: Amount of space available on the disk in MB.
:paramtype available_size_mb: int
:keyword container_size_mb: Total size of the disk in MB.
:paramtype container_size_mb: int
:keyword provisioning_status: The provisioning status of the storage container.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.StorageContainerStatusProvisioningStatus
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.available_size_mb = available_size_mb
self.container_size_mb = container_size_mb
self.provisioning_status = provisioning_status
class StorageContainerStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the storage container.
:ivar operation_id: The ID of the operation performed on the storage container.
:vartype operation_id: str
:ivar status: The status of the operation performed on the storage container [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the storage container.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the storage container [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
class StorageProfileUpdate(_serialization.Model):
"""StorageProfileUpdate.
:ivar data_disks: adds data disks to the virtual machine for the update call.
:vartype data_disks: list[~azure.mgmt.azurestackhci.models.StorageProfileUpdateDataDisksItem]
"""
_attribute_map = {
"data_disks": {"key": "dataDisks", "type": "[StorageProfileUpdateDataDisksItem]"},
}
def __init__(self, *, data_disks: Optional[List["_models.StorageProfileUpdateDataDisksItem"]] = None, **kwargs):
"""
:keyword data_disks: adds data disks to the virtual machine for the update call.
:paramtype data_disks: list[~azure.mgmt.azurestackhci.models.StorageProfileUpdateDataDisksItem]
"""
super().__init__(**kwargs)
self.data_disks = data_disks
class StorageProfileUpdateDataDisksItem(_serialization.Model):
"""StorageProfileUpdateDataDisksItem.
:ivar name:
:vartype name: str
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
}
def __init__(self, *, name: Optional[str] = None, **kwargs):
"""
:keyword name:
:paramtype name: str
"""
super().__init__(**kwargs)
self.name = name
class SystemData(_serialization.Model):
"""Metadata pertaining to creation and last modification of the resource.
:ivar created_by: The identity that created the resource.
:vartype created_by: str
:ivar created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:vartype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar created_at: The timestamp of resource creation (UTC).
:vartype created_at: ~datetime.datetime
:ivar last_modified_by: The identity that last modified the resource.
:vartype last_modified_by: str
:ivar last_modified_by_type: The type of identity that last modified the resource. Known values
are: "User", "Application", "ManagedIdentity", and "Key".
:vartype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:ivar last_modified_at: The timestamp of resource last modification (UTC).
:vartype last_modified_at: ~datetime.datetime
"""
_attribute_map = {
"created_by": {"key": "createdBy", "type": "str"},
"created_by_type": {"key": "createdByType", "type": "str"},
"created_at": {"key": "createdAt", "type": "iso-8601"},
"last_modified_by": {"key": "lastModifiedBy", "type": "str"},
"last_modified_by_type": {"key": "lastModifiedByType", "type": "str"},
"last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"},
}
def __init__(
self,
*,
created_by: Optional[str] = None,
created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
created_at: Optional[datetime.datetime] = None,
last_modified_by: Optional[str] = None,
last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None,
last_modified_at: Optional[datetime.datetime] = None,
**kwargs
):
"""
:keyword created_by: The identity that created the resource.
:paramtype created_by: str
:keyword created_by_type: The type of identity that created the resource. Known values are:
"User", "Application", "ManagedIdentity", and "Key".
:paramtype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword created_at: The timestamp of resource creation (UTC).
:paramtype created_at: ~datetime.datetime
:keyword last_modified_by: The identity that last modified the resource.
:paramtype last_modified_by: str
:keyword last_modified_by_type: The type of identity that last modified the resource. Known
values are: "User", "Application", "ManagedIdentity", and "Key".
:paramtype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType
:keyword last_modified_at: The timestamp of resource last modification (UTC).
:paramtype last_modified_at: ~datetime.datetime
"""
super().__init__(**kwargs)
self.created_by = created_by
self.created_by_type = created_by_type
self.created_at = created_at
self.last_modified_by = last_modified_by
self.last_modified_by_type = last_modified_by_type
self.last_modified_at = last_modified_at
class Virtualharddisks(TrackedResource): # pylint: disable=too-many-instance-attributes
"""The virtual hard disk resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar block_size_bytes:
:vartype block_size_bytes: int
:ivar disk_size_bytes: diskSizeBytes - size of the disk in GB.
:vartype disk_size_bytes: int
:ivar dynamic: Boolean for enabling dynamic sizing on the virtual hard disk.
:vartype dynamic: bool
:ivar logical_sector_bytes:
:vartype logical_sector_bytes: int
:ivar physical_sector_bytes:
:vartype physical_sector_bytes: int
:ivar hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known
values are: "V1" and "V2".
:vartype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration
:ivar disk_file_format: The format of the actual VHD file [vhd, vhdx]. Known values are: "vhdx"
and "vhd".
:vartype disk_file_format: str or ~azure.mgmt.azurestackhci.models.DiskFileFormat
:ivar provisioning_state: Provisioning state of the gallery image. Known values are:
"Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum
:ivar container_id: Storage ContainerID of the storage container to be used for VHD.
:vartype container_id: str
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar status: VirtualHardDiskStatus defines the observed state of virtualharddisks.
:vartype status: ~azure.mgmt.azurestackhci.models.VirtualHardDiskStatus
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"system_data": {"key": "systemData", "type": "SystemData"},
"block_size_bytes": {"key": "properties.blockSizeBytes", "type": "int"},
"disk_size_bytes": {"key": "properties.diskSizeBytes", "type": "int"},
"dynamic": {"key": "properties.dynamic", "type": "bool"},
"logical_sector_bytes": {"key": "properties.logicalSectorBytes", "type": "int"},
"physical_sector_bytes": {"key": "properties.physicalSectorBytes", "type": "int"},
"hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"},
"disk_file_format": {"key": "properties.diskFileFormat", "type": "str"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"container_id": {"key": "properties.containerId", "type": "str"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"status": {"key": "properties.status", "type": "VirtualHardDiskStatus"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
block_size_bytes: Optional[int] = None,
disk_size_bytes: Optional[int] = None,
dynamic: Optional[bool] = None,
logical_sector_bytes: Optional[int] = None,
physical_sector_bytes: Optional[int] = None,
hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None,
disk_file_format: Optional[Union[str, "_models.DiskFileFormat"]] = None,
container_id: Optional[str] = None,
resource_name: Optional[str] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:keyword block_size_bytes:
:paramtype block_size_bytes: int
:keyword disk_size_bytes: diskSizeBytes - size of the disk in GB.
:paramtype disk_size_bytes: int
:keyword dynamic: Boolean for enabling dynamic sizing on the virtual hard disk.
:paramtype dynamic: bool
:keyword logical_sector_bytes:
:paramtype logical_sector_bytes: int
:keyword physical_sector_bytes:
:paramtype physical_sector_bytes: int
:keyword hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known
values are: "V1" and "V2".
:paramtype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration
:keyword disk_file_format: The format of the actual VHD file [vhd, vhdx]. Known values are:
"vhdx" and "vhd".
:paramtype disk_file_format: str or ~azure.mgmt.azurestackhci.models.DiskFileFormat
:keyword container_id: Storage ContainerID of the storage container to be used for VHD.
:paramtype container_id: str
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.system_data = None
self.block_size_bytes = block_size_bytes
self.disk_size_bytes = disk_size_bytes
self.dynamic = dynamic
self.logical_sector_bytes = logical_sector_bytes
self.physical_sector_bytes = physical_sector_bytes
self.hyper_v_generation = hyper_v_generation
self.disk_file_format = disk_file_format
self.provisioning_state = None
self.container_id = container_id
self.resource_name = resource_name
self.status = None
class VirtualharddisksListResult(_serialization.Model):
"""VirtualharddisksListResult.
:ivar value:
:vartype value: list[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:ivar next_link:
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[Virtualharddisks]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self, *, value: Optional[List["_models.Virtualharddisks"]] = None, next_link: Optional[str] = None, **kwargs
):
"""
:keyword value:
:paramtype value: list[~azure.mgmt.azurestackhci.models.Virtualharddisks]
:keyword next_link:
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class VirtualharddisksPatch(_serialization.Model):
"""The virtual hard disk resource patch definition.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class VirtualHardDiskStatus(_serialization.Model):
"""VirtualHardDiskStatus defines the observed state of virtualharddisks.
:ivar error_code: VirtualHardDisk provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar provisioning_status: The provisioning status of the virtual hard disk.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.VirtualHardDiskStatusProvisioningStatus
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"provisioning_status": {"key": "provisioningStatus", "type": "VirtualHardDiskStatusProvisioningStatus"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
provisioning_status: Optional["_models.VirtualHardDiskStatusProvisioningStatus"] = None,
**kwargs
):
"""
:keyword error_code: VirtualHardDisk provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword provisioning_status: The provisioning status of the virtual hard disk.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.VirtualHardDiskStatusProvisioningStatus
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.provisioning_status = provisioning_status
class VirtualHardDiskStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the virtual hard disk.
:ivar operation_id: The ID of the operation performed on the virtual hard disk.
:vartype operation_id: str
:ivar status: The status of the operation performed on the virtual hard disk [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the virtual hard disk.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the virtual hard disk [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
class Virtualmachines(TrackedResource): # pylint: disable=too-many-instance-attributes
"""The virtual machine resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:ivar identity: Identity for the resource.
:vartype identity: ~azure.mgmt.azurestackhci.models.Identity
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar hardware_profile: HardwareProfile - Specifies the hardware settings for the virtual
machine.
:vartype hardware_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesHardwareProfile
:ivar network_profile: NetworkProfile - describes the network configuration the virtual
machine.
:vartype network_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesNetworkProfile
:ivar os_profile: OsProfile - describes the configuration of the operating system and sets
login data.
:vartype os_profile: ~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfile
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar security_profile: SecurityProfile - Specifies the security settings for the virtual
machine.
:vartype security_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesSecurityProfile
:ivar storage_profile: StorageProfile - contains information about the disks and storage
information for the virtual machine.
:vartype storage_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfile
:ivar provisioning_state: Provisioning state of the gallery image. Known values are:
"Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum
:ivar status: VirtualMachineStatus defines the observed state of virtualmachines.
:vartype status: ~azure.mgmt.azurestackhci.models.VirtualMachineStatus
:ivar guest_agent_profile: Guest agent status properties.
:vartype guest_agent_profile: ~azure.mgmt.azurestackhci.models.GuestAgentProfile
:ivar vm_id: Unique identifier for the vm resource.
:vartype vm_id: str
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
"vm_id": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"identity": {"key": "identity", "type": "Identity"},
"system_data": {"key": "systemData", "type": "SystemData"},
"hardware_profile": {"key": "properties.hardwareProfile", "type": "VirtualmachinesPropertiesHardwareProfile"},
"network_profile": {"key": "properties.networkProfile", "type": "VirtualmachinesPropertiesNetworkProfile"},
"os_profile": {"key": "properties.osProfile", "type": "VirtualmachinesPropertiesOsProfile"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"security_profile": {"key": "properties.securityProfile", "type": "VirtualmachinesPropertiesSecurityProfile"},
"storage_profile": {"key": "properties.storageProfile", "type": "VirtualmachinesPropertiesStorageProfile"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"status": {"key": "properties.status", "type": "VirtualMachineStatus"},
"guest_agent_profile": {"key": "properties.guestAgentProfile", "type": "GuestAgentProfile"},
"vm_id": {"key": "properties.vmId", "type": "str"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
identity: Optional["_models.Identity"] = None,
hardware_profile: Optional["_models.VirtualmachinesPropertiesHardwareProfile"] = None,
network_profile: Optional["_models.VirtualmachinesPropertiesNetworkProfile"] = None,
os_profile: Optional["_models.VirtualmachinesPropertiesOsProfile"] = None,
resource_name: Optional[str] = None,
security_profile: Optional["_models.VirtualmachinesPropertiesSecurityProfile"] = None,
storage_profile: Optional["_models.VirtualmachinesPropertiesStorageProfile"] = None,
guest_agent_profile: Optional["_models.GuestAgentProfile"] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:keyword identity: Identity for the resource.
:paramtype identity: ~azure.mgmt.azurestackhci.models.Identity
:keyword hardware_profile: HardwareProfile - Specifies the hardware settings for the virtual
machine.
:paramtype hardware_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesHardwareProfile
:keyword network_profile: NetworkProfile - describes the network configuration the virtual
machine.
:paramtype network_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesNetworkProfile
:keyword os_profile: OsProfile - describes the configuration of the operating system and sets
login data.
:paramtype os_profile: ~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfile
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
:keyword security_profile: SecurityProfile - Specifies the security settings for the virtual
machine.
:paramtype security_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesSecurityProfile
:keyword storage_profile: StorageProfile - contains information about the disks and storage
information for the virtual machine.
:paramtype storage_profile:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfile
:keyword guest_agent_profile: Guest agent status properties.
:paramtype guest_agent_profile: ~azure.mgmt.azurestackhci.models.GuestAgentProfile
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.identity = identity
self.system_data = None
self.hardware_profile = hardware_profile
self.network_profile = network_profile
self.os_profile = os_profile
self.resource_name = resource_name
self.security_profile = security_profile
self.storage_profile = storage_profile
self.provisioning_state = None
self.status = None
self.guest_agent_profile = guest_agent_profile
self.vm_id = None
class VirtualmachinesListResult(_serialization.Model):
"""VirtualmachinesListResult.
:ivar value:
:vartype value: list[~azure.mgmt.azurestackhci.models.Virtualmachines]
:ivar next_link:
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[Virtualmachines]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self, *, value: Optional[List["_models.Virtualmachines"]] = None, next_link: Optional[str] = None, **kwargs
):
"""
:keyword value:
:paramtype value: list[~azure.mgmt.azurestackhci.models.Virtualmachines]
:keyword next_link:
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class VirtualmachinesPatch(_serialization.Model):
"""The virtual machine resource patch definition.
:ivar properties: Defines the resource properties for the update.
:vartype properties: ~azure.mgmt.azurestackhci.models.VirtualMachineUpdateProperties
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"properties": {"key": "properties", "type": "VirtualMachineUpdateProperties"},
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(
self,
*,
properties: Optional["_models.VirtualMachineUpdateProperties"] = None,
tags: Optional[Dict[str, str]] = None,
**kwargs
):
"""
:keyword properties: Defines the resource properties for the update.
:paramtype properties: ~azure.mgmt.azurestackhci.models.VirtualMachineUpdateProperties
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.properties = properties
self.tags = tags
class VirtualmachinesPropertiesHardwareProfile(_serialization.Model):
"""HardwareProfile - Specifies the hardware settings for the virtual machine.
:ivar vm_size:
:vartype vm_size: str
:ivar processors: number of processors for the virtual machine.
:vartype processors: int
:ivar memory_gb: RAM in gb for the virtual machine.
:vartype memory_gb: int
:ivar dynamic_memory_config:
:vartype dynamic_memory_config:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig
"""
_attribute_map = {
"vm_size": {"key": "vmSize", "type": "str"},
"processors": {"key": "processors", "type": "int"},
"memory_gb": {"key": "memoryGB", "type": "int"},
"dynamic_memory_config": {
"key": "dynamicMemoryConfig",
"type": "VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig",
},
}
def __init__(
self,
*,
vm_size: Optional[str] = None,
processors: Optional[int] = None,
memory_gb: Optional[int] = None,
dynamic_memory_config: Optional["_models.VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig"] = None,
**kwargs
):
"""
:keyword vm_size:
:paramtype vm_size: str
:keyword processors: number of processors for the virtual machine.
:paramtype processors: int
:keyword memory_gb: RAM in gb for the virtual machine.
:paramtype memory_gb: int
:keyword dynamic_memory_config:
:paramtype dynamic_memory_config:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig
"""
super().__init__(**kwargs)
self.vm_size = vm_size
self.processors = processors
self.memory_gb = memory_gb
self.dynamic_memory_config = dynamic_memory_config
class VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig(_serialization.Model):
"""VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig.
:ivar maximum_memory_gb:
:vartype maximum_memory_gb: int
:ivar minimum_memory_gb:
:vartype minimum_memory_gb: int
:ivar target_memory_buffer:
:vartype target_memory_buffer: int
"""
_attribute_map = {
"maximum_memory_gb": {"key": "maximumMemoryGB", "type": "int"},
"minimum_memory_gb": {"key": "minimumMemoryGB", "type": "int"},
"target_memory_buffer": {"key": "targetMemoryBuffer", "type": "int"},
}
def __init__(
self,
*,
maximum_memory_gb: Optional[int] = None,
minimum_memory_gb: Optional[int] = None,
target_memory_buffer: Optional[int] = None,
**kwargs
):
"""
:keyword maximum_memory_gb:
:paramtype maximum_memory_gb: int
:keyword minimum_memory_gb:
:paramtype minimum_memory_gb: int
:keyword target_memory_buffer:
:paramtype target_memory_buffer: int
"""
super().__init__(**kwargs)
self.maximum_memory_gb = maximum_memory_gb
self.minimum_memory_gb = minimum_memory_gb
self.target_memory_buffer = target_memory_buffer
class VirtualmachinesPropertiesNetworkProfile(_serialization.Model):
"""NetworkProfile - describes the network configuration the virtual machine.
:ivar network_interfaces: NetworkInterfaces - list of network interfaces to be attached to the
virtual machine.
:vartype network_interfaces:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem]
"""
_attribute_map = {
"network_interfaces": {
"key": "networkInterfaces",
"type": "[VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem]",
},
}
def __init__(
self,
*,
network_interfaces: Optional[
List["_models.VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem"]
] = None,
**kwargs
):
"""
:keyword network_interfaces: NetworkInterfaces - list of network interfaces to be attached to
the virtual machine.
:paramtype network_interfaces:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem]
"""
super().__init__(**kwargs)
self.network_interfaces = network_interfaces
class VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem(_serialization.Model):
"""VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem.
:ivar id: ID - Resource Id of the network interface.
:vartype id: str
"""
_attribute_map = {
"id": {"key": "id", "type": "str"},
}
def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin
"""
:keyword id: ID - Resource Id of the network interface.
:paramtype id: str
"""
super().__init__(**kwargs)
self.id = id
class VirtualmachinesPropertiesOsProfile(_serialization.Model):
"""OsProfile - describes the configuration of the operating system and sets login data.
:ivar admin_password: AdminPassword - admin password.
:vartype admin_password: str
:ivar admin_username: AdminUsername - admin username.
:vartype admin_username: str
:ivar computer_name: ComputerName - name of the compute.
:vartype computer_name: str
:ivar linux_configuration: LinuxConfiguration - linux specific configuration values for the
virtual machine.
:vartype linux_configuration:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileLinuxConfiguration
:ivar os_type: OsType - string specifying whether the OS is Linux or Windows. Known values are:
"Linux" and "Windows".
:vartype os_type: str or ~azure.mgmt.azurestackhci.models.OsTypeEnum
:ivar windows_configuration: Windows Configuration for the virtual machine.
:vartype windows_configuration:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileWindowsConfiguration
"""
_attribute_map = {
"admin_password": {"key": "adminPassword", "type": "str"},
"admin_username": {"key": "adminUsername", "type": "str"},
"computer_name": {"key": "computerName", "type": "str"},
"linux_configuration": {
"key": "linuxConfiguration",
"type": "VirtualmachinesPropertiesOsProfileLinuxConfiguration",
},
"os_type": {"key": "osType", "type": "str"},
"windows_configuration": {
"key": "windowsConfiguration",
"type": "VirtualmachinesPropertiesOsProfileWindowsConfiguration",
},
}
def __init__(
self,
*,
admin_password: Optional[str] = None,
admin_username: Optional[str] = None,
computer_name: Optional[str] = None,
linux_configuration: Optional["_models.VirtualmachinesPropertiesOsProfileLinuxConfiguration"] = None,
os_type: Optional[Union[str, "_models.OsTypeEnum"]] = None,
windows_configuration: Optional["_models.VirtualmachinesPropertiesOsProfileWindowsConfiguration"] = None,
**kwargs
):
"""
:keyword admin_password: AdminPassword - admin password.
:paramtype admin_password: str
:keyword admin_username: AdminUsername - admin username.
:paramtype admin_username: str
:keyword computer_name: ComputerName - name of the compute.
:paramtype computer_name: str
:keyword linux_configuration: LinuxConfiguration - linux specific configuration values for the
virtual machine.
:paramtype linux_configuration:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileLinuxConfiguration
:keyword os_type: OsType - string specifying whether the OS is Linux or Windows. Known values
are: "Linux" and "Windows".
:paramtype os_type: str or ~azure.mgmt.azurestackhci.models.OsTypeEnum
:keyword windows_configuration: Windows Configuration for the virtual machine.
:paramtype windows_configuration:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileWindowsConfiguration
"""
super().__init__(**kwargs)
self.admin_password = admin_password
self.admin_username = admin_username
self.computer_name = computer_name
self.linux_configuration = linux_configuration
self.os_type = os_type
self.windows_configuration = windows_configuration
class VirtualmachinesPropertiesOsProfileLinuxConfiguration(_serialization.Model):
"""LinuxConfiguration - linux specific configuration values for the virtual machine.
:ivar disable_password_authentication: DisablePasswordAuthentication - whether password
authentication should be disabled.
:vartype disable_password_authentication: bool
:ivar ssh: SSH - contains settings related to ssh configuration.
:vartype ssh:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh
:ivar provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should be
triggered during the virtual machine creation process.
:vartype provision_vm_agent: bool
"""
_attribute_map = {
"disable_password_authentication": {"key": "disablePasswordAuthentication", "type": "bool"},
"ssh": {"key": "ssh", "type": "VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh"},
"provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"},
}
def __init__(
self,
*,
disable_password_authentication: Optional[bool] = None,
ssh: Optional["_models.VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh"] = None,
provision_vm_agent: Optional[bool] = None,
**kwargs
):
"""
:keyword disable_password_authentication: DisablePasswordAuthentication - whether password
authentication should be disabled.
:paramtype disable_password_authentication: bool
:keyword ssh: SSH - contains settings related to ssh configuration.
:paramtype ssh:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh
:keyword provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should
be triggered during the virtual machine creation process.
:paramtype provision_vm_agent: bool
"""
super().__init__(**kwargs)
self.disable_password_authentication = disable_password_authentication
self.ssh = ssh
self.provision_vm_agent = provision_vm_agent
class VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh(_serialization.Model):
"""SSH - contains settings related to ssh configuration.
:ivar public_keys: PublicKeys - The list of SSH public keys used to authenticate with linux
based VMs.
:vartype public_keys:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem]
"""
_attribute_map = {
"public_keys": {
"key": "publicKeys",
"type": "[VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem]",
},
}
def __init__(
self,
*,
public_keys: Optional[
List["_models.VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem"]
] = None,
**kwargs
):
"""
:keyword public_keys: PublicKeys - The list of SSH public keys used to authenticate with linux
based VMs.
:paramtype public_keys:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem]
"""
super().__init__(**kwargs)
self.public_keys = public_keys
class VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem(_serialization.Model):
"""VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem.
:ivar key_data: KeyData - SSH public key certificate used to authenticate with the VM through
ssh. The key needs to be at least 2048-bit and in ssh-rsa format. :code:`<br>`:code:`<br>` For
creating ssh keys, see `Create SSH keys on Linux and Mac for Li nux VMs in Azure
<https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-mac-create-ssh-keys?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json>`_.
:vartype key_data: str
:ivar path: Path - Specifies the full path on the created VM where ssh public key is stored. If
the file already exists, the specified key is appended to the file. Example:
/home/user/.ssh/authorized_keys.
:vartype path: str
"""
_attribute_map = {
"key_data": {"key": "keyData", "type": "str"},
"path": {"key": "path", "type": "str"},
}
def __init__(self, *, key_data: Optional[str] = None, path: Optional[str] = None, **kwargs):
"""
:keyword key_data: KeyData - SSH public key certificate used to authenticate with the VM
through ssh. The key needs to be at least 2048-bit and in ssh-rsa format.
:code:`<br>`:code:`<br>` For creating ssh keys, see `Create SSH keys on Linux and Mac for Li
nux VMs in Azure
<https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-mac-create-ssh-keys?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json>`_.
:paramtype key_data: str
:keyword path: Path - Specifies the full path on the created VM where ssh public key is stored.
If the file already exists, the specified key is appended to the file. Example:
/home/user/.ssh/authorized_keys.
:paramtype path: str
"""
super().__init__(**kwargs)
self.key_data = key_data
self.path = path
class VirtualmachinesPropertiesOsProfileWindowsConfiguration(_serialization.Model):
"""Windows Configuration for the virtual machine.
:ivar enable_automatic_updates: Whether to EnableAutomaticUpdates on the machine.
:vartype enable_automatic_updates: bool
:ivar ssh: SSH Configuration.
:vartype ssh:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh
:ivar time_zone: TimeZone for the virtual machine.
:vartype time_zone: str
:ivar provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should be
triggered during the virtual machine creation process.
:vartype provision_vm_agent: bool
"""
_attribute_map = {
"enable_automatic_updates": {"key": "enableAutomaticUpdates", "type": "bool"},
"ssh": {"key": "ssh", "type": "VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh"},
"time_zone": {"key": "timeZone", "type": "str"},
"provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"},
}
def __init__(
self,
*,
enable_automatic_updates: Optional[bool] = None,
ssh: Optional["_models.VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh"] = None,
time_zone: Optional[str] = None,
provision_vm_agent: Optional[bool] = None,
**kwargs
):
"""
:keyword enable_automatic_updates: Whether to EnableAutomaticUpdates on the machine.
:paramtype enable_automatic_updates: bool
:keyword ssh: SSH Configuration.
:paramtype ssh:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh
:keyword time_zone: TimeZone for the virtual machine.
:paramtype time_zone: str
:keyword provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should
be triggered during the virtual machine creation process.
:paramtype provision_vm_agent: bool
"""
super().__init__(**kwargs)
self.enable_automatic_updates = enable_automatic_updates
self.ssh = ssh
self.time_zone = time_zone
self.provision_vm_agent = provision_vm_agent
class VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh(_serialization.Model):
"""SSH Configuration.
:ivar public_keys: PublicKeys - The list of SSH public keys used to authenticate with linux
based VMs.
:vartype public_keys:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem]
"""
_attribute_map = {
"public_keys": {
"key": "publicKeys",
"type": "[VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem]",
},
}
def __init__(
self,
*,
public_keys: Optional[
List["_models.VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem"]
] = None,
**kwargs
):
"""
:keyword public_keys: PublicKeys - The list of SSH public keys used to authenticate with linux
based VMs.
:paramtype public_keys:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem]
"""
super().__init__(**kwargs)
self.public_keys = public_keys
class VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem(_serialization.Model):
"""VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem.
:ivar key_data: KeyData - SSH public key certificate used to authenticate with the VM through
ssh. The key needs to be at least 2048-bit and in ssh-rsa format. :code:`<br>`:code:`<br>` For
creating ssh keys, see `Create SSH keys on Linux and Mac for Li nux VMs in Azure
<https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-mac-create-ssh-keys?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json>`_.
:vartype key_data: str
:ivar path: Path - Specifies the full path on the created VM where ssh public key is stored. If
the file already exists, the specified key is appended to the file. Example:
/home/user/.ssh/authorized_keys.
:vartype path: str
"""
_attribute_map = {
"key_data": {"key": "keyData", "type": "str"},
"path": {"key": "path", "type": "str"},
}
def __init__(self, *, key_data: Optional[str] = None, path: Optional[str] = None, **kwargs):
"""
:keyword key_data: KeyData - SSH public key certificate used to authenticate with the VM
through ssh. The key needs to be at least 2048-bit and in ssh-rsa format.
:code:`<br>`:code:`<br>` For creating ssh keys, see `Create SSH keys on Linux and Mac for Li
nux VMs in Azure
<https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-mac-create-ssh-keys?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json>`_.
:paramtype key_data: str
:keyword path: Path - Specifies the full path on the created VM where ssh public key is stored.
If the file already exists, the specified key is appended to the file. Example:
/home/user/.ssh/authorized_keys.
:paramtype path: str
"""
super().__init__(**kwargs)
self.key_data = key_data
self.path = path
class VirtualmachinesPropertiesSecurityProfile(_serialization.Model):
"""SecurityProfile - Specifies the security settings for the virtual machine.
:ivar enable_tpm:
:vartype enable_tpm: bool
:ivar uefi_settings:
:vartype uefi_settings:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesSecurityProfileUefiSettings
"""
_attribute_map = {
"enable_tpm": {"key": "enableTPM", "type": "bool"},
"uefi_settings": {"key": "uefiSettings", "type": "VirtualmachinesPropertiesSecurityProfileUefiSettings"},
}
def __init__(
self,
*,
enable_tpm: Optional[bool] = None,
uefi_settings: Optional["_models.VirtualmachinesPropertiesSecurityProfileUefiSettings"] = None,
**kwargs
):
"""
:keyword enable_tpm:
:paramtype enable_tpm: bool
:keyword uefi_settings:
:paramtype uefi_settings:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesSecurityProfileUefiSettings
"""
super().__init__(**kwargs)
self.enable_tpm = enable_tpm
self.uefi_settings = uefi_settings
class VirtualmachinesPropertiesSecurityProfileUefiSettings(_serialization.Model):
"""VirtualmachinesPropertiesSecurityProfileUefiSettings.
:ivar secure_boot_enabled: Specifies whether secure boot should be enabled on the virtual
machine.
:vartype secure_boot_enabled: bool
"""
_attribute_map = {
"secure_boot_enabled": {"key": "secureBootEnabled", "type": "bool"},
}
def __init__(self, *, secure_boot_enabled: Optional[bool] = None, **kwargs):
"""
:keyword secure_boot_enabled: Specifies whether secure boot should be enabled on the virtual
machine.
:paramtype secure_boot_enabled: bool
"""
super().__init__(**kwargs)
self.secure_boot_enabled = secure_boot_enabled
class VirtualmachinesPropertiesStorageProfile(_serialization.Model):
"""StorageProfile - contains information about the disks and storage information for the virtual machine.
:ivar data_disks: adds data disks to the virtual machine.
:vartype data_disks:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfileDataDisksItem]
:ivar image_reference: Which Image to use for the virtual machine.
:vartype image_reference:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfileImageReference
:ivar os_disk: VHD to attach as OS disk.
:vartype os_disk:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfileOsDisk
:ivar vm_config_container_name: Name of the storage container that hosts the VM configuration
file.
:vartype vm_config_container_name: str
"""
_attribute_map = {
"data_disks": {"key": "dataDisks", "type": "[VirtualmachinesPropertiesStorageProfileDataDisksItem]"},
"image_reference": {"key": "imageReference", "type": "VirtualmachinesPropertiesStorageProfileImageReference"},
"os_disk": {"key": "osDisk", "type": "VirtualmachinesPropertiesStorageProfileOsDisk"},
"vm_config_container_name": {"key": "vmConfigContainerName", "type": "str"},
}
def __init__(
self,
*,
data_disks: Optional[List["_models.VirtualmachinesPropertiesStorageProfileDataDisksItem"]] = None,
image_reference: Optional["_models.VirtualmachinesPropertiesStorageProfileImageReference"] = None,
os_disk: Optional["_models.VirtualmachinesPropertiesStorageProfileOsDisk"] = None,
vm_config_container_name: Optional[str] = None,
**kwargs
):
"""
:keyword data_disks: adds data disks to the virtual machine.
:paramtype data_disks:
list[~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfileDataDisksItem]
:keyword image_reference: Which Image to use for the virtual machine.
:paramtype image_reference:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfileImageReference
:keyword os_disk: VHD to attach as OS disk.
:paramtype os_disk:
~azure.mgmt.azurestackhci.models.VirtualmachinesPropertiesStorageProfileOsDisk
:keyword vm_config_container_name: Name of the storage container that hosts the VM
configuration file.
:paramtype vm_config_container_name: str
"""
super().__init__(**kwargs)
self.data_disks = data_disks
self.image_reference = image_reference
self.os_disk = os_disk
self.vm_config_container_name = vm_config_container_name
class VirtualmachinesPropertiesStorageProfileDataDisksItem(_serialization.Model):
"""VirtualmachinesPropertiesStorageProfileDataDisksItem.
:ivar name:
:vartype name: str
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
}
def __init__(self, *, name: Optional[str] = None, **kwargs):
"""
:keyword name:
:paramtype name: str
"""
super().__init__(**kwargs)
self.name = name
class VirtualmachinesPropertiesStorageProfileImageReference(_serialization.Model):
"""Which Image to use for the virtual machine.
:ivar name: Name - Name of the image.
:vartype name: str
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
}
def __init__(self, *, name: Optional[str] = None, **kwargs):
"""
:keyword name: Name - Name of the image.
:paramtype name: str
"""
super().__init__(**kwargs)
self.name = name
class VirtualmachinesPropertiesStorageProfileOsDisk(_serialization.Model):
"""VHD to attach as OS disk.
:ivar id: Specifies the virtual hard disk's ID.
:vartype id: str
"""
_attribute_map = {
"id": {"key": "id", "type": "str"},
}
def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin
"""
:keyword id: Specifies the virtual hard disk's ID.
:paramtype id: str
"""
super().__init__(**kwargs)
self.id = id
class VirtualMachineStatus(_serialization.Model):
"""VirtualMachineStatus defines the observed state of virtualmachines.
:ivar error_code: VirtualMachine provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar power_state: The power state of the virtual machine. Known values are: "Deallocated",
"Deallocating", "Running", "Starting", "Stopped", "Stopping", and "Unknown".
:vartype power_state: str or ~azure.mgmt.azurestackhci.models.PowerStateEnum
:ivar provisioning_status: The provisioning status of the virtual machine.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.VirtualMachineStatusProvisioningStatus
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"power_state": {"key": "powerState", "type": "str"},
"provisioning_status": {"key": "provisioningStatus", "type": "VirtualMachineStatusProvisioningStatus"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
power_state: Optional[Union[str, "_models.PowerStateEnum"]] = None,
provisioning_status: Optional["_models.VirtualMachineStatusProvisioningStatus"] = None,
**kwargs
):
"""
:keyword error_code: VirtualMachine provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword power_state: The power state of the virtual machine. Known values are: "Deallocated",
"Deallocating", "Running", "Starting", "Stopped", "Stopping", and "Unknown".
:paramtype power_state: str or ~azure.mgmt.azurestackhci.models.PowerStateEnum
:keyword provisioning_status: The provisioning status of the virtual machine.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.VirtualMachineStatusProvisioningStatus
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.power_state = power_state
self.provisioning_status = provisioning_status
class VirtualMachineStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the virtual machine.
:ivar operation_id: The ID of the operation performed on the virtual machine.
:vartype operation_id: str
:ivar status: The status of the operation performed on the virtual machine [Succeeded, Failed,
InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the virtual machine.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the virtual machine [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
class VirtualMachineUpdateProperties(_serialization.Model):
"""Defines the resource properties for the update.
:ivar hardware_profile: HardwareProfile - Specifies the hardware settings for the virtual
machine.
:vartype hardware_profile: ~azure.mgmt.azurestackhci.models.HardwareProfileUpdate
:ivar storage_profile:
:vartype storage_profile: ~azure.mgmt.azurestackhci.models.StorageProfileUpdate
:ivar network_profile: NetworkProfile - describes the network update configuration the virtual
machine.
:vartype network_profile: ~azure.mgmt.azurestackhci.models.NetworkProfileUpdate
"""
_attribute_map = {
"hardware_profile": {"key": "hardwareProfile", "type": "HardwareProfileUpdate"},
"storage_profile": {"key": "storageProfile", "type": "StorageProfileUpdate"},
"network_profile": {"key": "networkProfile", "type": "NetworkProfileUpdate"},
}
def __init__(
self,
*,
hardware_profile: Optional["_models.HardwareProfileUpdate"] = None,
storage_profile: Optional["_models.StorageProfileUpdate"] = None,
network_profile: Optional["_models.NetworkProfileUpdate"] = None,
**kwargs
):
"""
:keyword hardware_profile: HardwareProfile - Specifies the hardware settings for the virtual
machine.
:paramtype hardware_profile: ~azure.mgmt.azurestackhci.models.HardwareProfileUpdate
:keyword storage_profile:
:paramtype storage_profile: ~azure.mgmt.azurestackhci.models.StorageProfileUpdate
:keyword network_profile: NetworkProfile - describes the network update configuration the
virtual machine.
:paramtype network_profile: ~azure.mgmt.azurestackhci.models.NetworkProfileUpdate
"""
super().__init__(**kwargs)
self.hardware_profile = hardware_profile
self.storage_profile = storage_profile
self.network_profile = network_profile
class Virtualnetworks(TrackedResource): # pylint: disable=too-many-instance-attributes
"""The virtual network resource definition.
Variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to Azure.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
:vartype id: str
:ivar name: The name of the resource.
:vartype name: str
:ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or
"Microsoft.Storage/storageAccounts".
:vartype type: str
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
:ivar location: The geo-location where the resource lives. Required.
:vartype location: str
:ivar extended_location: The extendedLocation of the resource.
:vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:ivar system_data: Metadata pertaining to creation and last modification of the resource.
:vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData
:ivar network_type: Type of the network. Known values are: "NAT", "Transparent", "L2Bridge",
"L2Tunnel", "ICS", "Private", "Overlay", "Internal", and "Mirrored".
:vartype network_type: str or ~azure.mgmt.azurestackhci.models.NetworkTypeEnum
:ivar subnets: Subnet - list of subnets under the virtual network.
:vartype subnets: list[~azure.mgmt.azurestackhci.models.VirtualnetworksPropertiesSubnetsItem]
:ivar provisioning_state: Provisioning state of the gallery image. Known values are:
"Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled".
:vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum
:ivar resource_name: name of the object to be used in moc.
:vartype resource_name: str
:ivar status: VirtualNetworkStatus defines the observed state of virtual networks.
:vartype status: ~azure.mgmt.azurestackhci.models.VirtualNetworkStatus
"""
_validation = {
"id": {"readonly": True},
"name": {"readonly": True},
"type": {"readonly": True},
"location": {"required": True},
"system_data": {"readonly": True},
"provisioning_state": {"readonly": True},
"status": {"readonly": True},
}
_attribute_map = {
"id": {"key": "id", "type": "str"},
"name": {"key": "name", "type": "str"},
"type": {"key": "type", "type": "str"},
"tags": {"key": "tags", "type": "{str}"},
"location": {"key": "location", "type": "str"},
"extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"},
"system_data": {"key": "systemData", "type": "SystemData"},
"network_type": {"key": "properties.networkType", "type": "str"},
"subnets": {"key": "properties.subnets", "type": "[VirtualnetworksPropertiesSubnetsItem]"},
"provisioning_state": {"key": "properties.provisioningState", "type": "str"},
"resource_name": {"key": "properties.resourceName", "type": "str"},
"status": {"key": "properties.status", "type": "VirtualNetworkStatus"},
}
def __init__(
self,
*,
location: str,
tags: Optional[Dict[str, str]] = None,
extended_location: Optional["_models.ExtendedLocation"] = None,
network_type: Optional[Union[str, "_models.NetworkTypeEnum"]] = None,
subnets: Optional[List["_models.VirtualnetworksPropertiesSubnetsItem"]] = None,
resource_name: Optional[str] = None,
**kwargs
):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
:keyword location: The geo-location where the resource lives. Required.
:paramtype location: str
:keyword extended_location: The extendedLocation of the resource.
:paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation
:keyword network_type: Type of the network. Known values are: "NAT", "Transparent", "L2Bridge",
"L2Tunnel", "ICS", "Private", "Overlay", "Internal", and "Mirrored".
:paramtype network_type: str or ~azure.mgmt.azurestackhci.models.NetworkTypeEnum
:keyword subnets: Subnet - list of subnets under the virtual network.
:paramtype subnets: list[~azure.mgmt.azurestackhci.models.VirtualnetworksPropertiesSubnetsItem]
:keyword resource_name: name of the object to be used in moc.
:paramtype resource_name: str
"""
super().__init__(tags=tags, location=location, **kwargs)
self.extended_location = extended_location
self.system_data = None
self.network_type = network_type
self.subnets = subnets
self.provisioning_state = None
self.resource_name = resource_name
self.status = None
class VirtualnetworksListResult(_serialization.Model):
"""VirtualnetworksListResult.
:ivar value:
:vartype value: list[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:ivar next_link:
:vartype next_link: str
"""
_attribute_map = {
"value": {"key": "value", "type": "[Virtualnetworks]"},
"next_link": {"key": "nextLink", "type": "str"},
}
def __init__(
self, *, value: Optional[List["_models.Virtualnetworks"]] = None, next_link: Optional[str] = None, **kwargs
):
"""
:keyword value:
:paramtype value: list[~azure.mgmt.azurestackhci.models.Virtualnetworks]
:keyword next_link:
:paramtype next_link: str
"""
super().__init__(**kwargs)
self.value = value
self.next_link = next_link
class VirtualnetworksPatch(_serialization.Model):
"""The virtual network resource patch definition.
:ivar tags: Resource tags.
:vartype tags: dict[str, str]
"""
_attribute_map = {
"tags": {"key": "tags", "type": "{str}"},
}
def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs):
"""
:keyword tags: Resource tags.
:paramtype tags: dict[str, str]
"""
super().__init__(**kwargs)
self.tags = tags
class VirtualnetworksPropertiesSubnetsItem(_serialization.Model):
"""Subnet subnet in a virtual network resource.
:ivar name: Name - The name of the resource that is unique within a resource group. This name
can be used to access the resource.
:vartype name: str
:ivar address_prefix: Cidr for this subnet - IPv4, IPv6.
:vartype address_prefix: str
:ivar address_prefixes: AddressPrefixes - List of address prefixes for the subnet.
:vartype address_prefixes: list[str]
:ivar ip_allocation_method: IPAllocationMethod - The IP address allocation method. Possible
values include: 'Static', 'Dynamic'. Known values are: "Dynamic" and "Static".
:vartype ip_allocation_method: str or ~azure.mgmt.azurestackhci.models.IpAllocationMethodEnum
:ivar ip_configuration_references: IPConfigurationReferences - list of
IPConfigurationReferences.
:vartype ip_configuration_references:
list[~azure.mgmt.azurestackhci.models.ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems]
:ivar route_table: RouteTable for the subnet.
:vartype route_table:
~azure.mgmt.azurestackhci.models.ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable
:ivar ip_pools: network associated pool of IP Addresses.
:vartype ip_pools: list[~azure.mgmt.azurestackhci.models.IPPool]
:ivar vlan: Vlan to use for the subnet.
:vartype vlan: int
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"address_prefix": {"key": "properties.addressPrefix", "type": "str"},
"address_prefixes": {"key": "properties.addressPrefixes", "type": "[str]"},
"ip_allocation_method": {"key": "properties.ipAllocationMethod", "type": "str"},
"ip_configuration_references": {
"key": "properties.ipConfigurationReferences",
"type": "[ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems]",
},
"route_table": {
"key": "properties.routeTable",
"type": "ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable",
},
"ip_pools": {"key": "properties.ipPools", "type": "[IPPool]"},
"vlan": {"key": "properties.vlan", "type": "int"},
}
def __init__(
self,
*,
name: Optional[str] = None,
address_prefix: Optional[str] = None,
address_prefixes: Optional[List[str]] = None,
ip_allocation_method: Optional[Union[str, "_models.IpAllocationMethodEnum"]] = None,
ip_configuration_references: Optional[
List[
"_models.ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems"
]
] = None,
route_table: Optional[
"_models.ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable"
] = None,
ip_pools: Optional[List["_models.IPPool"]] = None,
vlan: Optional[int] = None,
**kwargs
):
"""
:keyword name: Name - The name of the resource that is unique within a resource group. This
name can be used to access the resource.
:paramtype name: str
:keyword address_prefix: Cidr for this subnet - IPv4, IPv6.
:paramtype address_prefix: str
:keyword address_prefixes: AddressPrefixes - List of address prefixes for the subnet.
:paramtype address_prefixes: list[str]
:keyword ip_allocation_method: IPAllocationMethod - The IP address allocation method. Possible
values include: 'Static', 'Dynamic'. Known values are: "Dynamic" and "Static".
:paramtype ip_allocation_method: str or ~azure.mgmt.azurestackhci.models.IpAllocationMethodEnum
:keyword ip_configuration_references: IPConfigurationReferences - list of
IPConfigurationReferences.
:paramtype ip_configuration_references:
list[~azure.mgmt.azurestackhci.models.ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems]
:keyword route_table: RouteTable for the subnet.
:paramtype route_table:
~azure.mgmt.azurestackhci.models.ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable
:keyword ip_pools: network associated pool of IP Addresses.
:paramtype ip_pools: list[~azure.mgmt.azurestackhci.models.IPPool]
:keyword vlan: Vlan to use for the subnet.
:paramtype vlan: int
"""
super().__init__(**kwargs)
self.name = name
self.address_prefix = address_prefix
self.address_prefixes = address_prefixes
self.ip_allocation_method = ip_allocation_method
self.ip_configuration_references = ip_configuration_references
self.route_table = route_table
self.ip_pools = ip_pools
self.vlan = vlan
class VirtualnetworksPropertiesSubnetsPropertiesItemsItem(_serialization.Model):
"""Route is associated with a subnet.
:ivar name: Name - name of the subnet.
:vartype name: str
:ivar address_prefix: AddressPrefix - The destination CIDR to which the route applies.
:vartype address_prefix: str
:ivar next_hop_ip_address: NextHopIPAddress - The IP address packets should be forwarded to.
Next hop values are only allowed in routes where the next hop type is VirtualAppliance.
:vartype next_hop_ip_address: str
"""
_attribute_map = {
"name": {"key": "name", "type": "str"},
"address_prefix": {"key": "properties.addressPrefix", "type": "str"},
"next_hop_ip_address": {"key": "properties.nextHopIpAddress", "type": "str"},
}
def __init__(
self,
*,
name: Optional[str] = None,
address_prefix: Optional[str] = None,
next_hop_ip_address: Optional[str] = None,
**kwargs
):
"""
:keyword name: Name - name of the subnet.
:paramtype name: str
:keyword address_prefix: AddressPrefix - The destination CIDR to which the route applies.
:paramtype address_prefix: str
:keyword next_hop_ip_address: NextHopIPAddress - The IP address packets should be forwarded to.
Next hop values are only allowed in routes where the next hop type is VirtualAppliance.
:paramtype next_hop_ip_address: str
"""
super().__init__(**kwargs)
self.name = name
self.address_prefix = address_prefix
self.next_hop_ip_address = next_hop_ip_address
class VirtualNetworkStatus(_serialization.Model):
"""VirtualNetworkStatus defines the observed state of virtual networks.
:ivar error_code: VirtualNetwork provisioning error code.
:vartype error_code: str
:ivar error_message: Descriptive error message.
:vartype error_message: str
:ivar provisioning_status: The provisioning status of the virtual network.
:vartype provisioning_status:
~azure.mgmt.azurestackhci.models.VirtualNetworkStatusProvisioningStatus
"""
_attribute_map = {
"error_code": {"key": "errorCode", "type": "str"},
"error_message": {"key": "errorMessage", "type": "str"},
"provisioning_status": {"key": "provisioningStatus", "type": "VirtualNetworkStatusProvisioningStatus"},
}
def __init__(
self,
*,
error_code: Optional[str] = None,
error_message: Optional[str] = None,
provisioning_status: Optional["_models.VirtualNetworkStatusProvisioningStatus"] = None,
**kwargs
):
"""
:keyword error_code: VirtualNetwork provisioning error code.
:paramtype error_code: str
:keyword error_message: Descriptive error message.
:paramtype error_message: str
:keyword provisioning_status: The provisioning status of the virtual network.
:paramtype provisioning_status:
~azure.mgmt.azurestackhci.models.VirtualNetworkStatusProvisioningStatus
"""
super().__init__(**kwargs)
self.error_code = error_code
self.error_message = error_message
self.provisioning_status = provisioning_status
class VirtualNetworkStatusProvisioningStatus(_serialization.Model):
"""The provisioning status of the virtual network.
:ivar operation_id: The ID of the operation performed on the virtual network.
:vartype operation_id: str
:ivar status: The status of the operation performed on the virtual network [Succeeded, Failed,
InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:vartype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
_attribute_map = {
"operation_id": {"key": "operationId", "type": "str"},
"status": {"key": "status", "type": "str"},
}
def __init__(
self,
*,
operation_id: Optional[str] = None,
status: Optional[Union[str, "_models.ProvisioningStatusEnum"]] = None,
**kwargs
):
"""
:keyword operation_id: The ID of the operation performed on the virtual network.
:paramtype operation_id: str
:keyword status: The status of the operation performed on the virtual network [Succeeded,
Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress".
:paramtype status: str or ~azure.mgmt.azurestackhci.models.ProvisioningStatusEnum
"""
super().__init__(**kwargs)
self.operation_id = operation_id
self.status = status
| 0.594787 | 0.248751 |
from enum import Enum
from azure.core import CaseInsensitiveEnumMeta
class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs."""
INTERNAL = "Internal"
class ArcSettingAggregateState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Aggregate state of Arc agent across the nodes in this HCI cluster."""
NOT_SPECIFIED = "NotSpecified"
ERROR = "Error"
SUCCEEDED = "Succeeded"
CANCELED = "Canceled"
FAILED = "Failed"
CONNECTED = "Connected"
DISCONNECTED = "Disconnected"
DELETED = "Deleted"
CREATING = "Creating"
UPDATING = "Updating"
DELETING = "Deleting"
MOVING = "Moving"
PARTIALLY_SUCCEEDED = "PartiallySucceeded"
PARTIALLY_CONNECTED = "PartiallyConnected"
IN_PROGRESS = "InProgress"
class CloudInitDataSource(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Datasource for the gallery image when provisioning with cloud-init (Azure or NoCloud)."""
NO_CLOUD = "NoCloud"
AZURE = "Azure"
class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The type of identity that created the resource."""
USER = "User"
APPLICATION = "Application"
MANAGED_IDENTITY = "ManagedIdentity"
KEY = "Key"
class DiagnosticLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Desired level of diagnostic data emitted by the cluster."""
OFF = "Off"
BASIC = "Basic"
ENHANCED = "Enhanced"
class DiskFileFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The format of the actual VHD file [vhd, vhdx]."""
VHDX = "vhdx"
VHD = "vhd"
class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The type of extendedLocation."""
CUSTOM_LOCATION = "CustomLocation"
class ExtensionAggregateState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Aggregate state of Arc Extensions across the nodes in this HCI cluster."""
NOT_SPECIFIED = "NotSpecified"
ERROR = "Error"
SUCCEEDED = "Succeeded"
CANCELED = "Canceled"
FAILED = "Failed"
CONNECTED = "Connected"
DISCONNECTED = "Disconnected"
DELETED = "Deleted"
CREATING = "Creating"
UPDATING = "Updating"
DELETING = "Deleting"
MOVING = "Moving"
PARTIALLY_SUCCEEDED = "PartiallySucceeded"
PARTIALLY_CONNECTED = "PartiallyConnected"
IN_PROGRESS = "InProgress"
class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The hypervisor generation of the Virtual Machine [V1, V2]."""
V1 = "V1"
V2 = "V2"
class ImdsAttestation(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""IMDS attestation status of the cluster."""
DISABLED = "Disabled"
ENABLED = "Enabled"
class IpAllocationMethodEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""IPAllocationMethod - The IP address allocation method. Possible values include: 'Static',
'Dynamic'.
"""
DYNAMIC = "Dynamic"
STATIC = "Static"
class IPPoolTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""ip pool type."""
VM = "vm"
VIPPOOL = "vippool"
class NetworkTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of the network."""
NAT = "NAT"
TRANSPARENT = "Transparent"
L2_BRIDGE = "L2Bridge"
L2_TUNNEL = "L2Tunnel"
ICS = "ICS"
PRIVATE = "Private"
OVERLAY = "Overlay"
INTERNAL = "Internal"
MIRRORED = "Mirrored"
class NodeArcState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""State of Arc agent in this node."""
NOT_SPECIFIED = "NotSpecified"
ERROR = "Error"
SUCCEEDED = "Succeeded"
CANCELED = "Canceled"
FAILED = "Failed"
CONNECTED = "Connected"
DISCONNECTED = "Disconnected"
DELETED = "Deleted"
CREATING = "Creating"
UPDATING = "Updating"
DELETING = "Deleting"
MOVING = "Moving"
class NodeExtensionState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""State of Arc Extension in this node."""
NOT_SPECIFIED = "NotSpecified"
ERROR = "Error"
SUCCEEDED = "Succeeded"
CANCELED = "Canceled"
FAILED = "Failed"
CONNECTED = "Connected"
DISCONNECTED = "Disconnected"
DELETED = "Deleted"
CREATING = "Creating"
UPDATING = "Updating"
DELETING = "Deleting"
MOVING = "Moving"
class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""operating system type that the gallery image uses. Expected to be linux or windows."""
WINDOWS = "Windows"
LINUX = "Linux"
class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit
logs UX. Default value is "user,system".
"""
USER = "user"
SYSTEM = "system"
USER_SYSTEM = "user,system"
class OsTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""OsType - string specifying whether the OS is Linux or Windows."""
LINUX = "Linux"
WINDOWS = "Windows"
class PowerStateEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The power state of the virtual machine."""
DEALLOCATED = "Deallocated"
DEALLOCATING = "Deallocating"
RUNNING = "Running"
STARTING = "Starting"
STOPPED = "Stopped"
STOPPING = "Stopping"
UNKNOWN = "Unknown"
class PrivateIPAllocationMethodEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""PrivateIPAllocationMethod - The private IP address allocation method. Possible values include:
'Static', 'Dynamic'.
"""
DYNAMIC = "Dynamic"
STATIC = "Static"
class ProvisioningAction(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Defines the different types of operations for guest agent."""
INSTALL = "install"
UNINSTALL = "uninstall"
REPAIR = "repair"
class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Provisioning state of the ArcSetting proxy resource."""
SUCCEEDED = "Succeeded"
FAILED = "Failed"
CANCELED = "Canceled"
ACCEPTED = "Accepted"
PROVISIONING = "Provisioning"
class ProvisioningStateEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Provisioning state of the gallery image."""
SUCCEEDED = "Succeeded"
FAILED = "Failed"
IN_PROGRESS = "InProgress"
ACCEPTED = "Accepted"
DELETING = "Deleting"
CANCELED = "Canceled"
class ProvisioningStatusEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The status of the operation performed on the gallery image [Succeeded, Failed, InProgress]."""
SUCCEEDED = "Succeeded"
FAILED = "Failed"
IN_PROGRESS = "InProgress"
class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Status of the cluster agent."""
NOT_YET_REGISTERED = "NotYetRegistered"
CONNECTED_RECENTLY = "ConnectedRecently"
NOT_CONNECTED_RECENTLY = "NotConnectedRecently"
DISCONNECTED = "Disconnected"
ERROR = "Error"
class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The level code."""
INFO = "Info"
WARNING = "Warning"
ERROR = "Error"
class StatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The status of the hybrid machine agent."""
CONNECTED = "Connected"
DISCONNECTED = "Disconnected"
ERROR = "Error"
class VmSizeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""VmSizeEnum."""
DEFAULT = "Default"
STANDARD_A2_V2 = "Standard_A2_v2"
STANDARD_A4_V2 = "Standard_A4_v2"
STANDARD_D2_S_V3 = "Standard_D2s_v3"
STANDARD_D4_S_V3 = "Standard_D4s_v3"
STANDARD_D8_S_V3 = "Standard_D8s_v3"
STANDARD_D16_S_V3 = "Standard_D16s_v3"
STANDARD_D32_S_V3 = "Standard_D32s_v3"
STANDARD_DS2_V2 = "Standard_DS2_v2"
STANDARD_DS3_V2 = "Standard_DS3_v2"
STANDARD_DS4_V2 = "Standard_DS4_v2"
STANDARD_DS5_V2 = "Standard_DS5_v2"
STANDARD_DS13_V2 = "Standard_DS13_v2"
STANDARD_K8_S_V1 = "Standard_K8S_v1"
STANDARD_K8_S2_V1 = "Standard_K8S2_v1"
STANDARD_K8_S3_V1 = "Standard_K8S3_v1"
STANDARD_K8_S4_V1 = "Standard_K8S4_v1"
STANDARD_NK6 = "Standard_NK6"
STANDARD_NK12 = "Standard_NK12"
STANDARD_NV6 = "Standard_NV6"
STANDARD_NV12 = "Standard_NV12"
STANDARD_K8_S5_V1 = "Standard_K8S5_v1"
CUSTOM = "Custom"
class WindowsServerSubscription(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Desired state of Windows Server Subscription."""
DISABLED = "Disabled"
ENABLED = "Enabled"
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/models/_azure_stack_hci_client_enums.py
|
_azure_stack_hci_client_enums.py
|
from enum import Enum
from azure.core import CaseInsensitiveEnumMeta
class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs."""
INTERNAL = "Internal"
class ArcSettingAggregateState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Aggregate state of Arc agent across the nodes in this HCI cluster."""
NOT_SPECIFIED = "NotSpecified"
ERROR = "Error"
SUCCEEDED = "Succeeded"
CANCELED = "Canceled"
FAILED = "Failed"
CONNECTED = "Connected"
DISCONNECTED = "Disconnected"
DELETED = "Deleted"
CREATING = "Creating"
UPDATING = "Updating"
DELETING = "Deleting"
MOVING = "Moving"
PARTIALLY_SUCCEEDED = "PartiallySucceeded"
PARTIALLY_CONNECTED = "PartiallyConnected"
IN_PROGRESS = "InProgress"
class CloudInitDataSource(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Datasource for the gallery image when provisioning with cloud-init (Azure or NoCloud)."""
NO_CLOUD = "NoCloud"
AZURE = "Azure"
class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The type of identity that created the resource."""
USER = "User"
APPLICATION = "Application"
MANAGED_IDENTITY = "ManagedIdentity"
KEY = "Key"
class DiagnosticLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Desired level of diagnostic data emitted by the cluster."""
OFF = "Off"
BASIC = "Basic"
ENHANCED = "Enhanced"
class DiskFileFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The format of the actual VHD file [vhd, vhdx]."""
VHDX = "vhdx"
VHD = "vhd"
class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The type of extendedLocation."""
CUSTOM_LOCATION = "CustomLocation"
class ExtensionAggregateState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Aggregate state of Arc Extensions across the nodes in this HCI cluster."""
NOT_SPECIFIED = "NotSpecified"
ERROR = "Error"
SUCCEEDED = "Succeeded"
CANCELED = "Canceled"
FAILED = "Failed"
CONNECTED = "Connected"
DISCONNECTED = "Disconnected"
DELETED = "Deleted"
CREATING = "Creating"
UPDATING = "Updating"
DELETING = "Deleting"
MOVING = "Moving"
PARTIALLY_SUCCEEDED = "PartiallySucceeded"
PARTIALLY_CONNECTED = "PartiallyConnected"
IN_PROGRESS = "InProgress"
class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The hypervisor generation of the Virtual Machine [V1, V2]."""
V1 = "V1"
V2 = "V2"
class ImdsAttestation(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""IMDS attestation status of the cluster."""
DISABLED = "Disabled"
ENABLED = "Enabled"
class IpAllocationMethodEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""IPAllocationMethod - The IP address allocation method. Possible values include: 'Static',
'Dynamic'.
"""
DYNAMIC = "Dynamic"
STATIC = "Static"
class IPPoolTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""ip pool type."""
VM = "vm"
VIPPOOL = "vippool"
class NetworkTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of the network."""
NAT = "NAT"
TRANSPARENT = "Transparent"
L2_BRIDGE = "L2Bridge"
L2_TUNNEL = "L2Tunnel"
ICS = "ICS"
PRIVATE = "Private"
OVERLAY = "Overlay"
INTERNAL = "Internal"
MIRRORED = "Mirrored"
class NodeArcState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""State of Arc agent in this node."""
NOT_SPECIFIED = "NotSpecified"
ERROR = "Error"
SUCCEEDED = "Succeeded"
CANCELED = "Canceled"
FAILED = "Failed"
CONNECTED = "Connected"
DISCONNECTED = "Disconnected"
DELETED = "Deleted"
CREATING = "Creating"
UPDATING = "Updating"
DELETING = "Deleting"
MOVING = "Moving"
class NodeExtensionState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""State of Arc Extension in this node."""
NOT_SPECIFIED = "NotSpecified"
ERROR = "Error"
SUCCEEDED = "Succeeded"
CANCELED = "Canceled"
FAILED = "Failed"
CONNECTED = "Connected"
DISCONNECTED = "Disconnected"
DELETED = "Deleted"
CREATING = "Creating"
UPDATING = "Updating"
DELETING = "Deleting"
MOVING = "Moving"
class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""operating system type that the gallery image uses. Expected to be linux or windows."""
WINDOWS = "Windows"
LINUX = "Linux"
class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit
logs UX. Default value is "user,system".
"""
USER = "user"
SYSTEM = "system"
USER_SYSTEM = "user,system"
class OsTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""OsType - string specifying whether the OS is Linux or Windows."""
LINUX = "Linux"
WINDOWS = "Windows"
class PowerStateEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The power state of the virtual machine."""
DEALLOCATED = "Deallocated"
DEALLOCATING = "Deallocating"
RUNNING = "Running"
STARTING = "Starting"
STOPPED = "Stopped"
STOPPING = "Stopping"
UNKNOWN = "Unknown"
class PrivateIPAllocationMethodEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""PrivateIPAllocationMethod - The private IP address allocation method. Possible values include:
'Static', 'Dynamic'.
"""
DYNAMIC = "Dynamic"
STATIC = "Static"
class ProvisioningAction(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Defines the different types of operations for guest agent."""
INSTALL = "install"
UNINSTALL = "uninstall"
REPAIR = "repair"
class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Provisioning state of the ArcSetting proxy resource."""
SUCCEEDED = "Succeeded"
FAILED = "Failed"
CANCELED = "Canceled"
ACCEPTED = "Accepted"
PROVISIONING = "Provisioning"
class ProvisioningStateEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Provisioning state of the gallery image."""
SUCCEEDED = "Succeeded"
FAILED = "Failed"
IN_PROGRESS = "InProgress"
ACCEPTED = "Accepted"
DELETING = "Deleting"
CANCELED = "Canceled"
class ProvisioningStatusEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The status of the operation performed on the gallery image [Succeeded, Failed, InProgress]."""
SUCCEEDED = "Succeeded"
FAILED = "Failed"
IN_PROGRESS = "InProgress"
class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Status of the cluster agent."""
NOT_YET_REGISTERED = "NotYetRegistered"
CONNECTED_RECENTLY = "ConnectedRecently"
NOT_CONNECTED_RECENTLY = "NotConnectedRecently"
DISCONNECTED = "Disconnected"
ERROR = "Error"
class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The level code."""
INFO = "Info"
WARNING = "Warning"
ERROR = "Error"
class StatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The status of the hybrid machine agent."""
CONNECTED = "Connected"
DISCONNECTED = "Disconnected"
ERROR = "Error"
class VmSizeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""VmSizeEnum."""
DEFAULT = "Default"
STANDARD_A2_V2 = "Standard_A2_v2"
STANDARD_A4_V2 = "Standard_A4_v2"
STANDARD_D2_S_V3 = "Standard_D2s_v3"
STANDARD_D4_S_V3 = "Standard_D4s_v3"
STANDARD_D8_S_V3 = "Standard_D8s_v3"
STANDARD_D16_S_V3 = "Standard_D16s_v3"
STANDARD_D32_S_V3 = "Standard_D32s_v3"
STANDARD_DS2_V2 = "Standard_DS2_v2"
STANDARD_DS3_V2 = "Standard_DS3_v2"
STANDARD_DS4_V2 = "Standard_DS4_v2"
STANDARD_DS5_V2 = "Standard_DS5_v2"
STANDARD_DS13_V2 = "Standard_DS13_v2"
STANDARD_K8_S_V1 = "Standard_K8S_v1"
STANDARD_K8_S2_V1 = "Standard_K8S2_v1"
STANDARD_K8_S3_V1 = "Standard_K8S3_v1"
STANDARD_K8_S4_V1 = "Standard_K8S4_v1"
STANDARD_NK6 = "Standard_NK6"
STANDARD_NK12 = "Standard_NK12"
STANDARD_NV6 = "Standard_NV6"
STANDARD_NV12 = "Standard_NV12"
STANDARD_K8_S5_V1 = "Standard_K8S5_v1"
CUSTOM = "Custom"
class WindowsServerSubscription(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Desired state of Windows Server Subscription."""
DISABLED = "Disabled"
ENABLED = "Enabled"
| 0.862685 | 0.121295 |
from ._models_py3 import ArcSetting
from ._models_py3 import ArcSettingList
from ._models_py3 import Cluster
from ._models_py3 import ClusterDesiredProperties
from ._models_py3 import ClusterList
from ._models_py3 import ClusterNode
from ._models_py3 import ClusterPatch
from ._models_py3 import ClusterReportedProperties
from ._models_py3 import ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable
from ._models_py3 import (
ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems,
)
from ._models_py3 import ErrorAdditionalInfo
from ._models_py3 import ErrorDetail
from ._models_py3 import ErrorResponse
from ._models_py3 import ExtendedLocation
from ._models_py3 import Extension
from ._models_py3 import ExtensionList
from ._models_py3 import GalleryDiskImage
from ._models_py3 import GalleryImageIdentifier
from ._models_py3 import GalleryImageStatus
from ._models_py3 import GalleryImageStatusDownloadStatus
from ._models_py3 import GalleryImageStatusProvisioningStatus
from ._models_py3 import GalleryImageVersion
from ._models_py3 import GalleryImageVersionStorageProfile
from ._models_py3 import GalleryOSDiskImage
from ._models_py3 import Galleryimages
from ._models_py3 import GalleryimagesListResult
from ._models_py3 import GalleryimagesPatch
from ._models_py3 import GuestAgent
from ._models_py3 import GuestAgentList
from ._models_py3 import GuestAgentProfile
from ._models_py3 import GuestCredential
from ._models_py3 import HardwareProfileUpdate
from ._models_py3 import HttpProxyConfiguration
from ._models_py3 import HybridIdentityMetadata
from ._models_py3 import HybridIdentityMetadataList
from ._models_py3 import IPPool
from ._models_py3 import IPPoolInfo
from ._models_py3 import Identity
from ._models_py3 import InterfaceDNSSettings
from ._models_py3 import IpConfiguration
from ._models_py3 import IpConfigurationProperties
from ._models_py3 import IpConfigurationPropertiesSubnet
from ._models_py3 import MachineExtension
from ._models_py3 import MachineExtensionInstanceView
from ._models_py3 import MachineExtensionInstanceViewStatus
from ._models_py3 import MachineExtensionPropertiesInstanceView
from ._models_py3 import MachineExtensionUpdate
from ._models_py3 import MachineExtensionsListResult
from ._models_py3 import MarketplaceGalleryImageStatus
from ._models_py3 import MarketplaceGalleryImageStatusDownloadStatus
from ._models_py3 import MarketplaceGalleryImageStatusProvisioningStatus
from ._models_py3 import Marketplacegalleryimages
from ._models_py3 import MarketplacegalleryimagesListResult
from ._models_py3 import MarketplacegalleryimagesPatch
from ._models_py3 import NetworkInterfaceStatus
from ._models_py3 import NetworkInterfaceStatusProvisioningStatus
from ._models_py3 import NetworkProfileUpdate
from ._models_py3 import NetworkProfileUpdateNetworkInterfacesItem
from ._models_py3 import Networkinterfaces
from ._models_py3 import NetworkinterfacesListResult
from ._models_py3 import NetworkinterfacesPatch
from ._models_py3 import Operation
from ._models_py3 import OperationDisplay
from ._models_py3 import OperationListResult
from ._models_py3 import PerNodeExtensionState
from ._models_py3 import PerNodeState
from ._models_py3 import ProxyResource
from ._models_py3 import Resource
from ._models_py3 import ResourcePatch
from ._models_py3 import StorageContainerStatus
from ._models_py3 import StorageContainerStatusProvisioningStatus
from ._models_py3 import StorageProfileUpdate
from ._models_py3 import StorageProfileUpdateDataDisksItem
from ._models_py3 import Storagecontainers
from ._models_py3 import StoragecontainersExtendedLocation
from ._models_py3 import StoragecontainersListResult
from ._models_py3 import StoragecontainersPatch
from ._models_py3 import SystemData
from ._models_py3 import TrackedResource
from ._models_py3 import VirtualHardDiskStatus
from ._models_py3 import VirtualHardDiskStatusProvisioningStatus
from ._models_py3 import VirtualMachineStatus
from ._models_py3 import VirtualMachineStatusProvisioningStatus
from ._models_py3 import VirtualMachineUpdateProperties
from ._models_py3 import VirtualNetworkStatus
from ._models_py3 import VirtualNetworkStatusProvisioningStatus
from ._models_py3 import Virtualharddisks
from ._models_py3 import VirtualharddisksListResult
from ._models_py3 import VirtualharddisksPatch
from ._models_py3 import Virtualmachines
from ._models_py3 import VirtualmachinesListResult
from ._models_py3 import VirtualmachinesPatch
from ._models_py3 import VirtualmachinesPropertiesHardwareProfile
from ._models_py3 import VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig
from ._models_py3 import VirtualmachinesPropertiesNetworkProfile
from ._models_py3 import VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem
from ._models_py3 import VirtualmachinesPropertiesOsProfile
from ._models_py3 import VirtualmachinesPropertiesOsProfileLinuxConfiguration
from ._models_py3 import VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh
from ._models_py3 import VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem
from ._models_py3 import VirtualmachinesPropertiesOsProfileWindowsConfiguration
from ._models_py3 import VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh
from ._models_py3 import VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem
from ._models_py3 import VirtualmachinesPropertiesSecurityProfile
from ._models_py3 import VirtualmachinesPropertiesSecurityProfileUefiSettings
from ._models_py3 import VirtualmachinesPropertiesStorageProfile
from ._models_py3 import VirtualmachinesPropertiesStorageProfileDataDisksItem
from ._models_py3 import VirtualmachinesPropertiesStorageProfileImageReference
from ._models_py3 import VirtualmachinesPropertiesStorageProfileOsDisk
from ._models_py3 import Virtualnetworks
from ._models_py3 import VirtualnetworksListResult
from ._models_py3 import VirtualnetworksPatch
from ._models_py3 import VirtualnetworksPropertiesSubnetsItem
from ._models_py3 import VirtualnetworksPropertiesSubnetsPropertiesItemsItem
from ._azure_stack_hci_client_enums import ActionType
from ._azure_stack_hci_client_enums import ArcSettingAggregateState
from ._azure_stack_hci_client_enums import CloudInitDataSource
from ._azure_stack_hci_client_enums import CreatedByType
from ._azure_stack_hci_client_enums import DiagnosticLevel
from ._azure_stack_hci_client_enums import DiskFileFormat
from ._azure_stack_hci_client_enums import ExtendedLocationTypes
from ._azure_stack_hci_client_enums import ExtensionAggregateState
from ._azure_stack_hci_client_enums import HyperVGeneration
from ._azure_stack_hci_client_enums import IPPoolTypeEnum
from ._azure_stack_hci_client_enums import ImdsAttestation
from ._azure_stack_hci_client_enums import IpAllocationMethodEnum
from ._azure_stack_hci_client_enums import NetworkTypeEnum
from ._azure_stack_hci_client_enums import NodeArcState
from ._azure_stack_hci_client_enums import NodeExtensionState
from ._azure_stack_hci_client_enums import OperatingSystemTypes
from ._azure_stack_hci_client_enums import Origin
from ._azure_stack_hci_client_enums import OsTypeEnum
from ._azure_stack_hci_client_enums import PowerStateEnum
from ._azure_stack_hci_client_enums import PrivateIPAllocationMethodEnum
from ._azure_stack_hci_client_enums import ProvisioningAction
from ._azure_stack_hci_client_enums import ProvisioningState
from ._azure_stack_hci_client_enums import ProvisioningStateEnum
from ._azure_stack_hci_client_enums import ProvisioningStatusEnum
from ._azure_stack_hci_client_enums import Status
from ._azure_stack_hci_client_enums import StatusLevelTypes
from ._azure_stack_hci_client_enums import StatusTypes
from ._azure_stack_hci_client_enums import VmSizeEnum
from ._azure_stack_hci_client_enums import WindowsServerSubscription
from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
from ._patch import patch_sdk as _patch_sdk
__all__ = [
"ArcSetting",
"ArcSettingList",
"Cluster",
"ClusterDesiredProperties",
"ClusterList",
"ClusterNode",
"ClusterPatch",
"ClusterReportedProperties",
"ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable",
"ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems",
"ErrorAdditionalInfo",
"ErrorDetail",
"ErrorResponse",
"ExtendedLocation",
"Extension",
"ExtensionList",
"GalleryDiskImage",
"GalleryImageIdentifier",
"GalleryImageStatus",
"GalleryImageStatusDownloadStatus",
"GalleryImageStatusProvisioningStatus",
"GalleryImageVersion",
"GalleryImageVersionStorageProfile",
"GalleryOSDiskImage",
"Galleryimages",
"GalleryimagesListResult",
"GalleryimagesPatch",
"GuestAgent",
"GuestAgentList",
"GuestAgentProfile",
"GuestCredential",
"HardwareProfileUpdate",
"HttpProxyConfiguration",
"HybridIdentityMetadata",
"HybridIdentityMetadataList",
"IPPool",
"IPPoolInfo",
"Identity",
"InterfaceDNSSettings",
"IpConfiguration",
"IpConfigurationProperties",
"IpConfigurationPropertiesSubnet",
"MachineExtension",
"MachineExtensionInstanceView",
"MachineExtensionInstanceViewStatus",
"MachineExtensionPropertiesInstanceView",
"MachineExtensionUpdate",
"MachineExtensionsListResult",
"MarketplaceGalleryImageStatus",
"MarketplaceGalleryImageStatusDownloadStatus",
"MarketplaceGalleryImageStatusProvisioningStatus",
"Marketplacegalleryimages",
"MarketplacegalleryimagesListResult",
"MarketplacegalleryimagesPatch",
"NetworkInterfaceStatus",
"NetworkInterfaceStatusProvisioningStatus",
"NetworkProfileUpdate",
"NetworkProfileUpdateNetworkInterfacesItem",
"Networkinterfaces",
"NetworkinterfacesListResult",
"NetworkinterfacesPatch",
"Operation",
"OperationDisplay",
"OperationListResult",
"PerNodeExtensionState",
"PerNodeState",
"ProxyResource",
"Resource",
"ResourcePatch",
"StorageContainerStatus",
"StorageContainerStatusProvisioningStatus",
"StorageProfileUpdate",
"StorageProfileUpdateDataDisksItem",
"Storagecontainers",
"StoragecontainersExtendedLocation",
"StoragecontainersListResult",
"StoragecontainersPatch",
"SystemData",
"TrackedResource",
"VirtualHardDiskStatus",
"VirtualHardDiskStatusProvisioningStatus",
"VirtualMachineStatus",
"VirtualMachineStatusProvisioningStatus",
"VirtualMachineUpdateProperties",
"VirtualNetworkStatus",
"VirtualNetworkStatusProvisioningStatus",
"Virtualharddisks",
"VirtualharddisksListResult",
"VirtualharddisksPatch",
"Virtualmachines",
"VirtualmachinesListResult",
"VirtualmachinesPatch",
"VirtualmachinesPropertiesHardwareProfile",
"VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig",
"VirtualmachinesPropertiesNetworkProfile",
"VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem",
"VirtualmachinesPropertiesOsProfile",
"VirtualmachinesPropertiesOsProfileLinuxConfiguration",
"VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh",
"VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem",
"VirtualmachinesPropertiesOsProfileWindowsConfiguration",
"VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh",
"VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem",
"VirtualmachinesPropertiesSecurityProfile",
"VirtualmachinesPropertiesSecurityProfileUefiSettings",
"VirtualmachinesPropertiesStorageProfile",
"VirtualmachinesPropertiesStorageProfileDataDisksItem",
"VirtualmachinesPropertiesStorageProfileImageReference",
"VirtualmachinesPropertiesStorageProfileOsDisk",
"Virtualnetworks",
"VirtualnetworksListResult",
"VirtualnetworksPatch",
"VirtualnetworksPropertiesSubnetsItem",
"VirtualnetworksPropertiesSubnetsPropertiesItemsItem",
"ActionType",
"ArcSettingAggregateState",
"CloudInitDataSource",
"CreatedByType",
"DiagnosticLevel",
"DiskFileFormat",
"ExtendedLocationTypes",
"ExtensionAggregateState",
"HyperVGeneration",
"IPPoolTypeEnum",
"ImdsAttestation",
"IpAllocationMethodEnum",
"NetworkTypeEnum",
"NodeArcState",
"NodeExtensionState",
"OperatingSystemTypes",
"Origin",
"OsTypeEnum",
"PowerStateEnum",
"PrivateIPAllocationMethodEnum",
"ProvisioningAction",
"ProvisioningState",
"ProvisioningStateEnum",
"ProvisioningStatusEnum",
"Status",
"StatusLevelTypes",
"StatusTypes",
"VmSizeEnum",
"WindowsServerSubscription",
]
__all__.extend([p for p in _patch_all if p not in __all__])
_patch_sdk()
|
azure-mgmt-azurestackhci
|
/azure_mgmt_azurestackhci-8.0.0b2-py3-none-any.whl/azure/mgmt/azurestackhci/models/__init__.py
|
__init__.py
|
from ._models_py3 import ArcSetting
from ._models_py3 import ArcSettingList
from ._models_py3 import Cluster
from ._models_py3 import ClusterDesiredProperties
from ._models_py3 import ClusterList
from ._models_py3 import ClusterNode
from ._models_py3 import ClusterPatch
from ._models_py3 import ClusterReportedProperties
from ._models_py3 import ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable
from ._models_py3 import (
ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems,
)
from ._models_py3 import ErrorAdditionalInfo
from ._models_py3 import ErrorDetail
from ._models_py3 import ErrorResponse
from ._models_py3 import ExtendedLocation
from ._models_py3 import Extension
from ._models_py3 import ExtensionList
from ._models_py3 import GalleryDiskImage
from ._models_py3 import GalleryImageIdentifier
from ._models_py3 import GalleryImageStatus
from ._models_py3 import GalleryImageStatusDownloadStatus
from ._models_py3 import GalleryImageStatusProvisioningStatus
from ._models_py3 import GalleryImageVersion
from ._models_py3 import GalleryImageVersionStorageProfile
from ._models_py3 import GalleryOSDiskImage
from ._models_py3 import Galleryimages
from ._models_py3 import GalleryimagesListResult
from ._models_py3 import GalleryimagesPatch
from ._models_py3 import GuestAgent
from ._models_py3 import GuestAgentList
from ._models_py3 import GuestAgentProfile
from ._models_py3 import GuestCredential
from ._models_py3 import HardwareProfileUpdate
from ._models_py3 import HttpProxyConfiguration
from ._models_py3 import HybridIdentityMetadata
from ._models_py3 import HybridIdentityMetadataList
from ._models_py3 import IPPool
from ._models_py3 import IPPoolInfo
from ._models_py3 import Identity
from ._models_py3 import InterfaceDNSSettings
from ._models_py3 import IpConfiguration
from ._models_py3 import IpConfigurationProperties
from ._models_py3 import IpConfigurationPropertiesSubnet
from ._models_py3 import MachineExtension
from ._models_py3 import MachineExtensionInstanceView
from ._models_py3 import MachineExtensionInstanceViewStatus
from ._models_py3 import MachineExtensionPropertiesInstanceView
from ._models_py3 import MachineExtensionUpdate
from ._models_py3 import MachineExtensionsListResult
from ._models_py3 import MarketplaceGalleryImageStatus
from ._models_py3 import MarketplaceGalleryImageStatusDownloadStatus
from ._models_py3 import MarketplaceGalleryImageStatusProvisioningStatus
from ._models_py3 import Marketplacegalleryimages
from ._models_py3 import MarketplacegalleryimagesListResult
from ._models_py3 import MarketplacegalleryimagesPatch
from ._models_py3 import NetworkInterfaceStatus
from ._models_py3 import NetworkInterfaceStatusProvisioningStatus
from ._models_py3 import NetworkProfileUpdate
from ._models_py3 import NetworkProfileUpdateNetworkInterfacesItem
from ._models_py3 import Networkinterfaces
from ._models_py3 import NetworkinterfacesListResult
from ._models_py3 import NetworkinterfacesPatch
from ._models_py3 import Operation
from ._models_py3 import OperationDisplay
from ._models_py3 import OperationListResult
from ._models_py3 import PerNodeExtensionState
from ._models_py3 import PerNodeState
from ._models_py3 import ProxyResource
from ._models_py3 import Resource
from ._models_py3 import ResourcePatch
from ._models_py3 import StorageContainerStatus
from ._models_py3 import StorageContainerStatusProvisioningStatus
from ._models_py3 import StorageProfileUpdate
from ._models_py3 import StorageProfileUpdateDataDisksItem
from ._models_py3 import Storagecontainers
from ._models_py3 import StoragecontainersExtendedLocation
from ._models_py3 import StoragecontainersListResult
from ._models_py3 import StoragecontainersPatch
from ._models_py3 import SystemData
from ._models_py3 import TrackedResource
from ._models_py3 import VirtualHardDiskStatus
from ._models_py3 import VirtualHardDiskStatusProvisioningStatus
from ._models_py3 import VirtualMachineStatus
from ._models_py3 import VirtualMachineStatusProvisioningStatus
from ._models_py3 import VirtualMachineUpdateProperties
from ._models_py3 import VirtualNetworkStatus
from ._models_py3 import VirtualNetworkStatusProvisioningStatus
from ._models_py3 import Virtualharddisks
from ._models_py3 import VirtualharddisksListResult
from ._models_py3 import VirtualharddisksPatch
from ._models_py3 import Virtualmachines
from ._models_py3 import VirtualmachinesListResult
from ._models_py3 import VirtualmachinesPatch
from ._models_py3 import VirtualmachinesPropertiesHardwareProfile
from ._models_py3 import VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig
from ._models_py3 import VirtualmachinesPropertiesNetworkProfile
from ._models_py3 import VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem
from ._models_py3 import VirtualmachinesPropertiesOsProfile
from ._models_py3 import VirtualmachinesPropertiesOsProfileLinuxConfiguration
from ._models_py3 import VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh
from ._models_py3 import VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem
from ._models_py3 import VirtualmachinesPropertiesOsProfileWindowsConfiguration
from ._models_py3 import VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh
from ._models_py3 import VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem
from ._models_py3 import VirtualmachinesPropertiesSecurityProfile
from ._models_py3 import VirtualmachinesPropertiesSecurityProfileUefiSettings
from ._models_py3 import VirtualmachinesPropertiesStorageProfile
from ._models_py3 import VirtualmachinesPropertiesStorageProfileDataDisksItem
from ._models_py3 import VirtualmachinesPropertiesStorageProfileImageReference
from ._models_py3 import VirtualmachinesPropertiesStorageProfileOsDisk
from ._models_py3 import Virtualnetworks
from ._models_py3 import VirtualnetworksListResult
from ._models_py3 import VirtualnetworksPatch
from ._models_py3 import VirtualnetworksPropertiesSubnetsItem
from ._models_py3 import VirtualnetworksPropertiesSubnetsPropertiesItemsItem
from ._azure_stack_hci_client_enums import ActionType
from ._azure_stack_hci_client_enums import ArcSettingAggregateState
from ._azure_stack_hci_client_enums import CloudInitDataSource
from ._azure_stack_hci_client_enums import CreatedByType
from ._azure_stack_hci_client_enums import DiagnosticLevel
from ._azure_stack_hci_client_enums import DiskFileFormat
from ._azure_stack_hci_client_enums import ExtendedLocationTypes
from ._azure_stack_hci_client_enums import ExtensionAggregateState
from ._azure_stack_hci_client_enums import HyperVGeneration
from ._azure_stack_hci_client_enums import IPPoolTypeEnum
from ._azure_stack_hci_client_enums import ImdsAttestation
from ._azure_stack_hci_client_enums import IpAllocationMethodEnum
from ._azure_stack_hci_client_enums import NetworkTypeEnum
from ._azure_stack_hci_client_enums import NodeArcState
from ._azure_stack_hci_client_enums import NodeExtensionState
from ._azure_stack_hci_client_enums import OperatingSystemTypes
from ._azure_stack_hci_client_enums import Origin
from ._azure_stack_hci_client_enums import OsTypeEnum
from ._azure_stack_hci_client_enums import PowerStateEnum
from ._azure_stack_hci_client_enums import PrivateIPAllocationMethodEnum
from ._azure_stack_hci_client_enums import ProvisioningAction
from ._azure_stack_hci_client_enums import ProvisioningState
from ._azure_stack_hci_client_enums import ProvisioningStateEnum
from ._azure_stack_hci_client_enums import ProvisioningStatusEnum
from ._azure_stack_hci_client_enums import Status
from ._azure_stack_hci_client_enums import StatusLevelTypes
from ._azure_stack_hci_client_enums import StatusTypes
from ._azure_stack_hci_client_enums import VmSizeEnum
from ._azure_stack_hci_client_enums import WindowsServerSubscription
from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
from ._patch import patch_sdk as _patch_sdk
__all__ = [
"ArcSetting",
"ArcSettingList",
"Cluster",
"ClusterDesiredProperties",
"ClusterList",
"ClusterNode",
"ClusterPatch",
"ClusterReportedProperties",
"ComponentsL15GkaSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesRoutetable",
"ComponentsVqks9HSchemasVirtualnetworkspropertiesPropertiesSubnetsItemsPropertiesIpconfigurationreferencesItems",
"ErrorAdditionalInfo",
"ErrorDetail",
"ErrorResponse",
"ExtendedLocation",
"Extension",
"ExtensionList",
"GalleryDiskImage",
"GalleryImageIdentifier",
"GalleryImageStatus",
"GalleryImageStatusDownloadStatus",
"GalleryImageStatusProvisioningStatus",
"GalleryImageVersion",
"GalleryImageVersionStorageProfile",
"GalleryOSDiskImage",
"Galleryimages",
"GalleryimagesListResult",
"GalleryimagesPatch",
"GuestAgent",
"GuestAgentList",
"GuestAgentProfile",
"GuestCredential",
"HardwareProfileUpdate",
"HttpProxyConfiguration",
"HybridIdentityMetadata",
"HybridIdentityMetadataList",
"IPPool",
"IPPoolInfo",
"Identity",
"InterfaceDNSSettings",
"IpConfiguration",
"IpConfigurationProperties",
"IpConfigurationPropertiesSubnet",
"MachineExtension",
"MachineExtensionInstanceView",
"MachineExtensionInstanceViewStatus",
"MachineExtensionPropertiesInstanceView",
"MachineExtensionUpdate",
"MachineExtensionsListResult",
"MarketplaceGalleryImageStatus",
"MarketplaceGalleryImageStatusDownloadStatus",
"MarketplaceGalleryImageStatusProvisioningStatus",
"Marketplacegalleryimages",
"MarketplacegalleryimagesListResult",
"MarketplacegalleryimagesPatch",
"NetworkInterfaceStatus",
"NetworkInterfaceStatusProvisioningStatus",
"NetworkProfileUpdate",
"NetworkProfileUpdateNetworkInterfacesItem",
"Networkinterfaces",
"NetworkinterfacesListResult",
"NetworkinterfacesPatch",
"Operation",
"OperationDisplay",
"OperationListResult",
"PerNodeExtensionState",
"PerNodeState",
"ProxyResource",
"Resource",
"ResourcePatch",
"StorageContainerStatus",
"StorageContainerStatusProvisioningStatus",
"StorageProfileUpdate",
"StorageProfileUpdateDataDisksItem",
"Storagecontainers",
"StoragecontainersExtendedLocation",
"StoragecontainersListResult",
"StoragecontainersPatch",
"SystemData",
"TrackedResource",
"VirtualHardDiskStatus",
"VirtualHardDiskStatusProvisioningStatus",
"VirtualMachineStatus",
"VirtualMachineStatusProvisioningStatus",
"VirtualMachineUpdateProperties",
"VirtualNetworkStatus",
"VirtualNetworkStatusProvisioningStatus",
"Virtualharddisks",
"VirtualharddisksListResult",
"VirtualharddisksPatch",
"Virtualmachines",
"VirtualmachinesListResult",
"VirtualmachinesPatch",
"VirtualmachinesPropertiesHardwareProfile",
"VirtualmachinesPropertiesHardwareProfileDynamicMemoryConfig",
"VirtualmachinesPropertiesNetworkProfile",
"VirtualmachinesPropertiesNetworkProfileNetworkInterfacesItem",
"VirtualmachinesPropertiesOsProfile",
"VirtualmachinesPropertiesOsProfileLinuxConfiguration",
"VirtualmachinesPropertiesOsProfileLinuxConfigurationSsh",
"VirtualmachinesPropertiesOsProfileLinuxConfigurationSshPublicKeysItem",
"VirtualmachinesPropertiesOsProfileWindowsConfiguration",
"VirtualmachinesPropertiesOsProfileWindowsConfigurationSsh",
"VirtualmachinesPropertiesOsProfileWindowsConfigurationSshPublicKeysItem",
"VirtualmachinesPropertiesSecurityProfile",
"VirtualmachinesPropertiesSecurityProfileUefiSettings",
"VirtualmachinesPropertiesStorageProfile",
"VirtualmachinesPropertiesStorageProfileDataDisksItem",
"VirtualmachinesPropertiesStorageProfileImageReference",
"VirtualmachinesPropertiesStorageProfileOsDisk",
"Virtualnetworks",
"VirtualnetworksListResult",
"VirtualnetworksPatch",
"VirtualnetworksPropertiesSubnetsItem",
"VirtualnetworksPropertiesSubnetsPropertiesItemsItem",
"ActionType",
"ArcSettingAggregateState",
"CloudInitDataSource",
"CreatedByType",
"DiagnosticLevel",
"DiskFileFormat",
"ExtendedLocationTypes",
"ExtensionAggregateState",
"HyperVGeneration",
"IPPoolTypeEnum",
"ImdsAttestation",
"IpAllocationMethodEnum",
"NetworkTypeEnum",
"NodeArcState",
"NodeExtensionState",
"OperatingSystemTypes",
"Origin",
"OsTypeEnum",
"PowerStateEnum",
"PrivateIPAllocationMethodEnum",
"ProvisioningAction",
"ProvisioningState",
"ProvisioningStateEnum",
"ProvisioningStatusEnum",
"Status",
"StatusLevelTypes",
"StatusTypes",
"VmSizeEnum",
"WindowsServerSubscription",
]
__all__.extend([p for p in _patch_all if p not in __all__])
_patch_sdk()
| 0.501953 | 0.043916 |
from copy import deepcopy
from typing import Any, TYPE_CHECKING
from azure.core.rest import HttpRequest, HttpResponse
from azure.mgmt.core import ARMPipelineClient
from . import models
from ._configuration import BareMetalInfrastructureClientConfiguration
from ._serialization import Deserializer, Serializer
from .operations import AzureBareMetalInstancesOperations, Operations
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class BareMetalInfrastructureClient: # pylint: disable=client-accepts-api-version-keyword
"""The BareMetalInfrastructure Management client.
:ivar azure_bare_metal_instances: AzureBareMetalInstancesOperations operations
:vartype azure_bare_metal_instances:
azure.mgmt.baremetalinfrastructure.operations.AzureBareMetalInstancesOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.baremetalinfrastructure.operations.Operations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2021-08-09". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = BareMetalInfrastructureClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.azure_bare_metal_instances = AzureBareMetalInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.HttpResponse
"""
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
self._client.close()
def __enter__(self):
# type: () -> BareMetalInfrastructureClient
self._client.__enter__()
return self
def __exit__(self, *exc_details):
# type: (Any) -> None
self._client.__exit__(*exc_details)
|
azure-mgmt-baremetalinfrastructure
|
/azure_mgmt_baremetalinfrastructure-1.1.0b1-py3-none-any.whl/azure/mgmt/baremetalinfrastructure/_bare_metal_infrastructure_client.py
|
_bare_metal_infrastructure_client.py
|
from copy import deepcopy
from typing import Any, TYPE_CHECKING
from azure.core.rest import HttpRequest, HttpResponse
from azure.mgmt.core import ARMPipelineClient
from . import models
from ._configuration import BareMetalInfrastructureClientConfiguration
from ._serialization import Deserializer, Serializer
from .operations import AzureBareMetalInstancesOperations, Operations
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class BareMetalInfrastructureClient: # pylint: disable=client-accepts-api-version-keyword
"""The BareMetalInfrastructure Management client.
:ivar azure_bare_metal_instances: AzureBareMetalInstancesOperations operations
:vartype azure_bare_metal_instances:
azure.mgmt.baremetalinfrastructure.operations.AzureBareMetalInstancesOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.baremetalinfrastructure.operations.Operations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2021-08-09". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = BareMetalInfrastructureClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.azure_bare_metal_instances = AzureBareMetalInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.HttpResponse
"""
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
self._client.close()
def __enter__(self):
# type: () -> BareMetalInfrastructureClient
self._client.__enter__()
return self
def __exit__(self, *exc_details):
# type: (Any) -> None
self._client.__exit__(*exc_details)
| 0.835215 | 0.109468 |
import sys
from typing import Any, TYPE_CHECKING
from azure.core.configuration import Configuration
from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
from ._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class BareMetalInfrastructureClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for BareMetalInfrastructureClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2021-08-09". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(BareMetalInfrastructureClientConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop("api_version", "2021-08-09") # type: Literal["2021-08-09"]
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-baremetalinfrastructure/{}".format(VERSION))
self._configure(**kwargs)
def _configure(
self, **kwargs # type: Any
):
# type: (...) -> None
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = ARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
|
azure-mgmt-baremetalinfrastructure
|
/azure_mgmt_baremetalinfrastructure-1.1.0b1-py3-none-any.whl/azure/mgmt/baremetalinfrastructure/_configuration.py
|
_configuration.py
|
import sys
from typing import Any, TYPE_CHECKING
from azure.core.configuration import Configuration
from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
from ._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential
class BareMetalInfrastructureClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for BareMetalInfrastructureClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2021-08-09". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(BareMetalInfrastructureClientConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop("api_version", "2021-08-09") # type: Literal["2021-08-09"]
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-baremetalinfrastructure/{}".format(VERSION))
self._configure(**kwargs)
def _configure(
self, **kwargs # type: Any
):
# type: (...) -> None
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = ARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
| 0.532182 | 0.080828 |
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-09")) # type: Literal["2021-08-09"]
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances"
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url = _format_url_section(_url, **path_format_arguments)
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-09")) # type: Literal["2021-08-09"]
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url = _format_url_section(_url, **path_format_arguments)
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, azure_bare_metal_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-09")) # type: Literal["2021-08-09"]
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"azureBareMetalInstanceName": _SERIALIZER.url(
"azure_bare_metal_instance_name", azure_bare_metal_instance_name, "str"
),
}
_url = _format_url_section(_url, **path_format_arguments)
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, azure_bare_metal_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-09")) # type: Literal["2021-08-09"]
content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str]
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"azureBareMetalInstanceName": _SERIALIZER.url(
"azure_bare_metal_instance_name", azure_bare_metal_instance_name, "str"
),
}
_url = _format_url_section(_url, **path_format_arguments)
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
class AzureBareMetalInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.baremetalinfrastructure.BareMetalInfrastructureClient`'s
:attr:`azure_bare_metal_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AzureBareMetalInstance"]:
"""Gets a list of Azure BareMetal instances in the specified subscription.
Gets a list of AzureBareMetal instances in the specified subscription. The operations returns
various properties of each Azure BareMetal instance.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either AzureBareMetalInstance or the result of
cls(response)
:rtype:
~azure.core.paging.ItemPaged[~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstancesListResult]
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
request.method = "GET"
return request
def extract_data(pipeline_response):
deserialized = self._deserialize("AzureBareMetalInstancesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances"} # type: ignore
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> Iterable["_models.AzureBareMetalInstance"]:
"""Gets a list of Azure BareMetal instances in the specified subscription and resource group.
Gets a list of AzureBareMetal instances in the specified subscription and resource group. The
operations returns various properties of each Azure BareMetal instance.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either AzureBareMetalInstance or the result of
cls(response)
:rtype:
~azure.core.paging.ItemPaged[~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstancesListResult]
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
request.method = "GET"
return request
def extract_data(pipeline_response):
deserialized = self._deserialize("AzureBareMetalInstancesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances"} # type: ignore
@distributed_trace
def get(
self, resource_group_name: str, azure_bare_metal_instance_name: str, **kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Gets an Azure BareMetal instance.
Gets an Azure BareMetal instance for the specified subscription, resource group, and instance
name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstance]
request = build_get_request(
resource_group_name=resource_group_name,
azure_bare_metal_instance_name=azure_bare_metal_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("AzureBareMetalInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}"} # type: ignore
@overload
def update(
self,
resource_group_name: str,
azure_bare_metal_instance_name: str,
tags_parameter: _models.Tags,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Patches the Tags field of a Azure BareMetal instance.
Patches the Tags field of a Azure BareMetal instance for the specified subscription, resource
group, and instance name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:param tags_parameter: Request body that only contains the new Tags field. Required.
:type tags_parameter: ~azure.mgmt.baremetalinfrastructure.models.Tags
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
azure_bare_metal_instance_name: str,
tags_parameter: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Patches the Tags field of a Azure BareMetal instance.
Patches the Tags field of a Azure BareMetal instance for the specified subscription, resource
group, and instance name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:param tags_parameter: Request body that only contains the new Tags field. Required.
:type tags_parameter: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
azure_bare_metal_instance_name: str,
tags_parameter: Union[_models.Tags, IO],
**kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Patches the Tags field of a Azure BareMetal instance.
Patches the Tags field of a Azure BareMetal instance for the specified subscription, resource
group, and instance name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:param tags_parameter: Request body that only contains the new Tags field. Is either a model
type or a IO type. Required.
:type tags_parameter: ~azure.mgmt.baremetalinfrastructure.models.Tags or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstance]
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(tags_parameter, (IO, bytes)):
_content = tags_parameter
else:
_json = self._serialize.body(tags_parameter, "Tags")
request = build_update_request(
resource_group_name=resource_group_name,
azure_bare_metal_instance_name=azure_bare_metal_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("AzureBareMetalInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}"} # type: ignore
|
azure-mgmt-baremetalinfrastructure
|
/azure_mgmt_baremetalinfrastructure-1.1.0b1-py3-none-any.whl/azure/mgmt/baremetalinfrastructure/operations/_azure_bare_metal_instances_operations.py
|
_azure_bare_metal_instances_operations.py
|
import sys
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request, _format_url_section
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-09")) # type: Literal["2021-08-09"]
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances"
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
}
_url = _format_url_section(_url, **path_format_arguments)
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-09")) # type: Literal["2021-08-09"]
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
}
_url = _format_url_section(_url, **path_format_arguments)
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_get_request(
resource_group_name: str, azure_bare_metal_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-09")) # type: Literal["2021-08-09"]
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"azureBareMetalInstanceName": _SERIALIZER.url(
"azure_bare_metal_instance_name", azure_bare_metal_instance_name, "str"
),
}
_url = _format_url_section(_url, **path_format_arguments)
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
def build_update_request(
resource_group_name: str, azure_bare_metal_instance_name: str, subscription_id: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-09")) # type: Literal["2021-08-09"]
content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str]
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop(
"template_url",
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}",
) # pylint: disable=line-too-long
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1),
"resourceGroupName": _SERIALIZER.url(
"resource_group_name", resource_group_name, "str", max_length=90, min_length=1
),
"azureBareMetalInstanceName": _SERIALIZER.url(
"azure_bare_metal_instance_name", azure_bare_metal_instance_name, "str"
),
}
_url = _format_url_section(_url, **path_format_arguments)
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
class AzureBareMetalInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.baremetalinfrastructure.BareMetalInfrastructureClient`'s
:attr:`azure_bare_metal_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AzureBareMetalInstance"]:
"""Gets a list of Azure BareMetal instances in the specified subscription.
Gets a list of AzureBareMetal instances in the specified subscription. The operations returns
various properties of each Azure BareMetal instance.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either AzureBareMetalInstance or the result of
cls(response)
:rtype:
~azure.core.paging.ItemPaged[~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstancesListResult]
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
request.method = "GET"
return request
def extract_data(pipeline_response):
deserialized = self._deserialize("AzureBareMetalInstancesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances"} # type: ignore
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> Iterable["_models.AzureBareMetalInstance"]:
"""Gets a list of Azure BareMetal instances in the specified subscription and resource group.
Gets a list of AzureBareMetal instances in the specified subscription and resource group. The
operations returns various properties of each Azure BareMetal instance.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either AzureBareMetalInstance or the result of
cls(response)
:rtype:
~azure.core.paging.ItemPaged[~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstancesListResult]
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
request.method = "GET"
return request
def extract_data(pipeline_response):
deserialized = self._deserialize("AzureBareMetalInstancesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link or None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances"} # type: ignore
@distributed_trace
def get(
self, resource_group_name: str, azure_bare_metal_instance_name: str, **kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Gets an Azure BareMetal instance.
Gets an Azure BareMetal instance for the specified subscription, resource group, and instance
name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstance]
request = build_get_request(
resource_group_name=resource_group_name,
azure_bare_metal_instance_name=azure_bare_metal_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("AzureBareMetalInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}"} # type: ignore
@overload
def update(
self,
resource_group_name: str,
azure_bare_metal_instance_name: str,
tags_parameter: _models.Tags,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Patches the Tags field of a Azure BareMetal instance.
Patches the Tags field of a Azure BareMetal instance for the specified subscription, resource
group, and instance name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:param tags_parameter: Request body that only contains the new Tags field. Required.
:type tags_parameter: ~azure.mgmt.baremetalinfrastructure.models.Tags
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
def update(
self,
resource_group_name: str,
azure_bare_metal_instance_name: str,
tags_parameter: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Patches the Tags field of a Azure BareMetal instance.
Patches the Tags field of a Azure BareMetal instance for the specified subscription, resource
group, and instance name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:param tags_parameter: Request body that only contains the new Tags field. Required.
:type tags_parameter: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace
def update(
self,
resource_group_name: str,
azure_bare_metal_instance_name: str,
tags_parameter: Union[_models.Tags, IO],
**kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Patches the Tags field of a Azure BareMetal instance.
Patches the Tags field of a Azure BareMetal instance for the specified subscription, resource
group, and instance name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:param tags_parameter: Request body that only contains the new Tags field. Is either a model
type or a IO type. Required.
:type tags_parameter: ~azure.mgmt.baremetalinfrastructure.models.Tags or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstance]
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(tags_parameter, (IO, bytes)):
_content = tags_parameter
else:
_json = self._serialize.body(tags_parameter, "Tags")
request = build_update_request(
resource_group_name=resource_group_name,
azure_bare_metal_instance_name=azure_bare_metal_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("AzureBareMetalInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}"} # type: ignore
| 0.522446 | 0.078325 |
import sys
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-09")) # type: Literal["2021-08-09"]
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/providers/Microsoft.BareMetalInfrastructure/operations")
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.baremetalinfrastructure.BareMetalInfrastructureClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> Iterable["_models.Operation"]:
"""Gets a list of AzureBareMetal management operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Operation or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.baremetalinfrastructure.models.Operation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationList]
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
request.method = "GET"
return request
def extract_data(pipeline_response):
deserialized = self._deserialize("OperationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {"url": "/providers/Microsoft.BareMetalInfrastructure/operations"} # type: ignore
|
azure-mgmt-baremetalinfrastructure
|
/azure_mgmt_baremetalinfrastructure-1.1.0b1-py3-none-any.whl/azure/mgmt/baremetalinfrastructure/operations/_operations.py
|
_operations.py
|
import sys
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar
import urllib.parse
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import HttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from .. import models as _models
from .._serialization import Serializer
from .._vendor import _convert_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
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:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-09")) # type: Literal["2021-08-09"]
accept = _headers.pop("Accept", "application/json")
# Construct URL
_url = kwargs.pop("template_url", "/providers/Microsoft.BareMetalInfrastructure/operations")
# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
# Construct headers
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.baremetalinfrastructure.BareMetalInfrastructureClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> Iterable["_models.Operation"]:
"""Gets a list of AzureBareMetal management operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Operation or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.baremetalinfrastructure.models.Operation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationList]
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
request.method = "GET"
return request
def extract_data(pipeline_response):
deserialized = self._deserialize("OperationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, iter(list_of_elem)
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return ItemPaged(get_next, extract_data)
list.metadata = {"url": "/providers/Microsoft.BareMetalInfrastructure/operations"} # type: ignore
| 0.619126 | 0.081923 |
from copy import deepcopy
from typing import Any, Awaitable, TYPE_CHECKING
from azure.core.rest import AsyncHttpResponse, HttpRequest
from azure.mgmt.core import AsyncARMPipelineClient
from .. import models
from .._serialization import Deserializer, Serializer
from ._configuration import BareMetalInfrastructureClientConfiguration
from .operations import AzureBareMetalInstancesOperations, Operations
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class BareMetalInfrastructureClient: # pylint: disable=client-accepts-api-version-keyword
"""The BareMetalInfrastructure Management client.
:ivar azure_bare_metal_instances: AzureBareMetalInstancesOperations operations
:vartype azure_bare_metal_instances:
azure.mgmt.baremetalinfrastructure.aio.operations.AzureBareMetalInstancesOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.baremetalinfrastructure.aio.operations.Operations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2021-08-09". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = BareMetalInfrastructureClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.azure_bare_metal_instances = AzureBareMetalInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client._send_request(request)
<AsyncHttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.AsyncHttpResponse
"""
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()
async def __aenter__(self) -> "BareMetalInfrastructureClient":
await self._client.__aenter__()
return self
async def __aexit__(self, *exc_details) -> None:
await self._client.__aexit__(*exc_details)
|
azure-mgmt-baremetalinfrastructure
|
/azure_mgmt_baremetalinfrastructure-1.1.0b1-py3-none-any.whl/azure/mgmt/baremetalinfrastructure/aio/_bare_metal_infrastructure_client.py
|
_bare_metal_infrastructure_client.py
|
from copy import deepcopy
from typing import Any, Awaitable, TYPE_CHECKING
from azure.core.rest import AsyncHttpResponse, HttpRequest
from azure.mgmt.core import AsyncARMPipelineClient
from .. import models
from .._serialization import Deserializer, Serializer
from ._configuration import BareMetalInfrastructureClientConfiguration
from .operations import AzureBareMetalInstancesOperations, Operations
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class BareMetalInfrastructureClient: # pylint: disable=client-accepts-api-version-keyword
"""The BareMetalInfrastructure Management client.
:ivar azure_bare_metal_instances: AzureBareMetalInstancesOperations operations
:vartype azure_bare_metal_instances:
azure.mgmt.baremetalinfrastructure.aio.operations.AzureBareMetalInstancesOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.baremetalinfrastructure.aio.operations.Operations
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:param base_url: Service URL. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: Api Version. Default value is "2021-08-09". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
self._config = BareMetalInfrastructureClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
)
self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.azure_bare_metal_instances = AzureBareMetalInstancesOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client._send_request(request)
<AsyncHttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
:param request: The network request you want to make. Required.
:type request: ~azure.core.rest.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
:return: The response of your network call. Does not do error handling on your response.
:rtype: ~azure.core.rest.AsyncHttpResponse
"""
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()
async def __aenter__(self) -> "BareMetalInfrastructureClient":
await self._client.__aenter__()
return self
async def __aexit__(self, *exc_details) -> None:
await self._client.__aexit__(*exc_details)
| 0.828592 | 0.123868 |
import sys
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, AsyncARMChallengeAuthenticationPolicy
from .._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class BareMetalInfrastructureClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for BareMetalInfrastructureClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2021-08-09". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(BareMetalInfrastructureClientConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop("api_version", "2021-08-09") # type: Literal["2021-08-09"]
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-baremetalinfrastructure/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
|
azure-mgmt-baremetalinfrastructure
|
/azure_mgmt_baremetalinfrastructure-1.1.0b1-py3-none-any.whl/azure/mgmt/baremetalinfrastructure/aio/_configuration.py
|
_configuration.py
|
import sys
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, AsyncARMChallengeAuthenticationPolicy
from .._version import VERSION
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials_async import AsyncTokenCredential
class BareMetalInfrastructureClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for BareMetalInfrastructureClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription. Required.
:type subscription_id: str
:keyword api_version: Api Version. Default value is "2021-08-09". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""
def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
super(BareMetalInfrastructureClientConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop("api_version", "2021-08-09") # type: Literal["2021-08-09"]
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
self.credential = credential
self.subscription_id = subscription_id
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-baremetalinfrastructure/{}".format(VERSION))
self._configure(**kwargs)
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(
self.credential, *self.credential_scopes, **kwargs
)
| 0.548432 | 0.082771 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._azure_bare_metal_instances_operations import (
build_get_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class AzureBareMetalInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.baremetalinfrastructure.aio.BareMetalInfrastructureClient`'s
:attr:`azure_bare_metal_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AzureBareMetalInstance"]:
"""Gets a list of Azure BareMetal instances in the specified subscription.
Gets a list of AzureBareMetal instances in the specified subscription. The operations returns
various properties of each Azure BareMetal instance.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either AzureBareMetalInstance or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstancesListResult]
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
request.method = "GET"
return request
async def extract_data(pipeline_response):
deserialized = self._deserialize("AzureBareMetalInstancesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances"} # type: ignore
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.AzureBareMetalInstance"]:
"""Gets a list of Azure BareMetal instances in the specified subscription and resource group.
Gets a list of AzureBareMetal instances in the specified subscription and resource group. The
operations returns various properties of each Azure BareMetal instance.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either AzureBareMetalInstance or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstancesListResult]
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
request.method = "GET"
return request
async def extract_data(pipeline_response):
deserialized = self._deserialize("AzureBareMetalInstancesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances"} # type: ignore
@distributed_trace_async
async def get(
self, resource_group_name: str, azure_bare_metal_instance_name: str, **kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Gets an Azure BareMetal instance.
Gets an Azure BareMetal instance for the specified subscription, resource group, and instance
name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstance]
request = build_get_request(
resource_group_name=resource_group_name,
azure_bare_metal_instance_name=azure_bare_metal_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("AzureBareMetalInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}"} # type: ignore
@overload
async def update(
self,
resource_group_name: str,
azure_bare_metal_instance_name: str,
tags_parameter: _models.Tags,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Patches the Tags field of a Azure BareMetal instance.
Patches the Tags field of a Azure BareMetal instance for the specified subscription, resource
group, and instance name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:param tags_parameter: Request body that only contains the new Tags field. Required.
:type tags_parameter: ~azure.mgmt.baremetalinfrastructure.models.Tags
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
azure_bare_metal_instance_name: str,
tags_parameter: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Patches the Tags field of a Azure BareMetal instance.
Patches the Tags field of a Azure BareMetal instance for the specified subscription, resource
group, and instance name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:param tags_parameter: Request body that only contains the new Tags field. Required.
:type tags_parameter: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
azure_bare_metal_instance_name: str,
tags_parameter: Union[_models.Tags, IO],
**kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Patches the Tags field of a Azure BareMetal instance.
Patches the Tags field of a Azure BareMetal instance for the specified subscription, resource
group, and instance name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:param tags_parameter: Request body that only contains the new Tags field. Is either a model
type or a IO type. Required.
:type tags_parameter: ~azure.mgmt.baremetalinfrastructure.models.Tags or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstance]
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(tags_parameter, (IO, bytes)):
_content = tags_parameter
else:
_json = self._serialize.body(tags_parameter, "Tags")
request = build_update_request(
resource_group_name=resource_group_name,
azure_bare_metal_instance_name=azure_bare_metal_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("AzureBareMetalInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}"} # type: ignore
|
azure-mgmt-baremetalinfrastructure
|
/azure_mgmt_baremetalinfrastructure-1.1.0b1-py3-none-any.whl/azure/mgmt/baremetalinfrastructure/aio/operations/_azure_bare_metal_instances_operations.py
|
_azure_bare_metal_instances_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
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.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._azure_bare_metal_instances_operations import (
build_get_request,
build_list_by_resource_group_request,
build_list_by_subscription_request,
build_update_request,
)
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class AzureBareMetalInstancesOperations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.baremetalinfrastructure.aio.BareMetalInfrastructureClient`'s
:attr:`azure_bare_metal_instances` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AzureBareMetalInstance"]:
"""Gets a list of Azure BareMetal instances in the specified subscription.
Gets a list of AzureBareMetal instances in the specified subscription. The operations returns
various properties of each Azure BareMetal instance.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either AzureBareMetalInstance or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstancesListResult]
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_subscription_request(
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_subscription.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
request.method = "GET"
return request
async def extract_data(pipeline_response):
deserialized = self._deserialize("AzureBareMetalInstancesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances"} # type: ignore
@distributed_trace
def list_by_resource_group(
self, resource_group_name: str, **kwargs: Any
) -> AsyncIterable["_models.AzureBareMetalInstance"]:
"""Gets a list of Azure BareMetal instances in the specified subscription and resource group.
Gets a list of AzureBareMetal instances in the specified subscription and resource group. The
operations returns various properties of each Azure BareMetal instance.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either AzureBareMetalInstance or the result of
cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstancesListResult]
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_by_resource_group_request(
resource_group_name=resource_group_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.list_by_resource_group.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
request.method = "GET"
return request
async def extract_data(pipeline_response):
deserialized = self._deserialize("AzureBareMetalInstancesListResult", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link or None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances"} # type: ignore
@distributed_trace_async
async def get(
self, resource_group_name: str, azure_bare_metal_instance_name: str, **kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Gets an Azure BareMetal instance.
Gets an Azure BareMetal instance for the specified subscription, resource group, and instance
name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstance]
request = build_get_request(
resource_group_name=resource_group_name,
azure_bare_metal_instance_name=azure_bare_metal_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
template_url=self.get.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("AzureBareMetalInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}"} # type: ignore
@overload
async def update(
self,
resource_group_name: str,
azure_bare_metal_instance_name: str,
tags_parameter: _models.Tags,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Patches the Tags field of a Azure BareMetal instance.
Patches the Tags field of a Azure BareMetal instance for the specified subscription, resource
group, and instance name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:param tags_parameter: Request body that only contains the new Tags field. Required.
:type tags_parameter: ~azure.mgmt.baremetalinfrastructure.models.Tags
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@overload
async def update(
self,
resource_group_name: str,
azure_bare_metal_instance_name: str,
tags_parameter: IO,
*,
content_type: str = "application/json",
**kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Patches the Tags field of a Azure BareMetal instance.
Patches the Tags field of a Azure BareMetal instance for the specified subscription, resource
group, and instance name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:param tags_parameter: Request body that only contains the new Tags field. Required.
:type tags_parameter: IO
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
@distributed_trace_async
async def update(
self,
resource_group_name: str,
azure_bare_metal_instance_name: str,
tags_parameter: Union[_models.Tags, IO],
**kwargs: Any
) -> _models.AzureBareMetalInstance:
"""Patches the Tags field of a Azure BareMetal instance.
Patches the Tags field of a Azure BareMetal instance for the specified subscription, resource
group, and instance name.
:param resource_group_name: The name of the resource group. The name is case insensitive.
Required.
:type resource_group_name: str
:param azure_bare_metal_instance_name: Name of the Azure BareMetal on Azure instance. Required.
:type azure_bare_metal_instance_name: str
:param tags_parameter: Request body that only contains the new Tags field. Is either a model
type or a IO type. Required.
:type tags_parameter: ~azure.mgmt.baremetalinfrastructure.models.Tags or IO
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
Default value is None.
:paramtype content_type: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: AzureBareMetalInstance or the result of cls(response)
:rtype: ~azure.mgmt.baremetalinfrastructure.models.AzureBareMetalInstance
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str]
cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureBareMetalInstance]
content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(tags_parameter, (IO, bytes)):
_content = tags_parameter
else:
_json = self._serialize.body(tags_parameter, "Tags")
request = build_update_request(
resource_group_name=resource_group_name,
azure_bare_metal_instance_name=azure_bare_metal_instance_name,
subscription_id=self._config.subscription_id,
api_version=api_version,
content_type=content_type,
json=_json,
content=_content,
template_url=self.update.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
deserialized = self._deserialize("AzureBareMetalInstance", pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized
update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}"} # type: ignore
| 0.701202 | 0.103885 |
import sys
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._operations import build_list_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.baremetalinfrastructure.aio.BareMetalInfrastructureClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]:
"""Gets a list of AzureBareMetal management operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Operation or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.baremetalinfrastructure.models.Operation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationList]
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
request.method = "GET"
return request
async def extract_data(pipeline_response):
deserialized = self._deserialize("OperationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {"url": "/providers/Microsoft.BareMetalInfrastructure/operations"} # type: ignore
|
azure-mgmt-baremetalinfrastructure
|
/azure_mgmt_baremetalinfrastructure-1.1.0b1-py3-none-any.whl/azure/mgmt/baremetalinfrastructure/aio/operations/_operations.py
|
_operations.py
|
import sys
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar
import urllib.parse
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
ResourceExistsError,
ResourceNotFoundError,
ResourceNotModifiedError,
map_error,
)
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse
from azure.core.rest import HttpRequest
from azure.core.tracing.decorator import distributed_trace
from azure.core.utils import case_insensitive_dict
from azure.mgmt.core.exceptions import ARMErrorFormat
from ... import models as _models
from ..._vendor import _convert_request
from ...operations._operations import build_list_request
if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
class Operations:
"""
.. warning::
**DO NOT** instantiate this class directly.
Instead, you should access the following operations through
:class:`~azure.mgmt.baremetalinfrastructure.aio.BareMetalInfrastructureClient`'s
:attr:`operations` attribute.
"""
models = _models
def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
@distributed_trace
def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]:
"""Gets a list of AzureBareMetal management operations.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either Operation or the result of cls(response)
:rtype:
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.baremetalinfrastructure.models.Operation]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = kwargs.pop("headers", {}) or {}
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
api_version = kwargs.pop(
"api_version", _params.pop("api-version", self._config.api_version)
) # type: Literal["2021-08-09"]
cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationList]
error_map = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})
def prepare_request(next_link=None):
if not next_link:
request = build_list_request(
api_version=api_version,
template_url=self.list.metadata["url"],
headers=_headers,
params=_params,
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
else:
# make call to next link with the client's api-version
_parsed_next_link = urllib.parse.urlparse(next_link)
_next_request_params = case_insensitive_dict(
{
key: [urllib.parse.quote(v) for v in value]
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
}
)
_next_request_params["api-version"] = self._config.api_version
request = HttpRequest(
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
)
request = _convert_request(request)
request.url = self._client.format_url(request.url) # type: ignore
request.method = "GET"
return request
async def extract_data(pipeline_response):
deserialized = self._deserialize("OperationList", pipeline_response)
list_of_elem = deserialized.value
if cls:
list_of_elem = cls(list_of_elem)
return None, AsyncList(list_of_elem)
async def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
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, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
return pipeline_response
return AsyncItemPaged(get_next, extract_data)
list.metadata = {"url": "/providers/Microsoft.BareMetalInfrastructure/operations"} # type: ignore
| 0.625209 | 0.092976 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.