From 38a335faa3d34e55820dacebb5fb8ab72058fbe2 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 13 Nov 2018 23:33:07 +0000 Subject: [PATCH 1/2] Generated from 6363da5bf9a13499463df8ff5e443801d064ab84 Adds Geo Replication Stats in Azure Storage Account's properties --- .../storage/v2018_07_01/models/__init__.py | 7 +++ .../models/geo_replication_stats.py | 53 +++++++++++++++++++ .../models/geo_replication_stats_py3.py | 53 +++++++++++++++++++ .../v2018_07_01/models/storage_account.py | 6 +++ .../v2018_07_01/models/storage_account_py3.py | 6 +++ .../models/storage_management_client_enums.py | 12 +++++ .../operations/storage_accounts_operations.py | 10 +++- 7 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/geo_replication_stats.py create mode 100644 azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/geo_replication_stats_py3.py diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py index c951f77e1575..10fdba5e08a3 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py @@ -31,6 +31,7 @@ from .identity_py3 import Identity from .storage_account_create_parameters_py3 import StorageAccountCreateParameters from .endpoints_py3 import Endpoints + from .geo_replication_stats_py3 import GeoReplicationStats from .storage_account_py3 import StorageAccount from .storage_account_key_py3 import StorageAccountKey from .storage_account_list_keys_result_py3 import StorageAccountListKeysResult @@ -83,6 +84,7 @@ from .identity import Identity from .storage_account_create_parameters import StorageAccountCreateParameters from .endpoints import Endpoints + from .geo_replication_stats import GeoReplicationStats from .storage_account import StorageAccount from .storage_account_key import StorageAccountKey from .storage_account_list_keys_result import StorageAccountListKeysResult @@ -129,6 +131,7 @@ Bypass, DefaultAction, AccessTier, + GeoReplicationStatus, ProvisioningState, AccountStatus, KeyPermission, @@ -144,6 +147,7 @@ LeaseDuration, ImmutabilityPolicyState, ImmutabilityPolicyUpdateType, + StorageAccountExpand, ) __all__ = [ @@ -168,6 +172,7 @@ 'Identity', 'StorageAccountCreateParameters', 'Endpoints', + 'GeoReplicationStats', 'StorageAccount', 'StorageAccountKey', 'StorageAccountListKeysResult', @@ -213,6 +218,7 @@ 'Bypass', 'DefaultAction', 'AccessTier', + 'GeoReplicationStatus', 'ProvisioningState', 'AccountStatus', 'KeyPermission', @@ -228,4 +234,5 @@ 'LeaseDuration', 'ImmutabilityPolicyState', 'ImmutabilityPolicyUpdateType', + 'StorageAccountExpand', ] diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/geo_replication_stats.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/geo_replication_stats.py new file mode 100644 index 000000000000..c5d108e0d189 --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/geo_replication_stats.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class GeoReplicationStats(Model): + """Statistics related to replication for storage account's Blob, Table, Queue + and File services. It is only available when geo-redundant replication is + enabled for the storage account. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar status: The status of the secondary location. Possible values are: - + Live: Indicates that the secondary location is active and operational. - + Bootstrap: Indicates initial synchronization from the primary location to + the secondary location is in progress.This typically occurs when + replication is first enabled. - Unavailable: Indicates that the secondary + location is temporarily unavailable. Possible values include: 'Live', + 'Bootstrap', 'Unavailable' + :vartype status: str or + ~azure.mgmt.storage.v2018_07_01.models.GeoReplicationStatus + :ivar last_sync_time: All primary writes preceding this UTC date/time + value are guaranteed to be available for read operations. Primary writes + following this point in time may or may not be available for reads. + Element may be default value if value of LastSyncTime is not available, + this can happen if secondary is offline or we are in bootstrap. + :vartype last_sync_time: datetime + """ + + _validation = { + 'status': {'readonly': True}, + 'last_sync_time': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(GeoReplicationStats, self).__init__(**kwargs) + self.status = None + self.last_sync_time = None diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/geo_replication_stats_py3.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/geo_replication_stats_py3.py new file mode 100644 index 000000000000..1f9b84b3602a --- /dev/null +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/geo_replication_stats_py3.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class GeoReplicationStats(Model): + """Statistics related to replication for storage account's Blob, Table, Queue + and File services. It is only available when geo-redundant replication is + enabled for the storage account. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar status: The status of the secondary location. Possible values are: - + Live: Indicates that the secondary location is active and operational. - + Bootstrap: Indicates initial synchronization from the primary location to + the secondary location is in progress.This typically occurs when + replication is first enabled. - Unavailable: Indicates that the secondary + location is temporarily unavailable. Possible values include: 'Live', + 'Bootstrap', 'Unavailable' + :vartype status: str or + ~azure.mgmt.storage.v2018_07_01.models.GeoReplicationStatus + :ivar last_sync_time: All primary writes preceding this UTC date/time + value are guaranteed to be available for read operations. Primary writes + following this point in time may or may not be available for reads. + Element may be default value if value of LastSyncTime is not available, + this can happen if secondary is offline or we are in bootstrap. + :vartype last_sync_time: datetime + """ + + _validation = { + 'status': {'readonly': True}, + 'last_sync_time': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs) -> None: + super(GeoReplicationStats, self).__init__(**kwargs) + self.status = None + self.last_sync_time = None diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account.py index 379f54fc2b9f..438942c71c10 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account.py @@ -105,6 +105,9 @@ class StorageAccount(TrackedResource): :param is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :type is_hns_enabled: bool + :ivar geo_replication_stats: Geo Replication Stats + :vartype geo_replication_stats: + ~azure.mgmt.storage.v2018_07_01.models.GeoReplicationStats """ _validation = { @@ -127,6 +130,7 @@ class StorageAccount(TrackedResource): 'encryption': {'readonly': True}, 'access_tier': {'readonly': True}, 'network_rule_set': {'readonly': True}, + 'geo_replication_stats': {'readonly': True}, } _attribute_map = { @@ -154,6 +158,7 @@ class StorageAccount(TrackedResource): 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, + 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, } def __init__(self, **kwargs): @@ -177,3 +182,4 @@ def __init__(self, **kwargs): self.enable_https_traffic_only = kwargs.get('enable_https_traffic_only', None) self.network_rule_set = None self.is_hns_enabled = kwargs.get('is_hns_enabled', None) + self.geo_replication_stats = None diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account_py3.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account_py3.py index b83276b42715..b75f741d68b2 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account_py3.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account_py3.py @@ -105,6 +105,9 @@ class StorageAccount(TrackedResource): :param is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :type is_hns_enabled: bool + :ivar geo_replication_stats: Geo Replication Stats + :vartype geo_replication_stats: + ~azure.mgmt.storage.v2018_07_01.models.GeoReplicationStats """ _validation = { @@ -127,6 +130,7 @@ class StorageAccount(TrackedResource): 'encryption': {'readonly': True}, 'access_tier': {'readonly': True}, 'network_rule_set': {'readonly': True}, + 'geo_replication_stats': {'readonly': True}, } _attribute_map = { @@ -154,6 +158,7 @@ class StorageAccount(TrackedResource): 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, + 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, } def __init__(self, *, location: str, tags=None, identity=None, enable_azure_files_aad_integration: bool=None, enable_https_traffic_only: bool=None, is_hns_enabled: bool=None, **kwargs) -> None: @@ -177,3 +182,4 @@ def __init__(self, *, location: str, tags=None, identity=None, enable_azure_file self.enable_https_traffic_only = enable_https_traffic_only self.network_rule_set = None self.is_hns_enabled = is_hns_enabled + self.geo_replication_stats = None diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_management_client_enums.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_management_client_enums.py index aa998284e397..b8dd0a6874ef 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_management_client_enums.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_management_client_enums.py @@ -89,6 +89,13 @@ class AccessTier(str, Enum): cool = "Cool" +class GeoReplicationStatus(str, Enum): + + live = "Live" + bootstrap = "Bootstrap" + unavailable = "Unavailable" + + class ProvisioningState(str, Enum): creating = "Creating" @@ -198,3 +205,8 @@ class ImmutabilityPolicyUpdateType(str, Enum): put = "put" lock = "lock" extend = "extend" + + +class StorageAccountExpand(str, Enum): + + geo_replication_stats = "geoReplicationStats" diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/storage_accounts_operations.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/storage_accounts_operations.py index 7b34e2cada26..04203aa83cef 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/storage_accounts_operations.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/storage_accounts_operations.py @@ -271,7 +271,7 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} def get_properties( - self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + self, resource_group_name, account_name, expand=None, custom_headers=None, raw=False, **operation_config): """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -283,6 +283,12 @@ def get_properties( specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :param expand: May be used to expand the properties within account's + properties. By default, data is not included when fecthing properties. + Currently we only support geoReplicationStats. Possible values + include: 'geoReplicationStats' + :type expand: str or + ~azure.mgmt.storage.v2018_07_01.models.StorageAccountExpand :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -305,6 +311,8 @@ def get_properties( # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'StorageAccountExpand') # Construct headers header_parameters = {} From 3f8ee2876010afca518de111b1ce7395aafbea70 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 14 Nov 2018 20:09:55 +0000 Subject: [PATCH 2/2] Generated from 126237ac76d98075599b17e0032c37e0af486e8b Merge branch 'master' into adds_geo_replication_stats --- .../v2018_07_01/models/storage_account.py | 6 ++ .../v2018_07_01/models/storage_account_py3.py | 6 ++ .../operations/storage_accounts_operations.py | 85 +++++++++++++++++++ 3 files changed, 97 insertions(+) diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account.py index 438942c71c10..0c9c592accff 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account.py @@ -108,6 +108,9 @@ class StorageAccount(TrackedResource): :ivar geo_replication_stats: Geo Replication Stats :vartype geo_replication_stats: ~azure.mgmt.storage.v2018_07_01.models.GeoReplicationStats + :ivar failover_in_progress: If the failover is in progress, the value will + be true, otherwise, it will be null. + :vartype failover_in_progress: bool """ _validation = { @@ -131,6 +134,7 @@ class StorageAccount(TrackedResource): 'access_tier': {'readonly': True}, 'network_rule_set': {'readonly': True}, 'geo_replication_stats': {'readonly': True}, + 'failover_in_progress': {'readonly': True}, } _attribute_map = { @@ -159,6 +163,7 @@ class StorageAccount(TrackedResource): 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, + 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, } def __init__(self, **kwargs): @@ -183,3 +188,4 @@ def __init__(self, **kwargs): self.network_rule_set = None self.is_hns_enabled = kwargs.get('is_hns_enabled', None) self.geo_replication_stats = None + self.failover_in_progress = None diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account_py3.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account_py3.py index b75f741d68b2..a08fcf8b985c 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account_py3.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/storage_account_py3.py @@ -108,6 +108,9 @@ class StorageAccount(TrackedResource): :ivar geo_replication_stats: Geo Replication Stats :vartype geo_replication_stats: ~azure.mgmt.storage.v2018_07_01.models.GeoReplicationStats + :ivar failover_in_progress: If the failover is in progress, the value will + be true, otherwise, it will be null. + :vartype failover_in_progress: bool """ _validation = { @@ -131,6 +134,7 @@ class StorageAccount(TrackedResource): 'access_tier': {'readonly': True}, 'network_rule_set': {'readonly': True}, 'geo_replication_stats': {'readonly': True}, + 'failover_in_progress': {'readonly': True}, } _attribute_map = { @@ -159,6 +163,7 @@ class StorageAccount(TrackedResource): 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, + 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, } def __init__(self, *, location: str, tags=None, identity=None, enable_azure_files_aad_integration: bool=None, enable_https_traffic_only: bool=None, is_hns_enabled: bool=None, **kwargs) -> None: @@ -183,3 +188,4 @@ def __init__(self, *, location: str, tags=None, identity=None, enable_azure_file self.network_rule_set = None self.is_hns_enabled = is_hns_enabled self.geo_replication_stats = None + self.failover_in_progress = None diff --git a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/storage_accounts_operations.py b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/storage_accounts_operations.py index 04203aa83cef..67f53973cb20 100644 --- a/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/storage_accounts_operations.py +++ b/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/storage_accounts_operations.py @@ -848,3 +848,88 @@ def list_service_sas( return deserialized list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} + + + def _failover_initial( + self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.failover.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def failover( + self, resource_group_name, account_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Failover request can be triggered for a storage account in case of + availability issues. The failover occurs from the storage account's + primary cluster to secondary cluster for RA-GRS accounts. The secondary + cluster will become primary after failover. + + :param resource_group_name: The name of the resource group within the + user's subscription. The name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the + specified resource group. Storage account names must be between 3 and + 24 characters in length and use numbers and lower-case letters only. + :type account_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: :class:`CloudError` + """ + raw_result = self._failover_initial( + resource_group_name=resource_group_name, + account_name=account_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'}