diff --git a/src/storagecache/HISTORY.rst b/src/storagecache/HISTORY.rst new file mode 100644 index 00000000000..27f152061e8 --- /dev/null +++ b/src/storagecache/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. diff --git a/src/storagecache/README.md b/src/storagecache/README.md new file mode 100644 index 00000000000..7807300395a --- /dev/null +++ b/src/storagecache/README.md @@ -0,0 +1,5 @@ +Microsoft Azure CLI 'storagecache' Extension +========================================== + +This package is for the 'storagecache' extension. +i.e. 'az storagecache' diff --git a/src/storagecache/azext_storagecache/__init__.py b/src/storagecache/azext_storagecache/__init__.py new file mode 100644 index 00000000000..af01d61d78d --- /dev/null +++ b/src/storagecache/azext_storagecache/__init__.py @@ -0,0 +1,46 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azext_storagecache.generated._help import helps # pylint: disable=unused-import + + +class StorageCacheManagementClientCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from azext_storagecache.generated._client_factory import cf_storagecache + storagecache_custom = CliCommandType( + operations_tmpl='azext_storagecache.custom#{}', + client_factory=cf_storagecache) + super(StorageCacheManagementClientCommandsLoader, self).__init__(cli_ctx=cli_ctx, + custom_command_type=storagecache_custom) + + def load_command_table(self, args): + from azext_storagecache.generated.commands import load_command_table + load_command_table(self, args) + try: + from azext_storagecache.manual.commands import load_command_table as load_command_table_manual + load_command_table_manual(self, args) + except ImportError: + pass + return self.command_table + + def load_arguments(self, command): + from azext_storagecache.generated._params import load_arguments + load_arguments(self, command) + try: + from azext_storagecache.manual._params import load_arguments as load_arguments_manual + load_arguments_manual(self, command) + except ImportError: + pass + + +COMMAND_LOADER_CLS = StorageCacheManagementClientCommandsLoader diff --git a/src/storagecache/azext_storagecache/action.py b/src/storagecache/azext_storagecache/action.py new file mode 100644 index 00000000000..a846b2766c4 --- /dev/null +++ b/src/storagecache/azext_storagecache/action.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.action import * # noqa: F403 +try: + from .manual.action import * # noqa: F403 +except ImportError: + pass diff --git a/src/storagecache/azext_storagecache/azext_metadata.json b/src/storagecache/azext_storagecache/azext_metadata.json new file mode 100644 index 00000000000..7b56fb1e11a --- /dev/null +++ b/src/storagecache/azext_storagecache/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isExperimental": true, + "azext.minCliCoreVersion": "2.3.1" +} \ No newline at end of file diff --git a/src/storagecache/azext_storagecache/custom.py b/src/storagecache/azext_storagecache/custom.py new file mode 100644 index 00000000000..7f31674ce96 --- /dev/null +++ b/src/storagecache/azext_storagecache/custom.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.custom import * # noqa: F403 +try: + from .manual.custom import * # noqa: F403 +except ImportError: + pass diff --git a/src/storagecache/azext_storagecache/generated/__init__.py b/src/storagecache/azext_storagecache/generated/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/storagecache/azext_storagecache/generated/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/storagecache/azext_storagecache/generated/_client_factory.py b/src/storagecache/azext_storagecache/generated/_client_factory.py new file mode 100644 index 00000000000..8aa1cfa00bd --- /dev/null +++ b/src/storagecache/azext_storagecache/generated/_client_factory.py @@ -0,0 +1,35 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + + +def cf_storagecache(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from ..vendored_sdks.storagecache import StorageCacheManagementClient + return get_mgmt_service_client(cli_ctx, StorageCacheManagementClient) + + +def cf_sku(cli_ctx, *_): + return cf_storagecache(cli_ctx).sku + + +def cf_usage_model(cli_ctx, *_): + return cf_storagecache(cli_ctx).usage_model + + +def cf_asc_operation(cli_ctx, *_): + return cf_storagecache(cli_ctx).asc_operation + + +def cf_cache(cli_ctx, *_): + return cf_storagecache(cli_ctx).cache + + +def cf_storage_target(cli_ctx, *_): + return cf_storagecache(cli_ctx).storage_target diff --git a/src/storagecache/azext_storagecache/generated/_help.py b/src/storagecache/azext_storagecache/generated/_help.py new file mode 100644 index 00000000000..975bf761232 --- /dev/null +++ b/src/storagecache/azext_storagecache/generated/_help.py @@ -0,0 +1,208 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +from knack.help_files import helps + + +helps['storagecache sku'] = """ + type: group + short-summary: storagecache sku +""" + +helps['storagecache sku list'] = """ + type: command + short-summary: Get the list of StorageCache.Cache SKUs available to this subscription. + examples: + - name: Skus_List + text: |- + az storagecache sku list +""" + +helps['storagecache usage-model'] = """ + type: group + short-summary: storagecache usage-model +""" + +helps['storagecache usage-model list'] = """ + type: command + short-summary: Get the list of Cache Usage Models available to this subscription. + examples: + - name: UsageModels_List + text: |- + az storagecache usage-model list +""" + +helps['storagecache asc-operation'] = """ + type: group + short-summary: storagecache asc-operation +""" + +helps['storagecache asc-operation show'] = """ + type: command + short-summary: Gets the status of an asynchronous operation for the Azure HPC cache + examples: + - name: AscOperations_Get + text: |- + az storagecache asc-operation show --operation-id "testoperationid" --location "West US" +""" + +helps['storagecache cache'] = """ + type: group + short-summary: storagecache cache +""" + +helps['storagecache cache list'] = """ + type: command + short-summary: Returns all Caches the user has access to under a subscription. + examples: + - name: Caches_ListByResourceGroup + text: |- + az storagecache cache list --resource-group "scgroup" +""" + +helps['storagecache cache show'] = """ + type: command + short-summary: Returns a Cache. + examples: + - name: Caches_Get + text: |- + az storagecache cache show --cache-name "sc1" --resource-group "scgroup" +""" + +helps['storagecache cache create'] = """ + type: command + short-summary: Create or update a Cache. + examples: + - name: Caches_CreateOrUpdate + text: |- + az storagecache cache create --location "westus" --cache-size-gb 3072 --subnet "/subscriptions/00000000-\ +0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1" --s\ +ku name="Standard_2G" --tags "{\\"Dept\\":\\"Initech\\"}" --cache-name "sc1" --resource-group "scgroup" +""" + +helps['storagecache cache update'] = """ + type: command + short-summary: Update a Cache instance. + examples: + - name: Caches_Update + text: |- + az storagecache cache update --location "westus" --cache-size-gb 3072 --subnet "/subscriptions/00000000-\ +0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1" --s\ +ku name="Standard_2G" --tags "{\\"Dept\\":\\"Initech\\"}" --cache-name "sc1" --resource-group "scgroup" +""" + +helps['storagecache cache delete'] = """ + type: command + short-summary: Schedules a Cache for deletion. + examples: + - name: Caches_Delete + text: |- + az storagecache cache delete --cache-name "sc" --resource-group "scgroup" +""" + +helps['storagecache cache flush'] = """ + type: command + short-summary: Tells a Cache to write all dirty data to the Storage Target(s). During the flush, clients will see e\ +rrors returned until the flush is complete. + examples: + - name: Caches_Flush + text: |- + az storagecache cache flush --cache-name "sc" --resource-group "scgroup" +""" + +helps['storagecache cache start'] = """ + type: command + short-summary: Tells a Stopped state Cache to transition to Active state. + examples: + - name: Caches_Start + text: |- + az storagecache cache start --cache-name "sc" --resource-group "scgroup" +""" + +helps['storagecache cache stop'] = """ + type: command + short-summary: Tells an Active Cache to transition to Stopped state. + examples: + - name: Caches_Stop + text: |- + az storagecache cache stop --cache-name "sc" --resource-group "scgroup" +""" + +helps['storagecache cache upgrade-firmware'] = """ + type: command + short-summary: Upgrade a Cache's firmware if a new version is available. Otherwise, this operation has no effect. + examples: + - name: Caches_UpgradeFirmware + text: |- + az storagecache cache upgrade-firmware --cache-name "sc1" --resource-group "scgroup" +""" + +helps['storagecache storage-target'] = """ + type: group + short-summary: storagecache storage-target +""" + +helps['storagecache storage-target list'] = """ + type: command + short-summary: Returns a list of Storage Targets for the specified Cache. + examples: + - name: StorageTargets_List + text: |- + az storagecache storage-target list --cache-name "sc1" --resource-group "scgroup" +""" + +helps['storagecache storage-target show'] = """ + type: command + short-summary: Returns a Storage Target from a Cache. + examples: + - name: StorageTargets_Get + text: |- + az storagecache storage-target show --cache-name "sc1" --resource-group "scgroup" --storage-target-name \ +"st1" +""" + +helps['storagecache storage-target create'] = """ + type: command + short-summary: Create or update a Storage Target. This operation is allowed at any time, but if the Cache is down o\ +r unhealthy, the actual creation/modification of the Storage Target may be delayed until the Cache is healthy again. + examples: + - name: StorageTargets_CreateOrUpdate + text: |- + az storagecache storage-target create --cache-name "sc1" --resource-group "scgroup" --storage-target-nam\ +e "st1" --junctions namespace-path="/path/on/cache" nfs-export="exp1" target-path="/path/on/exp1" --junctions namespace\ +-path="/path2/on/cache" nfs-export="exp2" target-path="/path2/on/exp2" --nfs3 target="10.0.44.44" usage-model="READ_HEA\ +VY_INFREQ" --target-type "nfs3" +""" + +helps['storagecache storage-target update'] = """ + type: command + short-summary: Create or update a Storage Target. This operation is allowed at any time, but if the Cache is down o\ +r unhealthy, the actual creation/modification of the Storage Target may be delayed until the Cache is healthy again. + examples: + - name: StorageTargets_CreateOrUpdate + text: |- + az storagecache storage-target update --cache-name "sc1" --resource-group "scgroup" --storage-target-nam\ +e "st1" --junctions namespace-path="/path/on/cache" nfs-export="exp1" target-path="/path/on/exp1" --junctions namespace\ +-path="/path2/on/cache" nfs-export="exp2" target-path="/path2/on/exp2" --nfs3 target="10.0.44.44" usage-model="READ_HEA\ +VY_INFREQ" --target-type "nfs3" +""" + +helps['storagecache storage-target delete'] = """ + type: command + short-summary: Removes a Storage Target from a Cache. This operation is allowed at any time, but if the Cache is do\ +wn or unhealthy, the actual removal of the Storage Target may be delayed until the Cache is healthy again. Note that if\ + the Cache has data to flush to the Storage Target, the data will be flushed before the Storage Target will be deleted. + examples: + - name: StorageTargets_Delete + text: |- + az storagecache storage-target delete --cache-name "sc1" --resource-group "scgroup" --storage-target-nam\ +e "st1" +""" diff --git a/src/storagecache/azext_storagecache/generated/_params.py b/src/storagecache/azext_storagecache/generated/_params.py new file mode 100644 index 00000000000..5cf212c1dc3 --- /dev/null +++ b/src/storagecache/azext_storagecache/generated/_params.py @@ -0,0 +1,186 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from knack.arguments import CLIArgumentType +from azure.cli.core.commands.parameters import ( + tags_type, + get_enum_type, + resource_group_name_type, + get_location_type +) +from azure.cli.core.commands.validators import get_default_location_from_resource_group +from azext_storagecache.action import ( + AddIdentity, + AddSku, + AddUpgradeStatus, + AddNetworkSettings, + AddSecuritySettings, + AddJunctions, + AddNfs3, + AddClfs +) + + +def load_arguments(self, _): + + with self.argument_context('storagecache sku list') as c: + pass + + with self.argument_context('storagecache usage-model list') as c: + pass + + with self.argument_context('storagecache asc-operation show') as c: + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('operation_id', help='The operation id which uniquely identifies the asynchronous operation.') + + with self.argument_context('storagecache cache list') as c: + c.argument('resource_group_name', resource_group_name_type) + + with self.argument_context('storagecache cache show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('cache_name', help='Name of Cache. Length of name must be not greater than 80 and chars must be in l' + 'ist of [-0-9a-zA-Z_] char class.') + + with self.argument_context('storagecache cache create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('cache_name', help='Name of Cache. Length of name must be not greater than 80 and chars must be in l' + 'ist of [-0-9a-zA-Z_] char class.') + c.argument('tags', tags_type) + c.argument('location', arg_type=get_location_type(self.cli_ctx), + validator=get_default_location_from_resource_group) + c.argument('identity', action=AddIdentity, nargs='+', help='The identity of the cache, if configured. Expect va' + 'lue: type=xx.') + c.argument('sku', action=AddSku, nargs='+', help='SKU for the Cache. Expect value: name=xx.') + c.argument('cache_size_gb', help='The size of this Cache, in GB.') + c.argument('provisioning_state', arg_type=get_enum_type(['Succeeded', 'Failed', 'Cancelled', 'Creating', 'Delet' + 'ing', 'Updating']), help='ARM provisioning state, see https://github.com/Azure/azure-resource-manag' + 'er-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property') + c.argument('subnet', help='Subnet used for the Cache.') + c.argument('upgrade_status', action=AddUpgradeStatus, nargs='+', help='Upgrade status of the Cache. Expect valu' + 'e: KEY1=VALUE1 KEY2=VALUE2 ...') + c.argument('network_settings', action=AddNetworkSettings, nargs='+', help='Specifies network settings of the ca' + 'che. Expect value: mtu=xx.') + c.argument('encryption_settings', arg_type=CLIArgumentType(options_list=['--encryption-settings'], help='Specif' + 'ies encryption settings of the cache. Expected value: json-string/@json-file.')) + c.argument('security_settings', action=AddSecuritySettings, nargs='+', help='Specifies security settings of the' + ' cache. Expect value: root-squash=xx.') + + with self.argument_context('storagecache cache update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('cache_name', help='Name of Cache. Length of name must be not greater than 80 and chars must be in l' + 'ist of [-0-9a-zA-Z_] char class.') + c.argument('tags', tags_type) + c.argument('location', arg_type=get_location_type(self.cli_ctx), + validator=get_default_location_from_resource_group) + c.argument('identity', action=AddIdentity, nargs='+', help='The identity of the cache, if configured. Expect va' + 'lue: type=xx.') + c.argument('sku', action=AddSku, nargs='+', help='SKU for the Cache. Expect value: name=xx.') + c.argument('cache_size_gb', help='The size of this Cache, in GB.') + c.argument('provisioning_state', arg_type=get_enum_type(['Succeeded', 'Failed', 'Cancelled', 'Creating', 'Delet' + 'ing', 'Updating']), help='ARM provisioning state, see https://github.com/Azure/azure-resource-manag' + 'er-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property') + c.argument('subnet', help='Subnet used for the Cache.') + c.argument('upgrade_status', action=AddUpgradeStatus, nargs='+', help='Upgrade status of the Cache. Expect valu' + 'e: KEY1=VALUE1 KEY2=VALUE2 ...') + c.argument('network_settings', action=AddNetworkSettings, nargs='+', help='Specifies network settings of the ca' + 'che. Expect value: mtu=xx.') + c.argument('encryption_settings', arg_type=CLIArgumentType(options_list=['--encryption-settings'], help='Specif' + 'ies encryption settings of the cache. Expected value: json-string/@json-file.')) + c.argument('security_settings', action=AddSecuritySettings, nargs='+', help='Specifies security settings of the' + ' cache. Expect value: root-squash=xx.') + + with self.argument_context('storagecache cache delete') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('cache_name', help='Name of Cache. Length of name must be not greater than 80 and chars must be in l' + 'ist of [-0-9a-zA-Z_] char class.') + + with self.argument_context('storagecache cache flush') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('cache_name', help='Name of Cache. Length of name must be not greater than 80 and chars must be in l' + 'ist of [-0-9a-zA-Z_] char class.') + + with self.argument_context('storagecache cache start') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('cache_name', help='Name of Cache. Length of name must be not greater than 80 and chars must be in l' + 'ist of [-0-9a-zA-Z_] char class.') + + with self.argument_context('storagecache cache stop') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('cache_name', help='Name of Cache. Length of name must be not greater than 80 and chars must be in l' + 'ist of [-0-9a-zA-Z_] char class.') + + with self.argument_context('storagecache cache upgrade-firmware') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('cache_name', help='Name of Cache. Length of name must be not greater than 80 and chars must be in l' + 'ist of [-0-9a-zA-Z_] char class.') + + with self.argument_context('storagecache storage-target list') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('cache_name', help='Name of Cache. Length of name must be not greater than 80 and chars must be in l' + 'ist of [-0-9a-zA-Z_] char class.') + + with self.argument_context('storagecache storage-target show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('cache_name', help='Name of Cache. Length of name must be not greater than 80 and chars must be in l' + 'ist of [-0-9a-zA-Z_] char class.') + c.argument('storage_target_name', help='Name of the Storage Target. Length of name must be not greater than 80 ' + 'and chars must be in list of [-0-9a-zA-Z_] char class.') + + with self.argument_context('storagecache storage-target create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('cache_name', help='Name of Cache. Length of name must be not greater than 80 and chars must be in l' + 'ist of [-0-9a-zA-Z_] char class.') + c.argument('storage_target_name', help='Name of the Storage Target. Length of name must be not greater than 80 ' + 'and chars must be in list of [-0-9a-zA-Z_] char class.') + c.argument('target_base_type', arg_type=get_enum_type(['nfs3', 'clfs', 'unknown']), help='Type of the Storage T' + 'arget.') + c.argument('junctions', action=AddJunctions, nargs='+', help='List of Cache namespace junctions to target for n' + 'amespace associations. Expect value: KEY1=VALUE1 KEY2=VALUE2 ... , available KEYs are: namespace-pa' + 'th, target-path, nfs-export.') + c.argument('target_type', help='Type of the Storage Target.') + c.argument('provisioning_state', arg_type=get_enum_type(['Succeeded', 'Failed', 'Cancelled', 'Creating', 'Delet' + 'ing', 'Updating']), help='ARM provisioning state, see https://github.com/Azure/azure-resource-manag' + 'er-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property') + c.argument('nfs3', action=AddNfs3, nargs='+', help='Properties when targetType is nfs3. Expect value: KEY1=VALU' + 'E1 KEY2=VALUE2 ... , available KEYs are: target, usage-model.') + c.argument('clfs', action=AddClfs, nargs='+', help='Properties when targetType is clfs. Expect value: target=xx' + '.') + c.argument('unknown', arg_type=CLIArgumentType(options_list=['--unknown'], help='Properties when targetType is ' + 'unknown. Expected value: json-string/@json-file.')) + + with self.argument_context('storagecache storage-target update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('cache_name', help='Name of Cache. Length of name must be not greater than 80 and chars must be in l' + 'ist of [-0-9a-zA-Z_] char class.') + c.argument('storage_target_name', help='Name of the Storage Target. Length of name must be not greater than 80 ' + 'and chars must be in list of [-0-9a-zA-Z_] char class.') + c.argument('target_base_type', arg_type=get_enum_type(['nfs3', 'clfs', 'unknown']), help='Type of the Storage T' + 'arget.') + c.argument('junctions', action=AddJunctions, nargs='+', help='List of Cache namespace junctions to target for n' + 'amespace associations. Expect value: KEY1=VALUE1 KEY2=VALUE2 ... , available KEYs are: namespace-pa' + 'th, target-path, nfs-export.') + c.argument('target_type', help='Type of the Storage Target.') + c.argument('provisioning_state', arg_type=get_enum_type(['Succeeded', 'Failed', 'Cancelled', 'Creating', 'Delet' + 'ing', 'Updating']), help='ARM provisioning state, see https://github.com/Azure/azure-resource-manag' + 'er-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property') + c.argument('nfs3', action=AddNfs3, nargs='+', help='Properties when targetType is nfs3. Expect value: KEY1=VALU' + 'E1 KEY2=VALUE2 ... , available KEYs are: target, usage-model.') + c.argument('clfs', action=AddClfs, nargs='+', help='Properties when targetType is clfs. Expect value: target=xx' + '.') + c.argument('unknown', arg_type=CLIArgumentType(options_list=['--unknown'], help='Properties when targetType is ' + 'unknown. Expected value: json-string/@json-file.')) + + with self.argument_context('storagecache storage-target delete') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('cache_name', help='Name of Cache. Length of name must be not greater than 80 and chars must be in l' + 'ist of [-0-9a-zA-Z_] char class.') + c.argument('storage_target_name', help='Name of Storage Target.') diff --git a/src/storagecache/azext_storagecache/generated/_validators.py b/src/storagecache/azext_storagecache/generated/_validators.py new file mode 100644 index 00000000000..7536d0531ea --- /dev/null +++ b/src/storagecache/azext_storagecache/generated/_validators.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + + +def example_name_or_id_validator(cmd, namespace): + from azure.cli.core.commands.client_factory import get_subscription_id + from msrestazure.tools import is_valid_resource_id, resource_id + if namespace.storage_account: + if not is_valid_resource_id(namespace.RESOURCE): + namespace.storage_account = resource_id( + subscription=get_subscription_id(cmd.cli_ctx), + resource_group=namespace.resource_group_name, + namespace='Microsoft.Storage', + type='storageAccounts', + name=namespace.storage_account + ) diff --git a/src/storagecache/azext_storagecache/generated/action.py b/src/storagecache/azext_storagecache/generated/action.py new file mode 100644 index 00000000000..f951d4b4aab --- /dev/null +++ b/src/storagecache/azext_storagecache/generated/action.py @@ -0,0 +1,202 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access + +import argparse +from knack.util import CLIError +from collections import defaultdict + + +class AddIdentity(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.identity = action + + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'type': + d['type'] = v[0] + return d + + +class AddSku(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.sku = action + + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'name': + d['name'] = v[0] + return d + + +class AddUpgradeStatus(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.upgrade_status = action + + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + return d + + +class AddNetworkSettings(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.network_settings = action + + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'mtu': + d['mtu'] = v[0] + return d + + +class AddSecuritySettings(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.security_settings = action + + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'root-squash': + d['root_squash'] = v[0] + return d + + +class AddJunctions(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + super(AddJunctions, self).__call__(parser, namespace, action, option_string) + + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'namespace-path': + d['namespace_path'] = v[0] + elif kl == 'target-path': + d['target_path'] = v[0] + elif kl == 'nfs-export': + d['nfs_export'] = v[0] + return d + + +class AddNfs3(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.nfs3 = action + + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'target': + d['target'] = v[0] + elif kl == 'usage-model': + d['usage_model'] = v[0] + return d + + +class AddClfs(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.clfs = action + + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'target': + d['target'] = v[0] + return d diff --git a/src/storagecache/azext_storagecache/generated/commands.py b/src/storagecache/azext_storagecache/generated/commands.py new file mode 100644 index 00000000000..7b2493da40a --- /dev/null +++ b/src/storagecache/azext_storagecache/generated/commands.py @@ -0,0 +1,70 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): + + from azext_storagecache.generated._client_factory import cf_sku + storagecache_sku = CliCommandType( + operations_tmpl='azext_storagecache.vendored_sdks.storagecache.operations._sku_operations#SkuOperations.{}', + client_factory=cf_sku) + with self.command_group('storagecache sku', storagecache_sku, client_factory=cf_sku, is_experimental=True) as g: + g.custom_command('list', 'storagecache_sku_list') + + from azext_storagecache.generated._client_factory import cf_usage_model + storagecache_usage_model = CliCommandType( + operations_tmpl='azext_storagecache.vendored_sdks.storagecache.operations._usage_model_operations#UsageModelOpe' + 'rations.{}', + client_factory=cf_usage_model) + with self.command_group('storagecache usage-model', storagecache_usage_model, client_factory=cf_usage_model, + is_experimental=True) as g: + g.custom_command('list', 'storagecache_usage_model_list') + + from azext_storagecache.generated._client_factory import cf_asc_operation + storagecache_asc_operation = CliCommandType( + operations_tmpl='azext_storagecache.vendored_sdks.storagecache.operations._asc_operation_operations#AscOperatio' + 'nOperations.{}', + client_factory=cf_asc_operation) + with self.command_group('storagecache asc-operation', storagecache_asc_operation, client_factory=cf_asc_operation, + is_experimental=True) as g: + g.custom_show_command('show', 'storagecache_asc_operation_show') + + from azext_storagecache.generated._client_factory import cf_cache + storagecache_cache = CliCommandType( + operations_tmpl='azext_storagecache.vendored_sdks.storagecache.operations._cache_operations#CacheOperations.{}', + client_factory=cf_cache) + with self.command_group('storagecache cache', storagecache_cache, client_factory=cf_cache, + is_experimental=True) as g: + g.custom_command('list', 'storagecache_cache_list') + g.custom_show_command('show', 'storagecache_cache_show') + g.custom_command('create', 'storagecache_cache_create', supports_no_wait=True) + g.custom_command('update', 'storagecache_cache_update') + g.custom_command('delete', 'storagecache_cache_delete', supports_no_wait=True) + g.custom_command('flush', 'storagecache_cache_flush', supports_no_wait=True) + g.custom_command('start', 'storagecache_cache_start', supports_no_wait=True) + g.custom_command('stop', 'storagecache_cache_stop', supports_no_wait=True) + g.custom_command('upgrade-firmware', 'storagecache_cache_upgrade_firmware', supports_no_wait=True) + g.wait_command('wait') + + from azext_storagecache.generated._client_factory import cf_storage_target + storagecache_storage_target = CliCommandType( + operations_tmpl='azext_storagecache.vendored_sdks.storagecache.operations._storage_target_operations#StorageTar' + 'getOperations.{}', + client_factory=cf_storage_target) + with self.command_group('storagecache storage-target', storagecache_storage_target, + client_factory=cf_storage_target, is_experimental=True) as g: + g.custom_command('list', 'storagecache_storage_target_list') + g.custom_show_command('show', 'storagecache_storage_target_show') + g.custom_command('create', 'storagecache_storage_target_create', supports_no_wait=True) + g.custom_command('update', 'storagecache_storage_target_update', supports_no_wait=True) + g.custom_command('delete', 'storagecache_storage_target_delete', supports_no_wait=True) + g.wait_command('wait') diff --git a/src/storagecache/azext_storagecache/generated/custom.py b/src/storagecache/azext_storagecache/generated/custom.py new file mode 100644 index 00000000000..547c41ad017 --- /dev/null +++ b/src/storagecache/azext_storagecache/generated/custom.py @@ -0,0 +1,217 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +import json + + +def storagecache_sku_list(cmd, client): + return client.list() + + +def storagecache_usage_model_list(cmd, client): + return client.list() + + +def storagecache_asc_operation_show(cmd, client, + location, + operation_id): + return client.get(location=location, + operation_id=operation_id) + + +def storagecache_cache_list(cmd, client, + resource_group_name=None): + if resource_group_name is not None: + return client.list_by_resource_group(resource_group_name=resource_group_name) + return client.list() + + +def storagecache_cache_show(cmd, client, + resource_group_name, + cache_name): + return client.get(resource_group_name=resource_group_name, + cache_name=cache_name) + + +def storagecache_cache_create(cmd, client, + resource_group_name, + cache_name, + tags=None, + location=None, + identity=None, + sku=None, + cache_size_gb=None, + provisioning_state=None, + subnet=None, + upgrade_status=None, + network_settings=None, + encryption_settings=None, + security_settings=None): + if isinstance(tags, str): + tags = json.loads(tags) + if isinstance(encryption_settings, str): + encryption_settings = json.loads(encryption_settings) + return client.begin_create_or_update(resource_group_name=resource_group_name, + cache_name=cache_name, + tags=tags, + location=location, + identity=identity, + sku=sku, + cache_size_gb=cache_size_gb, + provisioning_state=provisioning_state, + subnet=subnet, + upgrade_status=upgrade_status, + network_settings=network_settings, + encryption_settings=encryption_settings, + security_settings=security_settings) + + +def storagecache_cache_update(cmd, client, + resource_group_name, + cache_name, + tags=None, + location=None, + identity=None, + sku=None, + cache_size_gb=None, + provisioning_state=None, + subnet=None, + upgrade_status=None, + network_settings=None, + encryption_settings=None, + security_settings=None): + if isinstance(tags, str): + tags = json.loads(tags) + if isinstance(encryption_settings, str): + encryption_settings = json.loads(encryption_settings) + return client.update(resource_group_name=resource_group_name, + cache_name=cache_name, + tags=tags, + location=location, + identity=identity, + sku=sku, + cache_size_gb=cache_size_gb, + provisioning_state=provisioning_state, + subnet=subnet, + upgrade_status=upgrade_status, + network_settings=network_settings, + encryption_settings=encryption_settings, + security_settings=security_settings) + + +def storagecache_cache_delete(cmd, client, + resource_group_name, + cache_name): + return client.begin_delete(resource_group_name=resource_group_name, + cache_name=cache_name) + + +def storagecache_cache_flush(cmd, client, + resource_group_name, + cache_name): + return client.begin_flush(resource_group_name=resource_group_name, + cache_name=cache_name) + + +def storagecache_cache_start(cmd, client, + resource_group_name, + cache_name): + return client.begin_start(resource_group_name=resource_group_name, + cache_name=cache_name) + + +def storagecache_cache_stop(cmd, client, + resource_group_name, + cache_name): + return client.begin_stop(resource_group_name=resource_group_name, + cache_name=cache_name) + + +def storagecache_cache_upgrade_firmware(cmd, client, + resource_group_name, + cache_name): + return client.begin_upgrade_firmware(resource_group_name=resource_group_name, + cache_name=cache_name) + + +def storagecache_storage_target_list(cmd, client, + resource_group_name, + cache_name): + return client.list_by_cache(resource_group_name=resource_group_name, + cache_name=cache_name) + + +def storagecache_storage_target_show(cmd, client, + resource_group_name, + cache_name, + storage_target_name): + return client.get(resource_group_name=resource_group_name, + cache_name=cache_name, + storage_target_name=storage_target_name) + + +def storagecache_storage_target_create(cmd, client, + resource_group_name, + cache_name, + storage_target_name, + target_base_type=None, + junctions=None, + target_type=None, + provisioning_state=None, + nfs3=None, + clfs=None, + unknown=None): + if isinstance(unknown, str): + unknown = json.loads(unknown) + return client.begin_create_or_update(resource_group_name=resource_group_name, + cache_name=cache_name, + storage_target_name=storage_target_name, + target_base_type=target_base_type, + junctions=junctions, + target_type=target_type, + provisioning_state=provisioning_state, + nfs3=nfs3, + clfs=clfs, + unknown=unknown) + + +def storagecache_storage_target_update(cmd, client, + resource_group_name, + cache_name, + storage_target_name, + target_base_type=None, + junctions=None, + target_type=None, + provisioning_state=None, + nfs3=None, + clfs=None, + unknown=None): + if isinstance(unknown, str): + unknown = json.loads(unknown) + return client.begin_create_or_update(resource_group_name=resource_group_name, + cache_name=cache_name, + storage_target_name=storage_target_name, + target_base_type=target_base_type, + junctions=junctions, + target_type=target_type, + provisioning_state=provisioning_state, + nfs3=nfs3, + clfs=clfs, + unknown=unknown) + + +def storagecache_storage_target_delete(cmd, client, + resource_group_name, + cache_name, + storage_target_name): + return client.begin_delete(resource_group_name=resource_group_name, + cache_name=cache_name, + storage_target_name=storage_target_name) diff --git a/src/storagecache/azext_storagecache/manual/__init__.py b/src/storagecache/azext_storagecache/manual/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/storagecache/azext_storagecache/manual/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/storagecache/azext_storagecache/tests/__init__.py b/src/storagecache/azext_storagecache/tests/__init__.py new file mode 100644 index 00000000000..fe1bd438b46 --- /dev/null +++ b/src/storagecache/azext_storagecache/tests/__init__.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +import inspect +import os + + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) + + +def try_manual(func): + def import_manual_function(origin_func): + from importlib import import_module + decorated_path = inspect.getfile(origin_func) + module_path = __path__[0] + if not decorated_path.startswith(module_path): + raise Exception("Decorator can only be used in submodules!") + manual_path = os.path.join( + decorated_path[module_path.rfind(os.path.sep) + 1:]) + manual_file_path, manual_file_name = os.path.split(manual_path) + module_name, _ = os.path.splitext(manual_file_name) + manual_module = "..manual." + \ + ".".join(manual_file_path.split(os.path.sep) + [module_name, ]) + return getattr(import_module(manual_module, package=__name__), origin_func.__name__) + + def get_func_to_call(): + func_to_call = func + try: + func_to_call = import_manual_function(func) + except (ImportError, AttributeError): + pass + return func_to_call + + def wrapper(*args, **kwargs): + func_to_call = get_func_to_call() + print("running {}()...".format(func.__name__)) + return func_to_call(*args, **kwargs) + + if inspect.isclass(func): + return get_func_to_call() + else: + return wrapper diff --git a/src/storagecache/azext_storagecache/tests/latest/__init__.py b/src/storagecache/azext_storagecache/tests/latest/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/storagecache/azext_storagecache/tests/latest/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/storagecache/azext_storagecache/tests/latest/preparers.py b/src/storagecache/azext_storagecache/tests/latest/preparers.py new file mode 100644 index 00000000000..3d6672de64f --- /dev/null +++ b/src/storagecache/azext_storagecache/tests/latest/preparers.py @@ -0,0 +1,116 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import os +from datetime import datetime +from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer +from azure_devtools.scenario_tests import SingleValueReplacer +from azure.cli.testsdk.exceptions import CliTestError +from azure.cli.testsdk.reverse_dependency import get_dummy_cli + + +KEY_RESOURCE_GROUP = 'rg' +KEY_VIRTUAL_NETWORK = 'vnet' +KEY_VNET_SUBNET = 'subnet' + + +class VirtualNetworkPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='virtual_network', + resource_group_name=None, + resource_group_key=KEY_RESOURCE_GROUP, + dev_setting_name='AZURE_CLI_TEST_DEV_VIRTUAL_NETWORK_NAME', + random_name_length=24, key=KEY_VIRTUAL_NETWORK): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VirtualNetworkPreparer, self).__init__( + name_prefix, random_name_length) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group_name = resource_group_name + self.resource_group_key = resource_group_key + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **kwargs): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group_name: + self.resource_group_name = self.test_class_instance.kwargs.get( + self.resource_group_key) + if not self.resource_group_name: + raise CliTestError("Error: No resource group configured!") + + tags = {'product': 'azurecli', 'cause': 'automation', + 'date': datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')} + if 'ENV_JOB_NAME' in os.environ: + tags['job'] = os.environ['ENV_JOB_NAME'] + tags = ' '.join(['{}={}'.format(key, value) + for key, value in tags.items()]) + template = 'az network vnet create --resource-group {} --name {} --tag ' + tags + self.live_only_execute(self.cli_ctx, template.format( + self.resource_group_name, name)) + + self.test_class_instance.kwargs[self.key] = name + return {self.parameter_name: name} + + def remove_resource(self, name, **kwargs): + # delete vnet if test is being recorded and if the vnet is not a dev rg + if not self.dev_setting_name: + self.live_only_execute( + self.cli_ctx, 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name)) + + +class VnetSubnetPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='subnet', + resource_group_name=None, + resource_group_key=KEY_RESOURCE_GROUP, + vnet_name=None, + vnet_key=KEY_VIRTUAL_NETWORK, + address_prefixes="11.0.0.0/24", + dev_setting_name='AZURE_CLI_TEST_DEV_VNET_SUBNET_NAME', + random_name_length=24, key=KEY_VNET_SUBNET): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VnetSubnetPreparer, self).__init__( + name_prefix, random_name_length) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group_name = resource_group_name + self.resource_group_key = resource_group_key + self.vnet_name = vnet_name + self.vnet_key = vnet_key + self.address_prefixes = address_prefixes + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **kwargs): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group_name: + self.resource_group_name = self.test_class_instance.kwargs.get( + self.resource_group_key) + if not self.resource_group_name: + raise CliTestError("Error: No resource group configured!") + if not self.vnet_name: + self.vnet_name = self.test_class_instance.kwargs.get(self.vnet_key) + if not self.vnet_name: + raise CliTestError("Error: No vnet configured!") + + self.test_class_instance.kwargs[self.key] = 'default' + return {self.parameter_name: name} + + def remove_resource(self, name, **kwargs): + pass diff --git a/src/storagecache/azext_storagecache/tests/latest/test_storagecache_scenario.py b/src/storagecache/azext_storagecache/tests/latest/test_storagecache_scenario.py new file mode 100644 index 00000000000..2260135e5a2 --- /dev/null +++ b/src/storagecache/azext_storagecache/tests/latest/test_storagecache_scenario.py @@ -0,0 +1,244 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import os +import unittest + +from azure_devtools.scenario_tests import AllowLargeResponse +from azure.cli.testsdk import ScenarioTest +from .. import try_manual +from azure.cli.testsdk import ResourceGroupPreparer +from .preparers import VirtualNetworkPreparer + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +@try_manual +def setup(test, rg): + pass + + +# EXAMPLE: /AscOperations/get/AscOperations_Get +@try_manual +def step__ascoperations_get_ascoperations_get(test, rg): + test.cmd('az storagecache asc-operation show ' + '--operation-id "testoperationid" ' + '--location "West US"', + checks=[]) + + +# EXAMPLE: /Caches/put/Caches_CreateOrUpdate +@try_manual +def step__caches_put_caches_createorupdate(test, rg): + test.cmd('az storagecache cache create ' + '--location "westus" ' + '--cache-size-gb 3072 ' + '--subnet "/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.Network/virtualNetwork' + 's/{vn}/subnets/default" ' + '--sku name="Standard_2G" ' + '--tags "{{\\"Dept\\":\\"Initech\\"}}" ' + '--cache-name "sc1" ' + '--resource-group "{rg}"', + checks=[]) + test.cmd('az storagecache cache wait --created ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Caches/get/Caches_Get +@try_manual +def step__caches_get_caches_get(test, rg): + test.cmd('az storagecache cache show ' + '--cache-name "sc1" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Caches/get/Caches_List +@try_manual +def step__caches_get_caches_list(test, rg): + test.cmd('az storagecache cache list', + checks=[]) + + +# EXAMPLE: /Caches/get/Caches_ListByResourceGroup +@try_manual +def step__caches_get_caches_listbyresourcegroup(test, rg): + test.cmd('az storagecache cache list ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Caches/post/Caches_Flush +@try_manual +def step__caches_post_caches_flush(test, rg): + test.cmd('az storagecache cache flush ' + '--cache-name "sc" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Caches/post/Caches_Start +@try_manual +def step__caches_post_caches_start(test, rg): + test.cmd('az storagecache cache start ' + '--cache-name "sc" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Caches/post/Caches_Stop +@try_manual +def step__caches_post_caches_stop(test, rg): + test.cmd('az storagecache cache stop ' + '--cache-name "sc" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Caches/post/Caches_UpgradeFirmware +@try_manual +def step__caches_post_caches_upgradefirmware(test, rg): + test.cmd('az storagecache cache upgrade-firmware ' + '--cache-name "sc1" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Caches/patch/Caches_Update +@try_manual +def step__caches_patch_caches_update(test, rg): + test.cmd('az storagecache cache update ' + '--location "westus" ' + '--cache-size-gb 3072 ' + '--subnet "/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.Network/virtualNetwork' + 's/{vn}/subnets/default" ' + '--sku name="Standard_2G" ' + '--tags "{{\\"Dept\\":\\"Initech\\"}}" ' + '--cache-name "sc1" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Skus/get/Skus_List +@try_manual +def step__skus_get_skus_list(test, rg): + test.cmd('az storagecache sku list', + checks=[]) + + +# EXAMPLE: /StorageTargets/put/StorageTargets_CreateOrUpdate +@try_manual +def step__storagetargets_put_storagetargets_createorupdate(test, rg): + test.cmd('az storagecache storage-target create ' + '--cache-name "sc1" ' + '--resource-group "{rg}" ' + '--storage-target-name "{st1}" ' + '--junctions namespace-path="/path/on/cache" nfs-export="exp1" target-path="/path/on/exp1" ' + '--junctions namespace-path="/path2/on/cache" nfs-export="exp2" target-path="/path2/on/exp2" ' + '--nfs3 target="10.0.44.44" usage-model="READ_HEAVY_INFREQ" ' + '--target-type "nfs3"', + checks=[]) + test.cmd('az storagecache storage-target wait --created ' + '--resource-group "{rg}" ' + '--storage-target-name "{st1}"', + checks=[]) + + +# EXAMPLE: /StorageTargets/get/StorageTargets_Get +@try_manual +def step__storagetargets_get_storagetargets_get(test, rg): + test.cmd('az storagecache storage-target show ' + '--cache-name "sc1" ' + '--resource-group "{rg}" ' + '--storage-target-name "{st1}"', + checks=[]) + + +# EXAMPLE: /StorageTargets/get/StorageTargets_List +@try_manual +def step__storagetargets_get_storagetargets_list(test, rg): + test.cmd('az storagecache storage-target list ' + '--cache-name "sc1" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /UsageModels/get/UsageModels_List +@try_manual +def step__usagemodels_get_usagemodels_list(test, rg): + test.cmd('az storagecache usage-model list', + checks=[]) + + +# EXAMPLE: /Caches/delete/Caches_Delete +@try_manual +def step__caches_delete_caches_delete(test, rg): + test.cmd('az storagecache cache delete ' + '--cache-name "sc" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /StorageTargets/delete/StorageTargets_Delete +@try_manual +def step__storagetargets_delete_storagetargets_delete(test, rg): + test.cmd('az storagecache storage-target delete ' + '--cache-name "sc1" ' + '--resource-group "{rg}" ' + '--storage-target-name "{st1}"', + checks=[]) + + +@try_manual +def cleanup(test, rg): + pass + + +@try_manual +def call_scenario(test, rg): + setup(test, rg) + step__ascoperations_get_ascoperations_get(test, rg) + step__caches_put_caches_createorupdate(test, rg) + step__caches_get_caches_get(test, rg) + step__caches_get_caches_list(test, rg) + step__caches_get_caches_listbyresourcegroup(test, rg) + step__caches_post_caches_flush(test, rg) + step__caches_post_caches_start(test, rg) + step__caches_post_caches_stop(test, rg) + step__caches_post_caches_upgradefirmware(test, rg) + step__caches_patch_caches_update(test, rg) + step__skus_get_skus_list(test, rg) + step__storagetargets_put_storagetargets_createorupdate(test, rg) + step__storagetargets_get_storagetargets_get(test, rg) + step__storagetargets_get_storagetargets_list(test, rg) + step__usagemodels_get_usagemodels_list(test, rg) + step__caches_delete_caches_delete(test, rg) + step__storagetargets_delete_storagetargets_delete(test, rg) + cleanup(test, rg) + + +@try_manual +class StorageCacheManagementClientScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='cliteststoragecache_scgroup'[:7], key='rg', parameter_name='rg') + @VirtualNetworkPreparer(name_prefix='cliteststoragecache_scvnet'[:7], key='vn', resource_group_key='rg') + def test_storagecache(self, rg): + + self.kwargs.update({ + 'subscription_id': self.get_subscription_id() + }) + + self.kwargs.update({ + 'st1': 'st1', + }) + + call_scenario(self, rg) diff --git a/src/storagecache/azext_storagecache/vendored_sdks/__init__.py b/src/storagecache/azext_storagecache/vendored_sdks/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/__init__.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/__init__.py new file mode 100644 index 00000000000..dd29ace6add --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._storage_cache_management_client import StorageCacheManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['StorageCacheManagementClient'] + +try: + from .patch import patch_sdk + patch_sdk() +except ImportError: + pass diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/_configuration.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/_configuration.py new file mode 100644 index 00000000000..59bbdcf64ad --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class StorageCacheManagementClientConfiguration(Configuration): + """Configuration for StorageCacheManagementClient. + + 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: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :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(StorageCacheManagementClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-03-01" + self.credential_scopes = ['https://management.azure.com/.default'] + kwargs.setdefault('sdk_moniker', 'mgmt-storagecache/{}'.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.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/_storage_cache_management_client.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/_storage_cache_management_client.py new file mode 100644 index 00000000000..3bc17d48f02 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/_storage_cache_management_client.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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 ._configuration import StorageCacheManagementClientConfiguration +from .operations import OperationOperations +from .operations import SkuOperations +from .operations import UsageModelOperations +from .operations import AscOperationOperations +from .operations import CacheOperations +from .operations import StorageTargetOperations +from . import models + + +class StorageCacheManagementClient(object): + """A Storage Cache provides scalable caching service for NAS clients, serving data from either NFSv3 or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage Caches. + + :ivar operation: OperationOperations operations + :vartype operation: azure.mgmt.storagecache.operations.OperationOperations + :ivar sku: SkuOperations operations + :vartype sku: azure.mgmt.storagecache.operations.SkuOperations + :ivar usage_model: UsageModelOperations operations + :vartype usage_model: azure.mgmt.storagecache.operations.UsageModelOperations + :ivar asc_operation: AscOperationOperations operations + :vartype asc_operation: azure.mgmt.storagecache.operations.AscOperationOperations + :ivar cache: CacheOperations operations + :vartype cache: azure.mgmt.storagecache.operations.CacheOperations + :ivar storage_target: StorageTargetOperations operations + :vartype storage_target: azure.mgmt.storagecache.operations.StorageTargetOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :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 = StorageCacheManagementClientConfiguration(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.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.sku = SkuOperations( + self._client, self._config, self._serialize, self._deserialize) + self.usage_model = UsageModelOperations( + self._client, self._config, self._serialize, self._deserialize) + self.asc_operation = AscOperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.cache = CacheOperations( + self._client, self._config, self._serialize, self._deserialize) + self.storage_target = StorageTargetOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> StorageCacheManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/_version.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/_version.py new file mode 100644 index 00000000000..eae7c95b6fb --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/__init__.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/__init__.py new file mode 100644 index 00000000000..10668c3c519 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._storage_cache_management_client_async import StorageCacheManagementClient +__all__ = ['StorageCacheManagementClient'] diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/_configuration_async.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/_configuration_async.py new file mode 100644 index 00000000000..6554f769edf --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class StorageCacheManagementClientConfiguration(Configuration): + """Configuration for StorageCacheManagementClient. + + 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: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :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(StorageCacheManagementClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-03-01" + self.credential_scopes = ['https://management.azure.com/.default'] + kwargs.setdefault('sdk_moniker', 'mgmt-storagecache/{}'.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.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/_storage_cache_management_client_async.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/_storage_cache_management_client_async.py new file mode 100644 index 00000000000..7d84be9ced7 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/_storage_cache_management_client_async.py @@ -0,0 +1,83 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import StorageCacheManagementClientConfiguration +from .operations_async import OperationOperations +from .operations_async import SkuOperations +from .operations_async import UsageModelOperations +from .operations_async import AscOperationOperations +from .operations_async import CacheOperations +from .operations_async import StorageTargetOperations +from .. import models + + +class StorageCacheManagementClient(object): + """A Storage Cache provides scalable caching service for NAS clients, serving data from either NFSv3 or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage Caches. + + :ivar operation: OperationOperations operations + :vartype operation: azure.mgmt.storagecache.aio.operations_async.OperationOperations + :ivar sku: SkuOperations operations + :vartype sku: azure.mgmt.storagecache.aio.operations_async.SkuOperations + :ivar usage_model: UsageModelOperations operations + :vartype usage_model: azure.mgmt.storagecache.aio.operations_async.UsageModelOperations + :ivar asc_operation: AscOperationOperations operations + :vartype asc_operation: azure.mgmt.storagecache.aio.operations_async.AscOperationOperations + :ivar cache: CacheOperations operations + :vartype cache: azure.mgmt.storagecache.aio.operations_async.CacheOperations + :ivar storage_target: StorageTargetOperations operations + :vartype storage_target: azure.mgmt.storagecache.aio.operations_async.StorageTargetOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :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 = StorageCacheManagementClientConfiguration(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.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.sku = SkuOperations( + self._client, self._config, self._serialize, self._deserialize) + self.usage_model = UsageModelOperations( + self._client, self._config, self._serialize, self._deserialize) + self.asc_operation = AscOperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.cache = CacheOperations( + self._client, self._config, self._serialize, self._deserialize) + self.storage_target = StorageTargetOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "StorageCacheManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/__init__.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/__init__.py new file mode 100644 index 00000000000..e193101b9b8 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/__init__.py @@ -0,0 +1,23 @@ +# 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 ._operation_operations_async import OperationOperations +from ._sku_operations_async import SkuOperations +from ._usage_model_operations_async import UsageModelOperations +from ._asc_operation_operations_async import AscOperationOperations +from ._cache_operations_async import CacheOperations +from ._storage_target_operations_async import StorageTargetOperations + +__all__ = [ + 'OperationOperations', + 'SkuOperations', + 'UsageModelOperations', + 'AscOperationOperations', + 'CacheOperations', + 'StorageTargetOperations', +] diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_asc_operation_operations_async.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_asc_operation_operations_async.py new file mode 100644 index 00000000000..04671604670 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_asc_operation_operations_async.py @@ -0,0 +1,96 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import 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 + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AscOperationOperations: + """AscOperationOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.storagecache.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + location: str, + operation_id: str, + **kwargs + ) -> "models.AscOperation": + """Gets the status of an asynchronous operation for the Azure HPC cache. + + :param location: The region name which the operation will lookup into. + :type location: str + :param operation_id: The operation id which uniquely identifies the asynchronous operation. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AscOperation or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.AscOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AscOperation"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'operationId': self._serialize.url("operation_id", operation_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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('AscOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/locations/{location}/ascOperations/{operationId}'} diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_cache_operations_async.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_cache_operations_async.py new file mode 100644 index 00000000000..703c9c6566a --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_cache_operations_async.py @@ -0,0 +1,993 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CacheOperations: + """CacheOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.storagecache.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 + ) -> "models.CachesListResult": + """Returns all Caches the user has access to under a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CachesListResult or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.CachesListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CachesListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + 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) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('CachesListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/caches'} + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> "models.CachesListResult": + """Returns all Caches the user has access to under a resource group. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CachesListResult or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.CachesListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CachesListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('CachesListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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.StorageCache/caches'} + + async def _delete_initial( + self, + resource_group_name: str, + cache_name: str, + **kwargs + ) -> object: + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self._delete_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + '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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} + + async def delete( + self, + resource_group_name: str, + cache_name: str, + **kwargs + ) -> object: + """Schedules a Cache for deletion. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :return: An instance of LROPoller that returns + :rtype: ~azure.core.polling.LROPoller[object] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[object] + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} + + async def get( + self, + resource_group_name: str, + cache_name: str, + **kwargs + ) -> "models.Cache": + """Returns a Cache. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cache or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.Cache + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Cache"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + '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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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('Cache', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} + + async def _create_or_update_initial( + self, + resource_group_name: str, + cache_name: str, + tags: Optional[object] = None, + location: Optional[str] = None, + identity: Optional["models.CacheIdentity"] = None, + sku: Optional["models.CacheSku"] = None, + cache_size_gb: Optional[int] = None, + provisioning_state: Optional[Union[str, "models.ProvisioningStateType"]] = None, + subnet: Optional[str] = None, + upgrade_status: Optional["models.CacheUpgradeStatus"] = None, + network_settings: Optional["models.CacheNetworkSettings"] = None, + encryption_settings: Optional["models.CacheEncryptionSettings"] = None, + security_settings: Optional["models.CacheSecuritySettings"] = None, + **kwargs + ) -> "models.Cache": + cls = kwargs.pop('cls', None) # type: ClsType["models.Cache"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _cache = models.Cache(tags=tags, location=location, identity=identity, sku=sku, cache_size_gb=cache_size_gb, provisioning_state=provisioning_state, subnet=subnet, upgrade_status=upgrade_status, network_settings=network_settings, encryption_settings=encryption_settings, security_settings=security_settings) + api_version = "2020-03-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_or_update_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + if _cache is not None: + body_content = self._serialize.body(_cache, 'Cache') + 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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Cache', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Cache', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} + + async def create_or_update( + self, + resource_group_name: str, + cache_name: str, + tags: Optional[object] = None, + location: Optional[str] = None, + identity: Optional["models.CacheIdentity"] = None, + sku: Optional["models.CacheSku"] = None, + cache_size_gb: Optional[int] = None, + provisioning_state: Optional[Union[str, "models.ProvisioningStateType"]] = None, + subnet: Optional[str] = None, + upgrade_status: Optional["models.CacheUpgradeStatus"] = None, + network_settings: Optional["models.CacheNetworkSettings"] = None, + encryption_settings: Optional["models.CacheEncryptionSettings"] = None, + security_settings: Optional["models.CacheSecuritySettings"] = None, + **kwargs + ) -> "models.Cache": + """Create or update a Cache. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :param tags: ARM tags as name/value pairs. + :type tags: object + :param location: Region name string. + :type location: str + :param identity: The identity of the cache, if configured. + :type identity: ~azure.mgmt.storagecache.models.CacheIdentity + :param sku: SKU for the Cache. + :type sku: ~azure.mgmt.storagecache.models.CacheSku + :param cache_size_gb: The size of this Cache, in GB. + :type cache_size_gb: int + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param subnet: Subnet used for the Cache. + :type subnet: str + :param upgrade_status: Upgrade status of the Cache. + :type upgrade_status: ~azure.mgmt.storagecache.models.CacheUpgradeStatus + :param network_settings: Specifies network settings of the cache. + :type network_settings: ~azure.mgmt.storagecache.models.CacheNetworkSettings + :param encryption_settings: Specifies encryption settings of the cache. + :type encryption_settings: ~azure.mgmt.storagecache.models.CacheEncryptionSettings + :param security_settings: Specifies security settings of the cache. + :type security_settings: ~azure.mgmt.storagecache.models.CacheSecuritySettings + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :return: An instance of LROPoller that returns Cache + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storagecache.models.Cache] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.Cache"] + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + tags=tags, + location=location, + identity=identity, + sku=sku, + cache_size_gb=cache_size_gb, + provisioning_state=provisioning_state, + subnet=subnet, + upgrade_status=upgrade_status, + network_settings=network_settings, + encryption_settings=encryption_settings, + security_settings=security_settings, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Cache', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} + + async def update( + self, + resource_group_name: str, + cache_name: str, + tags: Optional[object] = None, + location: Optional[str] = None, + identity: Optional["models.CacheIdentity"] = None, + sku: Optional["models.CacheSku"] = None, + cache_size_gb: Optional[int] = None, + provisioning_state: Optional[Union[str, "models.ProvisioningStateType"]] = None, + subnet: Optional[str] = None, + upgrade_status: Optional["models.CacheUpgradeStatus"] = None, + network_settings: Optional["models.CacheNetworkSettings"] = None, + encryption_settings: Optional["models.CacheEncryptionSettings"] = None, + security_settings: Optional["models.CacheSecuritySettings"] = None, + **kwargs + ) -> "models.Cache": + """Update a Cache instance. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :param tags: ARM tags as name/value pairs. + :type tags: object + :param location: Region name string. + :type location: str + :param identity: The identity of the cache, if configured. + :type identity: ~azure.mgmt.storagecache.models.CacheIdentity + :param sku: SKU for the Cache. + :type sku: ~azure.mgmt.storagecache.models.CacheSku + :param cache_size_gb: The size of this Cache, in GB. + :type cache_size_gb: int + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param subnet: Subnet used for the Cache. + :type subnet: str + :param upgrade_status: Upgrade status of the Cache. + :type upgrade_status: ~azure.mgmt.storagecache.models.CacheUpgradeStatus + :param network_settings: Specifies network settings of the cache. + :type network_settings: ~azure.mgmt.storagecache.models.CacheNetworkSettings + :param encryption_settings: Specifies encryption settings of the cache. + :type encryption_settings: ~azure.mgmt.storagecache.models.CacheEncryptionSettings + :param security_settings: Specifies security settings of the cache. + :type security_settings: ~azure.mgmt.storagecache.models.CacheSecuritySettings + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cache or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.Cache + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Cache"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _cache = models.Cache(tags=tags, location=location, identity=identity, sku=sku, cache_size_gb=cache_size_gb, provisioning_state=provisioning_state, subnet=subnet, upgrade_status=upgrade_status, network_settings=network_settings, encryption_settings=encryption_settings, security_settings=security_settings) + api_version = "2020-03-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + if _cache is not None: + body_content = self._serialize.body(_cache, 'Cache') + 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('Cache', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} + + async def _flush_initial( + self, + resource_group_name: str, + cache_name: str, + **kwargs + ) -> object: + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self._flush_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + request = self._client.post(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _flush_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/flush'} + + async def flush( + self, + resource_group_name: str, + cache_name: str, + **kwargs + ) -> object: + """Tells a Cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors returned until the flush is complete. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :return: An instance of LROPoller that returns + :rtype: ~azure.core.polling.LROPoller[object] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[object] + raw_result = await self._flush_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + flush.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/flush'} + + async def _start_initial( + self, + resource_group_name: str, + cache_name: str, + **kwargs + ) -> object: + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self._start_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + request = self._client.post(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/start'} + + async def start( + self, + resource_group_name: str, + cache_name: str, + **kwargs + ) -> object: + """Tells a Stopped state Cache to transition to Active state. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :return: An instance of LROPoller that returns + :rtype: ~azure.core.polling.LROPoller[object] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[object] + raw_result = await self._start_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + start.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/start'} + + async def _stop_initial( + self, + resource_group_name: str, + cache_name: str, + **kwargs + ) -> object: + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self._stop_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + request = self._client.post(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stop'} + + async def stop( + self, + resource_group_name: str, + cache_name: str, + **kwargs + ) -> object: + """Tells an Active Cache to transition to Stopped state. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :return: An instance of LROPoller that returns + :rtype: ~azure.core.polling.LROPoller[object] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[object] + raw_result = await self._stop_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stop'} + + async def _upgrade_firmware_initial( + self, + resource_group_name: str, + cache_name: str, + **kwargs + ) -> object: + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self._upgrade_firmware_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 201: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _upgrade_firmware_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/upgrade'} + + async def upgrade_firmware( + self, + resource_group_name: str, + cache_name: str, + **kwargs + ) -> object: + """Upgrade a Cache's firmware if a new version is available. Otherwise, this operation has no effect. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :return: An instance of LROPoller that returns + :rtype: ~azure.core.polling.LROPoller[object] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[object] + raw_result = await self._upgrade_firmware_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + upgrade_firmware.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/upgrade'} diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_operation_operations_async.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_operation_operations_async.py new file mode 100644 index 00000000000..ceb66ea0f05 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_operation_operations_async.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations: + """OperationOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.storagecache.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 + ) -> "models.ApiOperationListResult": + """Lists all of the available Resource Provider operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiOperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.ApiOperationListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiOperationListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ApiOperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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.StorageCache/operations'} diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_sku_operations_async.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_sku_operations_async.py new file mode 100644 index 00000000000..1ab857a1ba3 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_sku_operations_async.py @@ -0,0 +1,104 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SkuOperations: + """SkuOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.storagecache.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 + ) -> "models.ResourceSkusResult": + """Get the list of StorageCache.Cache SKUs available to this subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceSkusResult or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.ResourceSkusResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceSkusResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + 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) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceSkusResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/skus'} diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_storage_target_operations_async.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_storage_target_operations_async.py new file mode 100644 index 00000000000..5814bd3d62b --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_storage_target_operations_async.py @@ -0,0 +1,433 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class StorageTargetOperations: + """StorageTargetOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.storagecache.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_by_cache( + self, + resource_group_name: str, + cache_name: str, + **kwargs + ) -> "models.StorageTargetsResult": + """Returns a list of Storage Targets for the specified Cache. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageTargetsResult or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.StorageTargetsResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.StorageTargetsResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_cache.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('StorageTargetsResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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_cache.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets'} + + async def _delete_initial( + self, + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs + ) -> object: + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self._delete_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + 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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} + + async def delete( + self, + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs + ) -> object: + """Removes a Storage Target from a Cache. This operation is allowed at any time, but if the Cache is down or unhealthy, the actual removal of the Storage Target may be delayed until the Cache is healthy again. Note that if the Cache has data to flush to the Storage Target, the data will be flushed before the Storage Target will be deleted. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :param storage_target_name: Name of Storage Target. + :type storage_target_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :return: An instance of LROPoller that returns + :rtype: ~azure.core.polling.LROPoller[object] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[object] + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + storage_target_name=storage_target_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} + + async def get( + self, + resource_group_name: str, + cache_name: str, + storage_target_name: str, + **kwargs + ) -> "models.StorageTarget": + """Returns a Storage Target from a Cache. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :param storage_target_name: Name of the Storage Target. Length of name must be not greater than + 80 and chars must be in list of [-0-9a-zA-Z_] char class. + :type storage_target_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageTarget or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.StorageTarget + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.StorageTarget"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + 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('StorageTarget', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} + + async def _create_or_update_initial( + self, + resource_group_name: str, + cache_name: str, + storage_target_name: str, + target_base_type: Optional[Union[str, "models.StorageTargetType"]] = None, + junctions: Optional[List["NamespaceJunction"]] = None, + target_type: Optional[str] = None, + provisioning_state: Optional[Union[str, "models.ProvisioningStateType"]] = None, + nfs3: Optional["models.Nfs3Target"] = None, + clfs: Optional["models.ClfsTarget"] = None, + unknown: Optional["models.UnknownTarget"] = None, + **kwargs + ) -> "models.StorageTarget": + cls = kwargs.pop('cls', None) # type: ClsType["models.StorageTarget"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _storagetarget = models.StorageTarget(target_base_type=target_base_type, junctions=junctions, target_type=target_type, provisioning_state=provisioning_state, nfs3=nfs3, clfs=clfs, unknown=unknown) + api_version = "2020-03-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_or_update_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + if _storagetarget is not None: + body_content = self._serialize.body(_storagetarget, 'StorageTarget') + 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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('StorageTarget', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('StorageTarget', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} + + async def create_or_update( + self, + resource_group_name: str, + cache_name: str, + storage_target_name: str, + target_base_type: Optional[Union[str, "models.StorageTargetType"]] = None, + junctions: Optional[List["NamespaceJunction"]] = None, + target_type: Optional[str] = None, + provisioning_state: Optional[Union[str, "models.ProvisioningStateType"]] = None, + nfs3: Optional["models.Nfs3Target"] = None, + clfs: Optional["models.ClfsTarget"] = None, + unknown: Optional["models.UnknownTarget"] = None, + **kwargs + ) -> "models.StorageTarget": + """Create or update a Storage Target. This operation is allowed at any time, but if the Cache is down or unhealthy, the actual creation/modification of the Storage Target may be delayed until the Cache is healthy again. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :param storage_target_name: Name of the Storage Target. Length of name must be not greater than + 80 and chars must be in list of [-0-9a-zA-Z_] char class. + :type storage_target_name: str + :param target_base_type: Type of the Storage Target. + :type target_base_type: str or ~azure.mgmt.storagecache.models.StorageTargetType + :param junctions: List of Cache namespace junctions to target for namespace associations. + :type junctions: list[~azure.mgmt.storagecache.models.NamespaceJunction] + :param target_type: Type of the Storage Target. + :type target_type: str + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param nfs3: Properties when targetType is nfs3. + :type nfs3: ~azure.mgmt.storagecache.models.Nfs3Target + :param clfs: Properties when targetType is clfs. + :type clfs: ~azure.mgmt.storagecache.models.ClfsTarget + :param unknown: Properties when targetType is unknown. + :type unknown: ~azure.mgmt.storagecache.models.UnknownTarget + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :return: An instance of LROPoller that returns StorageTarget + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storagecache.models.StorageTarget] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.StorageTarget"] + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + storage_target_name=storage_target_name, + target_base_type=target_base_type, + junctions=junctions, + target_type=target_type, + provisioning_state=provisioning_state, + nfs3=nfs3, + clfs=clfs, + unknown=unknown, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('StorageTarget', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_usage_model_operations_async.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_usage_model_operations_async.py new file mode 100644 index 00000000000..a5a0ec08c9e --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/aio/operations_async/_usage_model_operations_async.py @@ -0,0 +1,104 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import 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 + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class UsageModelOperations: + """UsageModelOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.storagecache.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 + ) -> "models.UsageModelsResult": + """Get the list of Cache Usage Models available to this subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UsageModelsResult or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.UsageModelsResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UsageModelsResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + 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) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('UsageModelsResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/usageModels'} diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/models/__init__.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/models/__init__.py new file mode 100644 index 00000000000..fb7fee6ff7b --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/models/__init__.py @@ -0,0 +1,136 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import ApiOperation + from ._models_py3 import ApiOperationDisplay + from ._models_py3 import ApiOperationListResult + from ._models_py3 import AscOperation + from ._models_py3 import Cache + from ._models_py3 import CacheEncryptionSettings + from ._models_py3 import CacheHealth + from ._models_py3 import CacheIdentity + from ._models_py3 import CacheNetworkSettings + from ._models_py3 import CacheSecuritySettings + from ._models_py3 import CacheSku + from ._models_py3 import CacheUpgradeStatus + from ._models_py3 import CachesListResult + from ._models_py3 import ClfsTarget + from ._models_py3 import ClfsTargetProperties + from ._models_py3 import CloudErrorBody + from ._models_py3 import ErrorResponse + from ._models_py3 import KeyVaultKeyReference + from ._models_py3 import KeyVaultKeyReferenceSourceVault + from ._models_py3 import NamespaceJunction + from ._models_py3 import Nfs3Target + from ._models_py3 import Nfs3TargetProperties + from ._models_py3 import ResourceSku + from ._models_py3 import ResourceSkuCapabilities + from ._models_py3 import ResourceSkuLocationInfo + from ._models_py3 import ResourceSkusResult + from ._models_py3 import Restriction + from ._models_py3 import StorageTarget + from ._models_py3 import StorageTargetProperties + from ._models_py3 import StorageTargetResource + from ._models_py3 import StorageTargetsResult + from ._models_py3 import UnknownTarget + from ._models_py3 import UnknownTargetProperties + from ._models_py3 import UsageModel + from ._models_py3 import UsageModelDisplay + from ._models_py3 import UsageModelsResult +except (SyntaxError, ImportError): + from ._models import ApiOperation # type: ignore + from ._models import ApiOperationDisplay # type: ignore + from ._models import ApiOperationListResult # type: ignore + from ._models import AscOperation # type: ignore + from ._models import Cache # type: ignore + from ._models import CacheEncryptionSettings # type: ignore + from ._models import CacheHealth # type: ignore + from ._models import CacheIdentity # type: ignore + from ._models import CacheNetworkSettings # type: ignore + from ._models import CacheSecuritySettings # type: ignore + from ._models import CacheSku # type: ignore + from ._models import CacheUpgradeStatus # type: ignore + from ._models import CachesListResult # type: ignore + from ._models import ClfsTarget # type: ignore + from ._models import ClfsTargetProperties # type: ignore + from ._models import CloudErrorBody # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import KeyVaultKeyReference # type: ignore + from ._models import KeyVaultKeyReferenceSourceVault # type: ignore + from ._models import NamespaceJunction # type: ignore + from ._models import Nfs3Target # type: ignore + from ._models import Nfs3TargetProperties # type: ignore + from ._models import ResourceSku # type: ignore + from ._models import ResourceSkuCapabilities # type: ignore + from ._models import ResourceSkuLocationInfo # type: ignore + from ._models import ResourceSkusResult # type: ignore + from ._models import Restriction # type: ignore + from ._models import StorageTarget # type: ignore + from ._models import StorageTargetProperties # type: ignore + from ._models import StorageTargetResource # type: ignore + from ._models import StorageTargetsResult # type: ignore + from ._models import UnknownTarget # type: ignore + from ._models import UnknownTargetProperties # type: ignore + from ._models import UsageModel # type: ignore + from ._models import UsageModelDisplay # type: ignore + from ._models import UsageModelsResult # type: ignore + +from ._storage_cache_management_client_enums import ( + CacheIdentityType, + FirmwareStatusType, + HealthStateType, + ProvisioningStateType, + ReasonCode, + StorageTargetType, +) + +__all__ = [ + 'ApiOperation', + 'ApiOperationDisplay', + 'ApiOperationListResult', + 'AscOperation', + 'Cache', + 'CacheEncryptionSettings', + 'CacheHealth', + 'CacheIdentity', + 'CacheNetworkSettings', + 'CacheSecuritySettings', + 'CacheSku', + 'CacheUpgradeStatus', + 'CachesListResult', + 'ClfsTarget', + 'ClfsTargetProperties', + 'CloudErrorBody', + 'ErrorResponse', + 'KeyVaultKeyReference', + 'KeyVaultKeyReferenceSourceVault', + 'NamespaceJunction', + 'Nfs3Target', + 'Nfs3TargetProperties', + 'ResourceSku', + 'ResourceSkuCapabilities', + 'ResourceSkuLocationInfo', + 'ResourceSkusResult', + 'Restriction', + 'StorageTarget', + 'StorageTargetProperties', + 'StorageTargetResource', + 'StorageTargetsResult', + 'UnknownTarget', + 'UnknownTargetProperties', + 'UsageModel', + 'UsageModelDisplay', + 'UsageModelsResult', + 'CacheIdentityType', + 'FirmwareStatusType', + 'HealthStateType', + 'ProvisioningStateType', + 'ReasonCode', + 'StorageTargetType', +] diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/models/_models.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/models/_models.py new file mode 100644 index 00000000000..16f9856f4cf --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/models/_models.py @@ -0,0 +1,1183 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import msrest.serialization + + +class ApiOperation(msrest.serialization.Model): + """REST API operation description: see https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/openapi-authoring-automated-guidelines.md#r3023-operationsapiimplementation. + + :param display: The object that represents the operation. + :type display: ~azure.mgmt.storagecache.models.ApiOperationDisplay + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + """ + + _attribute_map = { + 'display': {'key': 'display', 'type': 'ApiOperationDisplay'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiOperation, self).__init__(**kwargs) + self.display = kwargs.get('display', None) + self.name = kwargs.get('name', None) + + +class ApiOperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :param operation: Operation type: Read, write, delete, etc. + :type operation: str + :param provider: Service provider: Microsoft.StorageCache. + :type provider: str + :param resource: Resource on which the operation is performed: Cache, etc. + :type resource: str + """ + + _attribute_map = { + 'operation': {'key': 'operation', 'type': 'str'}, + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiOperationDisplay, self).__init__(**kwargs) + self.operation = kwargs.get('operation', None) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + + +class ApiOperationListResult(msrest.serialization.Model): + """Result of the request to list Resource Provider operations. It contains a list of operations and a URL link to get the next set of results. + + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + :param value: List of Resource Provider operations supported by the Microsoft.StorageCache + resource provider. + :type value: list[~azure.mgmt.storagecache.models.ApiOperation] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[ApiOperation]'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiOperationListResult, self).__init__(**kwargs) + self.next_link = kwargs.get('next_link', None) + self.value = kwargs.get('value', None) + + +class AscOperation(msrest.serialization.Model): + """The status of operation. + + :param id: The operation Id. + :type id: str + :param name: The operation name. + :type name: str + :param start_time: The start time of the operation. + :type start_time: str + :param end_time: The end time of the operation. + :type end_time: str + :param status: The status of the operation. + :type status: str + :param error: The error detail of the operation if any. + :type error: ~azure.mgmt.storagecache.models.ErrorResponse + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'str'}, + 'end_time': {'key': 'endTime', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__( + self, + **kwargs + ): + super(AscOperation, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.name = kwargs.get('name', None) + self.start_time = kwargs.get('start_time', None) + self.end_time = kwargs.get('end_time', None) + self.status = kwargs.get('status', None) + self.error = kwargs.get('error', None) + + +class Cache(msrest.serialization.Model): + """A Cache instance. Follows Azure Resource Manager standards: https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/resource-api-reference.md. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param tags: A set of tags. ARM tags as name/value pairs. + :type tags: object + :ivar id: Resource ID of the Cache. + :vartype id: str + :param location: Region name string. + :type location: str + :ivar name: Name of Cache. + :vartype name: str + :ivar type: Type of the Cache; Microsoft.StorageCache/Cache. + :vartype type: str + :param identity: The identity of the cache, if configured. + :type identity: ~azure.mgmt.storagecache.models.CacheIdentity + :param sku: SKU for the Cache. + :type sku: ~azure.mgmt.storagecache.models.CacheSku + :param cache_size_gb: The size of this Cache, in GB. + :type cache_size_gb: int + :ivar health: Health of the Cache. + :vartype health: ~azure.mgmt.storagecache.models.CacheHealth + :ivar mount_addresses: Array of IP addresses that can be used by clients mounting this Cache. + :vartype mount_addresses: list[str] + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: + "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", "Updating". + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param subnet: Subnet used for the Cache. + :type subnet: str + :param upgrade_status: Upgrade status of the Cache. + :type upgrade_status: ~azure.mgmt.storagecache.models.CacheUpgradeStatus + :param network_settings: Specifies network settings of the cache. + :type network_settings: ~azure.mgmt.storagecache.models.CacheNetworkSettings + :param encryption_settings: Specifies encryption settings of the cache. + :type encryption_settings: ~azure.mgmt.storagecache.models.CacheEncryptionSettings + :param security_settings: Specifies security settings of the cache. + :type security_settings: ~azure.mgmt.storagecache.models.CacheSecuritySettings + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True, 'pattern': r'^[-0-9a-zA-Z_]{1,80}$'}, + 'type': {'readonly': True}, + 'health': {'readonly': True}, + 'mount_addresses': {'readonly': True}, + } + + _attribute_map = { + 'tags': {'key': 'tags', 'type': 'object'}, + 'id': {'key': 'id', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'CacheIdentity'}, + 'sku': {'key': 'sku', 'type': 'CacheSku'}, + 'cache_size_gb': {'key': 'properties.cacheSizeGB', 'type': 'int'}, + 'health': {'key': 'properties.health', 'type': 'CacheHealth'}, + 'mount_addresses': {'key': 'properties.mountAddresses', 'type': '[str]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'subnet': {'key': 'properties.subnet', 'type': 'str'}, + 'upgrade_status': {'key': 'properties.upgradeStatus', 'type': 'CacheUpgradeStatus'}, + 'network_settings': {'key': 'properties.networkSettings', 'type': 'CacheNetworkSettings'}, + 'encryption_settings': {'key': 'properties.encryptionSettings', 'type': 'CacheEncryptionSettings'}, + 'security_settings': {'key': 'properties.securitySettings', 'type': 'CacheSecuritySettings'}, + } + + def __init__( + self, + **kwargs + ): + super(Cache, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.id = None + self.location = kwargs.get('location', None) + self.name = None + self.type = None + self.identity = kwargs.get('identity', None) + self.sku = kwargs.get('sku', None) + self.cache_size_gb = kwargs.get('cache_size_gb', None) + self.health = None + self.mount_addresses = None + self.provisioning_state = kwargs.get('provisioning_state', None) + self.subnet = kwargs.get('subnet', None) + self.upgrade_status = kwargs.get('upgrade_status', None) + self.network_settings = kwargs.get('network_settings', None) + self.encryption_settings = kwargs.get('encryption_settings', None) + self.security_settings = kwargs.get('security_settings', None) + + +class CacheEncryptionSettings(msrest.serialization.Model): + """Cache encryption settings. + + :param key_encryption_key: Specifies the location of the key encryption key in Key Vault. + :type key_encryption_key: ~azure.mgmt.storagecache.models.KeyVaultKeyReference + """ + + _attribute_map = { + 'key_encryption_key': {'key': 'keyEncryptionKey', 'type': 'KeyVaultKeyReference'}, + } + + def __init__( + self, + **kwargs + ): + super(CacheEncryptionSettings, self).__init__(**kwargs) + self.key_encryption_key = kwargs.get('key_encryption_key', None) + + +class CacheHealth(msrest.serialization.Model): + """An indication of Cache health. Gives more information about health than just that related to provisioning. + + :param state: List of Cache health states. Possible values include: "Unknown", "Healthy", + "Degraded", "Down", "Transitioning", "Stopping", "Stopped", "Upgrading", "Flushing". + :type state: str or ~azure.mgmt.storagecache.models.HealthStateType + :param status_description: Describes explanation of state. + :type status_description: str + """ + + _attribute_map = { + 'state': {'key': 'state', 'type': 'str'}, + 'status_description': {'key': 'statusDescription', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CacheHealth, self).__init__(**kwargs) + self.state = kwargs.get('state', None) + self.status_description = kwargs.get('status_description', None) + + +class CacheIdentity(msrest.serialization.Model): + """Cache identity properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of the cache. + :vartype principal_id: str + :ivar tenant_id: The tenant id associated with the cache. + :vartype tenant_id: str + :param type: The type of identity used for the cache. Possible values include: + "SystemAssigned", "None". + :type type: str or ~azure.mgmt.storagecache.models.CacheIdentityType + """ + + _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, + **kwargs + ): + super(CacheIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = kwargs.get('type', None) + + +class CacheNetworkSettings(msrest.serialization.Model): + """Cache network settings. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param mtu: The IPv4 maximum transmission unit configured for the subnet. + :type mtu: int + :ivar utility_addresses: Array of additional IP addresses used by this Cache. + :vartype utility_addresses: list[str] + """ + + _validation = { + 'mtu': {'maximum': 1500, 'minimum': 576}, + 'utility_addresses': {'readonly': True}, + } + + _attribute_map = { + 'mtu': {'key': 'mtu', 'type': 'int'}, + 'utility_addresses': {'key': 'utilityAddresses', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(CacheNetworkSettings, self).__init__(**kwargs) + self.mtu = kwargs.get('mtu', 1500) + self.utility_addresses = None + + +class CacheSecuritySettings(msrest.serialization.Model): + """Cache security settings. + + :param root_squash: root squash of cache property. + :type root_squash: bool + """ + + _attribute_map = { + 'root_squash': {'key': 'rootSquash', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(CacheSecuritySettings, self).__init__(**kwargs) + self.root_squash = kwargs.get('root_squash', None) + + +class CacheSku(msrest.serialization.Model): + """SKU for the Cache. + + :param name: SKU name for this Cache. + :type name: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CacheSku, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + + +class CachesListResult(msrest.serialization.Model): + """Result of the request to list Caches. It contains a list of Caches and a URL link to get the next set of results. + + :param next_link: URL to get the next set of Cache list results, if there are any. + :type next_link: str + :param value: List of Caches. + :type value: list[~azure.mgmt.storagecache.models.Cache] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Cache]'}, + } + + def __init__( + self, + **kwargs + ): + super(CachesListResult, self).__init__(**kwargs) + self.next_link = kwargs.get('next_link', None) + self.value = kwargs.get('value', None) + + +class CacheUpgradeStatus(msrest.serialization.Model): + """Properties describing the software upgrade state of the Cache. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar current_firmware_version: Version string of the firmware currently installed on this + Cache. + :vartype current_firmware_version: str + :ivar firmware_update_status: True if there is a firmware update ready to install on this + Cache. The firmware will automatically be installed after firmwareUpdateDeadline if not + triggered earlier via the upgrade operation. Possible values include: "available", + "unavailable". + :vartype firmware_update_status: str or ~azure.mgmt.storagecache.models.FirmwareStatusType + :ivar firmware_update_deadline: Time at which the pending firmware update will automatically be + installed on the Cache. + :vartype firmware_update_deadline: ~datetime.datetime + :ivar last_firmware_update: Time of the last successful firmware update. + :vartype last_firmware_update: ~datetime.datetime + :ivar pending_firmware_version: When firmwareUpdateAvailable is true, this field holds the + version string for the update. + :vartype pending_firmware_version: str + """ + + _validation = { + 'current_firmware_version': {'readonly': True}, + 'firmware_update_status': {'readonly': True}, + 'firmware_update_deadline': {'readonly': True}, + 'last_firmware_update': {'readonly': True}, + 'pending_firmware_version': {'readonly': True}, + } + + _attribute_map = { + 'current_firmware_version': {'key': 'currentFirmwareVersion', 'type': 'str'}, + 'firmware_update_status': {'key': 'firmwareUpdateStatus', 'type': 'str'}, + 'firmware_update_deadline': {'key': 'firmwareUpdateDeadline', 'type': 'iso-8601'}, + 'last_firmware_update': {'key': 'lastFirmwareUpdate', 'type': 'iso-8601'}, + 'pending_firmware_version': {'key': 'pendingFirmwareVersion', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CacheUpgradeStatus, self).__init__(**kwargs) + self.current_firmware_version = None + self.firmware_update_status = None + self.firmware_update_deadline = None + self.last_firmware_update = None + self.pending_firmware_version = None + + +class ClfsTarget(msrest.serialization.Model): + """Properties pertained to ClfsTarget. + + :param target: Resource ID of storage container. + :type target: str + """ + + _attribute_map = { + 'target': {'key': 'target', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ClfsTarget, self).__init__(**kwargs) + self.target = kwargs.get('target', None) + + +class StorageTargetProperties(msrest.serialization.Model): + """Properties of the Storage Target. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: ClfsTargetProperties, Nfs3TargetProperties, UnknownTargetProperties. + + All required parameters must be populated in order to send to Azure. + + :param target_base_type: Required. Type of the Storage Target.Constant filled by server. + Possible values include: "nfs3", "clfs", "unknown". + :type target_base_type: str or ~azure.mgmt.storagecache.models.StorageTargetType + :param junctions: List of Cache namespace junctions to target for namespace associations. + :type junctions: list[~azure.mgmt.storagecache.models.NamespaceJunction] + :param target_type: Type of the Storage Target. + :type target_type: str + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: + "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", "Updating". + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param nfs3: Properties when targetType is nfs3. + :type nfs3: ~azure.mgmt.storagecache.models.Nfs3Target + :param clfs: Properties when targetType is clfs. + :type clfs: ~azure.mgmt.storagecache.models.ClfsTarget + :param unknown: Properties when targetType is unknown. + :type unknown: ~azure.mgmt.storagecache.models.UnknownTarget + """ + + _validation = { + 'target_base_type': {'required': True}, + } + + _attribute_map = { + 'target_base_type': {'key': 'targetBaseType', 'type': 'str'}, + 'junctions': {'key': 'junctions', 'type': '[NamespaceJunction]'}, + 'target_type': {'key': 'targetType', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'nfs3': {'key': 'nfs3', 'type': 'Nfs3Target'}, + 'clfs': {'key': 'clfs', 'type': 'ClfsTarget'}, + 'unknown': {'key': 'unknown', 'type': 'UnknownTarget'}, + } + + _subtype_map = { + 'target_base_type': {'clfs': 'ClfsTargetProperties', 'nfs3': 'Nfs3TargetProperties', 'unknown': 'UnknownTargetProperties'} + } + + def __init__( + self, + **kwargs + ): + super(StorageTargetProperties, self).__init__(**kwargs) + self.target_base_type = None + self.junctions = kwargs.get('junctions', None) + self.target_type = kwargs.get('target_type', None) + self.provisioning_state = kwargs.get('provisioning_state', None) + self.nfs3 = kwargs.get('nfs3', None) + self.clfs = kwargs.get('clfs', None) + self.unknown = kwargs.get('unknown', None) + + +class ClfsTargetProperties(StorageTargetProperties): + """Storage container for use as a CLFS Storage Target. + + All required parameters must be populated in order to send to Azure. + + :param target_base_type: Required. Type of the Storage Target.Constant filled by server. + Possible values include: "nfs3", "clfs", "unknown". + :type target_base_type: str or ~azure.mgmt.storagecache.models.StorageTargetType + :param junctions: List of Cache namespace junctions to target for namespace associations. + :type junctions: list[~azure.mgmt.storagecache.models.NamespaceJunction] + :param target_type: Type of the Storage Target. + :type target_type: str + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: + "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", "Updating". + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param nfs3: Properties when targetType is nfs3. + :type nfs3: ~azure.mgmt.storagecache.models.Nfs3Target + :param clfs: Properties when targetType is clfs. + :type clfs: ~azure.mgmt.storagecache.models.ClfsTarget + :param unknown: Properties when targetType is unknown. + :type unknown: ~azure.mgmt.storagecache.models.UnknownTarget + """ + + _validation = { + 'target_base_type': {'required': True}, + } + + _attribute_map = { + 'target_base_type': {'key': 'targetBaseType', 'type': 'str'}, + 'junctions': {'key': 'junctions', 'type': '[NamespaceJunction]'}, + 'target_type': {'key': 'targetType', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'nfs3': {'key': 'nfs3', 'type': 'Nfs3Target'}, + 'clfs': {'key': 'clfs', 'type': 'ClfsTarget'}, + 'unknown': {'key': 'unknown', 'type': 'UnknownTarget'}, + } + + def __init__( + self, + **kwargs + ): + super(ClfsTargetProperties, self).__init__(**kwargs) + self.target_base_type = 'clfs' + + +class CloudErrorBody(msrest.serialization.Model): + """An error response. + + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :type code: str + :param details: A list of additional details about the error. + :type details: list[~azure.mgmt.storagecache.models.CloudErrorBody] + :param message: A message describing the error, intended to be suitable for display in a user + interface. + :type message: str + :param target: The target of the particular error. For example, the name of the property in + error. + :type target: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CloudErrorBody, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.details = kwargs.get('details', None) + self.message = kwargs.get('message', None) + self.target = kwargs.get('target', None) + + +class ErrorResponse(msrest.serialization.Model): + """Describes the format of Error response. + + :param code: Error code. + :type code: str + :param message: Error message indicating why the operation failed. + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class KeyVaultKeyReference(msrest.serialization.Model): + """Describes a reference to Key Vault Key. + + All required parameters must be populated in order to send to Azure. + + :param key_url: Required. The URL referencing a key encryption key in Key Vault. + :type key_url: str + :param source_vault: Required. Describes a resource Id to source Key Vault. + :type source_vault: ~azure.mgmt.storagecache.models.KeyVaultKeyReferenceSourceVault + """ + + _validation = { + 'key_url': {'required': True}, + 'source_vault': {'required': True}, + } + + _attribute_map = { + 'key_url': {'key': 'keyUrl', 'type': 'str'}, + 'source_vault': {'key': 'sourceVault', 'type': 'KeyVaultKeyReferenceSourceVault'}, + } + + def __init__( + self, + **kwargs + ): + super(KeyVaultKeyReference, self).__init__(**kwargs) + self.key_url = kwargs['key_url'] + self.source_vault = kwargs['source_vault'] + + +class KeyVaultKeyReferenceSourceVault(msrest.serialization.Model): + """Describes a resource Id to source Key Vault. + + :param id: Resource Id. + :type id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(KeyVaultKeyReferenceSourceVault, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + + +class NamespaceJunction(msrest.serialization.Model): + """A namespace junction. + + :param namespace_path: Namespace path on a Cache for a Storage Target. + :type namespace_path: str + :param target_path: Path in Storage Target to which namespacePath points. + :type target_path: str + :param nfs_export: NFS export where targetPath exists. + :type nfs_export: str + """ + + _attribute_map = { + 'namespace_path': {'key': 'namespacePath', 'type': 'str'}, + 'target_path': {'key': 'targetPath', 'type': 'str'}, + 'nfs_export': {'key': 'nfsExport', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(NamespaceJunction, self).__init__(**kwargs) + self.namespace_path = kwargs.get('namespace_path', None) + self.target_path = kwargs.get('target_path', None) + self.nfs_export = kwargs.get('nfs_export', None) + + +class Nfs3Target(msrest.serialization.Model): + """Properties pertained to Nfs3Target. + + :param target: IP address or host name of an NFSv3 host (e.g., 10.0.44.44). + :type target: str + :param usage_model: Identifies the primary usage model to be used for this Storage Target. Get + choices from .../usageModels. + :type usage_model: str + """ + + _validation = { + 'target': {'pattern': r'^[-.0-9a-zA-Z]+$'}, + } + + _attribute_map = { + 'target': {'key': 'target', 'type': 'str'}, + 'usage_model': {'key': 'usageModel', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Nfs3Target, self).__init__(**kwargs) + self.target = kwargs.get('target', None) + self.usage_model = kwargs.get('usage_model', None) + + +class Nfs3TargetProperties(StorageTargetProperties): + """An NFSv3 mount point for use as a Storage Target. + + All required parameters must be populated in order to send to Azure. + + :param target_base_type: Required. Type of the Storage Target.Constant filled by server. + Possible values include: "nfs3", "clfs", "unknown". + :type target_base_type: str or ~azure.mgmt.storagecache.models.StorageTargetType + :param junctions: List of Cache namespace junctions to target for namespace associations. + :type junctions: list[~azure.mgmt.storagecache.models.NamespaceJunction] + :param target_type: Type of the Storage Target. + :type target_type: str + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: + "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", "Updating". + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param nfs3: Properties when targetType is nfs3. + :type nfs3: ~azure.mgmt.storagecache.models.Nfs3Target + :param clfs: Properties when targetType is clfs. + :type clfs: ~azure.mgmt.storagecache.models.ClfsTarget + :param unknown: Properties when targetType is unknown. + :type unknown: ~azure.mgmt.storagecache.models.UnknownTarget + """ + + _validation = { + 'target_base_type': {'required': True}, + } + + _attribute_map = { + 'target_base_type': {'key': 'targetBaseType', 'type': 'str'}, + 'junctions': {'key': 'junctions', 'type': '[NamespaceJunction]'}, + 'target_type': {'key': 'targetType', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'nfs3': {'key': 'nfs3', 'type': 'Nfs3Target'}, + 'clfs': {'key': 'clfs', 'type': 'ClfsTarget'}, + 'unknown': {'key': 'unknown', 'type': 'UnknownTarget'}, + } + + def __init__( + self, + **kwargs + ): + super(Nfs3TargetProperties, self).__init__(**kwargs) + self.target_base_type = 'nfs3' + + +class ResourceSku(msrest.serialization.Model): + """A resource SKU. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_type: The type of resource the SKU applies to. + :vartype resource_type: str + :param capabilities: A list of capabilities of this SKU, such as throughput or ops/sec. + :type capabilities: list[~azure.mgmt.storagecache.models.ResourceSkuCapabilities] + :ivar locations: The set of locations that the SKU is available. This will be supported and + registered Azure Geo Regions (e.g., West US, East US, Southeast Asia, etc.). + :vartype locations: list[str] + :param location_info: The set of locations that the SKU is available. + :type location_info: list[~azure.mgmt.storagecache.models.ResourceSkuLocationInfo] + :param name: The name of this SKU. + :type name: str + :param restrictions: The restrictions preventing this SKU from being used. This is empty if + there are no restrictions. + :type restrictions: list[~azure.mgmt.storagecache.models.Restriction] + """ + + _validation = { + 'resource_type': {'readonly': True}, + 'locations': {'readonly': True}, + } + + _attribute_map = { + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': '[ResourceSkuCapabilities]'}, + 'locations': {'key': 'locations', 'type': '[str]'}, + 'location_info': {'key': 'locationInfo', 'type': '[ResourceSkuLocationInfo]'}, + 'name': {'key': 'name', 'type': 'str'}, + 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceSku, self).__init__(**kwargs) + self.resource_type = None + self.capabilities = kwargs.get('capabilities', None) + self.locations = None + self.location_info = kwargs.get('location_info', None) + self.name = kwargs.get('name', None) + self.restrictions = kwargs.get('restrictions', None) + + +class ResourceSkuCapabilities(msrest.serialization.Model): + """A resource SKU capability. + + :param name: Name of a capability, such as ops/sec. + :type name: str + :param value: Quantity, if the capability is measured by quantity. + :type value: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceSkuCapabilities, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.value = kwargs.get('value', None) + + +class ResourceSkuLocationInfo(msrest.serialization.Model): + """Resource SKU location information. + + :param location: Location where this SKU is available. + :type location: str + :param zones: Zones if any. + :type zones: list[str] + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'zones': {'key': 'zones', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceSkuLocationInfo, self).__init__(**kwargs) + self.location = kwargs.get('location', None) + self.zones = kwargs.get('zones', None) + + +class ResourceSkusResult(msrest.serialization.Model): + """The response from the List Cache SKUs operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param next_link: The URI to fetch the next page of Cache SKUs. + :type next_link: str + :ivar value: The list of SKUs available for the subscription. + :vartype value: list[~azure.mgmt.storagecache.models.ResourceSku] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[ResourceSku]'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceSkusResult, self).__init__(**kwargs) + self.next_link = kwargs.get('next_link', None) + self.value = None + + +class Restriction(msrest.serialization.Model): + """The restrictions preventing this SKU from being used. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The type of restrictions. In this version, the only possible value for this is + location. + :vartype type: str + :ivar values: The value of restrictions. If the restriction type is set to location, then this + would be the different locations where the SKU is restricted. + :vartype values: list[str] + :param reason_code: The reason for the restriction. As of now this can be "QuotaId" or + "NotAvailableForSubscription". "QuotaId" is set when the SKU has requiredQuotas parameter as + the subscription does not belong to that quota. "NotAvailableForSubscription" is related to + capacity at the datacenter. Possible values include: "QuotaId", "NotAvailableForSubscription". + :type reason_code: str or ~azure.mgmt.storagecache.models.ReasonCode + """ + + _validation = { + 'type': {'readonly': True}, + 'values': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Restriction, self).__init__(**kwargs) + self.type = None + self.values = None + self.reason_code = kwargs.get('reason_code', None) + + +class StorageTargetResource(msrest.serialization.Model): + """Resource used by a Cache. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Storage Target. + :vartype name: str + :ivar id: Resource ID of the Storage Target. + :vartype id: str + :ivar type: Type of the Storage Target; Microsoft.StorageCache/Cache/StorageTarget. + :vartype type: str + """ + + _validation = { + 'name': {'readonly': True, 'pattern': r'^[-0-9a-zA-Z_]{1,80}$'}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(StorageTargetResource, self).__init__(**kwargs) + self.name = None + self.id = None + self.type = None + + +class StorageTarget(StorageTargetResource): + """Type of the Storage Target. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Storage Target. + :vartype name: str + :ivar id: Resource ID of the Storage Target. + :vartype id: str + :ivar type: Type of the Storage Target; Microsoft.StorageCache/Cache/StorageTarget. + :vartype type: str + :param target_base_type: Type of the Storage Target.Constant filled by server. Possible values + include: "nfs3", "clfs", "unknown". + :type target_base_type: str or ~azure.mgmt.storagecache.models.StorageTargetType + :param junctions: List of Cache namespace junctions to target for namespace associations. + :type junctions: list[~azure.mgmt.storagecache.models.NamespaceJunction] + :param target_type: Type of the Storage Target. + :type target_type: str + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: + "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", "Updating". + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param nfs3: Properties when targetType is nfs3. + :type nfs3: ~azure.mgmt.storagecache.models.Nfs3Target + :param clfs: Properties when targetType is clfs. + :type clfs: ~azure.mgmt.storagecache.models.ClfsTarget + :param unknown: Properties when targetType is unknown. + :type unknown: ~azure.mgmt.storagecache.models.UnknownTarget + """ + + _validation = { + 'name': {'readonly': True, 'pattern': r'^[-0-9a-zA-Z_]{1,80}$'}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'target_base_type': {'key': 'properties.targetBaseType', 'type': 'str'}, + 'junctions': {'key': 'properties.junctions', 'type': '[NamespaceJunction]'}, + 'target_type': {'key': 'properties.targetType', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'nfs3': {'key': 'properties.nfs3', 'type': 'Nfs3Target'}, + 'clfs': {'key': 'properties.clfs', 'type': 'ClfsTarget'}, + 'unknown': {'key': 'properties.unknown', 'type': 'UnknownTarget'}, + } + + def __init__( + self, + **kwargs + ): + super(StorageTarget, self).__init__(**kwargs) + self.target_base_type = None + self.junctions = kwargs.get('junctions', None) + self.target_type = kwargs.get('target_type', None) + self.provisioning_state = kwargs.get('provisioning_state', None) + self.nfs3 = kwargs.get('nfs3', None) + self.clfs = kwargs.get('clfs', None) + self.unknown = kwargs.get('unknown', None) + + +class StorageTargetsResult(msrest.serialization.Model): + """A list of Storage Targets. + + :param next_link: The URI to fetch the next page of Storage Targets. + :type next_link: str + :param value: The list of Storage Targets defined for the Cache. + :type value: list[~azure.mgmt.storagecache.models.StorageTarget] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[StorageTarget]'}, + } + + def __init__( + self, + **kwargs + ): + super(StorageTargetsResult, self).__init__(**kwargs) + self.next_link = kwargs.get('next_link', None) + self.value = kwargs.get('value', None) + + +class UnknownTarget(msrest.serialization.Model): + """Properties pertained to UnknownTarget. + + :param unknown_map: Dictionary of string->string pairs containing information about the Storage + Target. + :type unknown_map: dict[str, str] + """ + + _attribute_map = { + 'unknown_map': {'key': 'unknownMap', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(UnknownTarget, self).__init__(**kwargs) + self.unknown_map = kwargs.get('unknown_map', None) + + +class UnknownTargetProperties(StorageTargetProperties): + """Storage container for use as an Unknown Storage Target. + + All required parameters must be populated in order to send to Azure. + + :param target_base_type: Required. Type of the Storage Target.Constant filled by server. + Possible values include: "nfs3", "clfs", "unknown". + :type target_base_type: str or ~azure.mgmt.storagecache.models.StorageTargetType + :param junctions: List of Cache namespace junctions to target for namespace associations. + :type junctions: list[~azure.mgmt.storagecache.models.NamespaceJunction] + :param target_type: Type of the Storage Target. + :type target_type: str + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: + "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", "Updating". + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param nfs3: Properties when targetType is nfs3. + :type nfs3: ~azure.mgmt.storagecache.models.Nfs3Target + :param clfs: Properties when targetType is clfs. + :type clfs: ~azure.mgmt.storagecache.models.ClfsTarget + :param unknown: Properties when targetType is unknown. + :type unknown: ~azure.mgmt.storagecache.models.UnknownTarget + """ + + _validation = { + 'target_base_type': {'required': True}, + } + + _attribute_map = { + 'target_base_type': {'key': 'targetBaseType', 'type': 'str'}, + 'junctions': {'key': 'junctions', 'type': '[NamespaceJunction]'}, + 'target_type': {'key': 'targetType', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'nfs3': {'key': 'nfs3', 'type': 'Nfs3Target'}, + 'clfs': {'key': 'clfs', 'type': 'ClfsTarget'}, + 'unknown': {'key': 'unknown', 'type': 'UnknownTarget'}, + } + + def __init__( + self, + **kwargs + ): + super(UnknownTargetProperties, self).__init__(**kwargs) + self.target_base_type = 'unknown' + + +class UsageModel(msrest.serialization.Model): + """A usage model. + + :param display: Localized information describing this usage model. + :type display: ~azure.mgmt.storagecache.models.UsageModelDisplay + :param model_name: Non-localized keyword name for this usage model. + :type model_name: str + :param target_type: The type of Storage Target to which this model is applicable (only nfs3 as + of this version). + :type target_type: str + """ + + _attribute_map = { + 'display': {'key': 'display', 'type': 'UsageModelDisplay'}, + 'model_name': {'key': 'modelName', 'type': 'str'}, + 'target_type': {'key': 'targetType', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(UsageModel, self).__init__(**kwargs) + self.display = kwargs.get('display', None) + self.model_name = kwargs.get('model_name', None) + self.target_type = kwargs.get('target_type', None) + + +class UsageModelDisplay(msrest.serialization.Model): + """Localized information describing this usage model. + + :param description: String to display for this usage model. + :type description: str + """ + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(UsageModelDisplay, self).__init__(**kwargs) + self.description = kwargs.get('description', None) + + +class UsageModelsResult(msrest.serialization.Model): + """A list of Cache usage models. + + :param next_link: The URI to fetch the next page of Cache usage models. + :type next_link: str + :param value: The list of usage models available for the subscription. + :type value: list[~azure.mgmt.storagecache.models.UsageModel] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[UsageModel]'}, + } + + def __init__( + self, + **kwargs + ): + super(UsageModelsResult, self).__init__(**kwargs) + self.next_link = kwargs.get('next_link', None) + self.value = kwargs.get('value', None) diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/models/_models_py3.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/models/_models_py3.py new file mode 100644 index 00000000000..3ac453333d0 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/models/_models_py3.py @@ -0,0 +1,1316 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Dict, List, Optional, Union + +import msrest.serialization + + +class ApiOperation(msrest.serialization.Model): + """REST API operation description: see https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/openapi-authoring-automated-guidelines.md#r3023-operationsapiimplementation. + + :param display: The object that represents the operation. + :type display: ~azure.mgmt.storagecache.models.ApiOperationDisplay + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + """ + + _attribute_map = { + 'display': {'key': 'display', 'type': 'ApiOperationDisplay'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["ApiOperationDisplay"] = None, + name: Optional[str] = None, + **kwargs + ): + super(ApiOperation, self).__init__(**kwargs) + self.display = display + self.name = name + + +class ApiOperationDisplay(msrest.serialization.Model): + """The object that represents the operation. + + :param operation: Operation type: Read, write, delete, etc. + :type operation: str + :param provider: Service provider: Microsoft.StorageCache. + :type provider: str + :param resource: Resource on which the operation is performed: Cache, etc. + :type resource: str + """ + + _attribute_map = { + 'operation': {'key': 'operation', 'type': 'str'}, + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + } + + def __init__( + self, + *, + operation: Optional[str] = None, + provider: Optional[str] = None, + resource: Optional[str] = None, + **kwargs + ): + super(ApiOperationDisplay, self).__init__(**kwargs) + self.operation = operation + self.provider = provider + self.resource = resource + + +class ApiOperationListResult(msrest.serialization.Model): + """Result of the request to list Resource Provider operations. It contains a list of operations and a URL link to get the next set of results. + + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + :param value: List of Resource Provider operations supported by the Microsoft.StorageCache + resource provider. + :type value: list[~azure.mgmt.storagecache.models.ApiOperation] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[ApiOperation]'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[List["ApiOperation"]] = None, + **kwargs + ): + super(ApiOperationListResult, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class AscOperation(msrest.serialization.Model): + """The status of operation. + + :param id: The operation Id. + :type id: str + :param name: The operation name. + :type name: str + :param start_time: The start time of the operation. + :type start_time: str + :param end_time: The end time of the operation. + :type end_time: str + :param status: The status of the operation. + :type status: str + :param error: The error detail of the operation if any. + :type error: ~azure.mgmt.storagecache.models.ErrorResponse + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'str'}, + 'end_time': {'key': 'endTime', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'ErrorResponse'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + status: Optional[str] = None, + error: Optional["ErrorResponse"] = None, + **kwargs + ): + super(AscOperation, self).__init__(**kwargs) + self.id = id + self.name = name + self.start_time = start_time + self.end_time = end_time + self.status = status + self.error = error + + +class Cache(msrest.serialization.Model): + """A Cache instance. Follows Azure Resource Manager standards: https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/resource-api-reference.md. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param tags: A set of tags. ARM tags as name/value pairs. + :type tags: object + :ivar id: Resource ID of the Cache. + :vartype id: str + :param location: Region name string. + :type location: str + :ivar name: Name of Cache. + :vartype name: str + :ivar type: Type of the Cache; Microsoft.StorageCache/Cache. + :vartype type: str + :param identity: The identity of the cache, if configured. + :type identity: ~azure.mgmt.storagecache.models.CacheIdentity + :param sku: SKU for the Cache. + :type sku: ~azure.mgmt.storagecache.models.CacheSku + :param cache_size_gb: The size of this Cache, in GB. + :type cache_size_gb: int + :ivar health: Health of the Cache. + :vartype health: ~azure.mgmt.storagecache.models.CacheHealth + :ivar mount_addresses: Array of IP addresses that can be used by clients mounting this Cache. + :vartype mount_addresses: list[str] + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: + "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", "Updating". + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param subnet: Subnet used for the Cache. + :type subnet: str + :param upgrade_status: Upgrade status of the Cache. + :type upgrade_status: ~azure.mgmt.storagecache.models.CacheUpgradeStatus + :param network_settings: Specifies network settings of the cache. + :type network_settings: ~azure.mgmt.storagecache.models.CacheNetworkSettings + :param encryption_settings: Specifies encryption settings of the cache. + :type encryption_settings: ~azure.mgmt.storagecache.models.CacheEncryptionSettings + :param security_settings: Specifies security settings of the cache. + :type security_settings: ~azure.mgmt.storagecache.models.CacheSecuritySettings + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True, 'pattern': r'^[-0-9a-zA-Z_]{1,80}$'}, + 'type': {'readonly': True}, + 'health': {'readonly': True}, + 'mount_addresses': {'readonly': True}, + } + + _attribute_map = { + 'tags': {'key': 'tags', 'type': 'object'}, + 'id': {'key': 'id', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'CacheIdentity'}, + 'sku': {'key': 'sku', 'type': 'CacheSku'}, + 'cache_size_gb': {'key': 'properties.cacheSizeGB', 'type': 'int'}, + 'health': {'key': 'properties.health', 'type': 'CacheHealth'}, + 'mount_addresses': {'key': 'properties.mountAddresses', 'type': '[str]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'subnet': {'key': 'properties.subnet', 'type': 'str'}, + 'upgrade_status': {'key': 'properties.upgradeStatus', 'type': 'CacheUpgradeStatus'}, + 'network_settings': {'key': 'properties.networkSettings', 'type': 'CacheNetworkSettings'}, + 'encryption_settings': {'key': 'properties.encryptionSettings', 'type': 'CacheEncryptionSettings'}, + 'security_settings': {'key': 'properties.securitySettings', 'type': 'CacheSecuritySettings'}, + } + + def __init__( + self, + *, + tags: Optional[object] = None, + location: Optional[str] = None, + identity: Optional["CacheIdentity"] = None, + sku: Optional["CacheSku"] = None, + cache_size_gb: Optional[int] = None, + provisioning_state: Optional[Union[str, "ProvisioningStateType"]] = None, + subnet: Optional[str] = None, + upgrade_status: Optional["CacheUpgradeStatus"] = None, + network_settings: Optional["CacheNetworkSettings"] = None, + encryption_settings: Optional["CacheEncryptionSettings"] = None, + security_settings: Optional["CacheSecuritySettings"] = None, + **kwargs + ): + super(Cache, self).__init__(**kwargs) + self.tags = tags + self.id = None + self.location = location + self.name = None + self.type = None + self.identity = identity + self.sku = sku + self.cache_size_gb = cache_size_gb + self.health = None + self.mount_addresses = None + self.provisioning_state = provisioning_state + self.subnet = subnet + self.upgrade_status = upgrade_status + self.network_settings = network_settings + self.encryption_settings = encryption_settings + self.security_settings = security_settings + + +class CacheEncryptionSettings(msrest.serialization.Model): + """Cache encryption settings. + + :param key_encryption_key: Specifies the location of the key encryption key in Key Vault. + :type key_encryption_key: ~azure.mgmt.storagecache.models.KeyVaultKeyReference + """ + + _attribute_map = { + 'key_encryption_key': {'key': 'keyEncryptionKey', 'type': 'KeyVaultKeyReference'}, + } + + def __init__( + self, + *, + key_encryption_key: Optional["KeyVaultKeyReference"] = None, + **kwargs + ): + super(CacheEncryptionSettings, self).__init__(**kwargs) + self.key_encryption_key = key_encryption_key + + +class CacheHealth(msrest.serialization.Model): + """An indication of Cache health. Gives more information about health than just that related to provisioning. + + :param state: List of Cache health states. Possible values include: "Unknown", "Healthy", + "Degraded", "Down", "Transitioning", "Stopping", "Stopped", "Upgrading", "Flushing". + :type state: str or ~azure.mgmt.storagecache.models.HealthStateType + :param status_description: Describes explanation of state. + :type status_description: str + """ + + _attribute_map = { + 'state': {'key': 'state', 'type': 'str'}, + 'status_description': {'key': 'statusDescription', 'type': 'str'}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "HealthStateType"]] = None, + status_description: Optional[str] = None, + **kwargs + ): + super(CacheHealth, self).__init__(**kwargs) + self.state = state + self.status_description = status_description + + +class CacheIdentity(msrest.serialization.Model): + """Cache identity properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of the cache. + :vartype principal_id: str + :ivar tenant_id: The tenant id associated with the cache. + :vartype tenant_id: str + :param type: The type of identity used for the cache. Possible values include: + "SystemAssigned", "None". + :type type: str or ~azure.mgmt.storagecache.models.CacheIdentityType + """ + + _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[Union[str, "CacheIdentityType"]] = None, + **kwargs + ): + super(CacheIdentity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class CacheNetworkSettings(msrest.serialization.Model): + """Cache network settings. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param mtu: The IPv4 maximum transmission unit configured for the subnet. + :type mtu: int + :ivar utility_addresses: Array of additional IP addresses used by this Cache. + :vartype utility_addresses: list[str] + """ + + _validation = { + 'mtu': {'maximum': 1500, 'minimum': 576}, + 'utility_addresses': {'readonly': True}, + } + + _attribute_map = { + 'mtu': {'key': 'mtu', 'type': 'int'}, + 'utility_addresses': {'key': 'utilityAddresses', 'type': '[str]'}, + } + + def __init__( + self, + *, + mtu: Optional[int] = 1500, + **kwargs + ): + super(CacheNetworkSettings, self).__init__(**kwargs) + self.mtu = mtu + self.utility_addresses = None + + +class CacheSecuritySettings(msrest.serialization.Model): + """Cache security settings. + + :param root_squash: root squash of cache property. + :type root_squash: bool + """ + + _attribute_map = { + 'root_squash': {'key': 'rootSquash', 'type': 'bool'}, + } + + def __init__( + self, + *, + root_squash: Optional[bool] = None, + **kwargs + ): + super(CacheSecuritySettings, self).__init__(**kwargs) + self.root_squash = root_squash + + +class CacheSku(msrest.serialization.Model): + """SKU for the Cache. + + :param name: SKU name for this Cache. + :type name: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + **kwargs + ): + super(CacheSku, self).__init__(**kwargs) + self.name = name + + +class CachesListResult(msrest.serialization.Model): + """Result of the request to list Caches. It contains a list of Caches and a URL link to get the next set of results. + + :param next_link: URL to get the next set of Cache list results, if there are any. + :type next_link: str + :param value: List of Caches. + :type value: list[~azure.mgmt.storagecache.models.Cache] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Cache]'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[List["Cache"]] = None, + **kwargs + ): + super(CachesListResult, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class CacheUpgradeStatus(msrest.serialization.Model): + """Properties describing the software upgrade state of the Cache. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar current_firmware_version: Version string of the firmware currently installed on this + Cache. + :vartype current_firmware_version: str + :ivar firmware_update_status: True if there is a firmware update ready to install on this + Cache. The firmware will automatically be installed after firmwareUpdateDeadline if not + triggered earlier via the upgrade operation. Possible values include: "available", + "unavailable". + :vartype firmware_update_status: str or ~azure.mgmt.storagecache.models.FirmwareStatusType + :ivar firmware_update_deadline: Time at which the pending firmware update will automatically be + installed on the Cache. + :vartype firmware_update_deadline: ~datetime.datetime + :ivar last_firmware_update: Time of the last successful firmware update. + :vartype last_firmware_update: ~datetime.datetime + :ivar pending_firmware_version: When firmwareUpdateAvailable is true, this field holds the + version string for the update. + :vartype pending_firmware_version: str + """ + + _validation = { + 'current_firmware_version': {'readonly': True}, + 'firmware_update_status': {'readonly': True}, + 'firmware_update_deadline': {'readonly': True}, + 'last_firmware_update': {'readonly': True}, + 'pending_firmware_version': {'readonly': True}, + } + + _attribute_map = { + 'current_firmware_version': {'key': 'currentFirmwareVersion', 'type': 'str'}, + 'firmware_update_status': {'key': 'firmwareUpdateStatus', 'type': 'str'}, + 'firmware_update_deadline': {'key': 'firmwareUpdateDeadline', 'type': 'iso-8601'}, + 'last_firmware_update': {'key': 'lastFirmwareUpdate', 'type': 'iso-8601'}, + 'pending_firmware_version': {'key': 'pendingFirmwareVersion', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CacheUpgradeStatus, self).__init__(**kwargs) + self.current_firmware_version = None + self.firmware_update_status = None + self.firmware_update_deadline = None + self.last_firmware_update = None + self.pending_firmware_version = None + + +class ClfsTarget(msrest.serialization.Model): + """Properties pertained to ClfsTarget. + + :param target: Resource ID of storage container. + :type target: str + """ + + _attribute_map = { + 'target': {'key': 'target', 'type': 'str'}, + } + + def __init__( + self, + *, + target: Optional[str] = None, + **kwargs + ): + super(ClfsTarget, self).__init__(**kwargs) + self.target = target + + +class StorageTargetProperties(msrest.serialization.Model): + """Properties of the Storage Target. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: ClfsTargetProperties, Nfs3TargetProperties, UnknownTargetProperties. + + All required parameters must be populated in order to send to Azure. + + :param target_base_type: Required. Type of the Storage Target.Constant filled by server. + Possible values include: "nfs3", "clfs", "unknown". + :type target_base_type: str or ~azure.mgmt.storagecache.models.StorageTargetType + :param junctions: List of Cache namespace junctions to target for namespace associations. + :type junctions: list[~azure.mgmt.storagecache.models.NamespaceJunction] + :param target_type: Type of the Storage Target. + :type target_type: str + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: + "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", "Updating". + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param nfs3: Properties when targetType is nfs3. + :type nfs3: ~azure.mgmt.storagecache.models.Nfs3Target + :param clfs: Properties when targetType is clfs. + :type clfs: ~azure.mgmt.storagecache.models.ClfsTarget + :param unknown: Properties when targetType is unknown. + :type unknown: ~azure.mgmt.storagecache.models.UnknownTarget + """ + + _validation = { + 'target_base_type': {'required': True}, + } + + _attribute_map = { + 'target_base_type': {'key': 'targetBaseType', 'type': 'str'}, + 'junctions': {'key': 'junctions', 'type': '[NamespaceJunction]'}, + 'target_type': {'key': 'targetType', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'nfs3': {'key': 'nfs3', 'type': 'Nfs3Target'}, + 'clfs': {'key': 'clfs', 'type': 'ClfsTarget'}, + 'unknown': {'key': 'unknown', 'type': 'UnknownTarget'}, + } + + _subtype_map = { + 'target_base_type': {'clfs': 'ClfsTargetProperties', 'nfs3': 'Nfs3TargetProperties', 'unknown': 'UnknownTargetProperties'} + } + + def __init__( + self, + *, + junctions: Optional[List["NamespaceJunction"]] = None, + target_type: Optional[str] = None, + provisioning_state: Optional[Union[str, "ProvisioningStateType"]] = None, + nfs3: Optional["Nfs3Target"] = None, + clfs: Optional["ClfsTarget"] = None, + unknown: Optional["UnknownTarget"] = None, + **kwargs + ): + super(StorageTargetProperties, self).__init__(**kwargs) + self.target_base_type = None + self.junctions = junctions + self.target_type = target_type + self.provisioning_state = provisioning_state + self.nfs3 = nfs3 + self.clfs = clfs + self.unknown = unknown + + +class ClfsTargetProperties(StorageTargetProperties): + """Storage container for use as a CLFS Storage Target. + + All required parameters must be populated in order to send to Azure. + + :param target_base_type: Required. Type of the Storage Target.Constant filled by server. + Possible values include: "nfs3", "clfs", "unknown". + :type target_base_type: str or ~azure.mgmt.storagecache.models.StorageTargetType + :param junctions: List of Cache namespace junctions to target for namespace associations. + :type junctions: list[~azure.mgmt.storagecache.models.NamespaceJunction] + :param target_type: Type of the Storage Target. + :type target_type: str + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: + "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", "Updating". + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param nfs3: Properties when targetType is nfs3. + :type nfs3: ~azure.mgmt.storagecache.models.Nfs3Target + :param clfs: Properties when targetType is clfs. + :type clfs: ~azure.mgmt.storagecache.models.ClfsTarget + :param unknown: Properties when targetType is unknown. + :type unknown: ~azure.mgmt.storagecache.models.UnknownTarget + """ + + _validation = { + 'target_base_type': {'required': True}, + } + + _attribute_map = { + 'target_base_type': {'key': 'targetBaseType', 'type': 'str'}, + 'junctions': {'key': 'junctions', 'type': '[NamespaceJunction]'}, + 'target_type': {'key': 'targetType', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'nfs3': {'key': 'nfs3', 'type': 'Nfs3Target'}, + 'clfs': {'key': 'clfs', 'type': 'ClfsTarget'}, + 'unknown': {'key': 'unknown', 'type': 'UnknownTarget'}, + } + + def __init__( + self, + *, + junctions: Optional[List["NamespaceJunction"]] = None, + target_type: Optional[str] = None, + provisioning_state: Optional[Union[str, "ProvisioningStateType"]] = None, + nfs3: Optional["Nfs3Target"] = None, + clfs: Optional["ClfsTarget"] = None, + unknown: Optional["UnknownTarget"] = None, + **kwargs + ): + super(ClfsTargetProperties, self).__init__(junctions=junctions, target_type=target_type, provisioning_state=provisioning_state, nfs3=nfs3, clfs=clfs, unknown=unknown, **kwargs) + self.target_base_type = 'clfs' + + +class CloudErrorBody(msrest.serialization.Model): + """An error response. + + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :type code: str + :param details: A list of additional details about the error. + :type details: list[~azure.mgmt.storagecache.models.CloudErrorBody] + :param message: A message describing the error, intended to be suitable for display in a user + interface. + :type message: str + :param target: The target of the particular error. For example, the name of the property in + error. + :type target: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + details: Optional[List["CloudErrorBody"]] = None, + message: Optional[str] = None, + target: Optional[str] = None, + **kwargs + ): + super(CloudErrorBody, self).__init__(**kwargs) + self.code = code + self.details = details + self.message = message + self.target = target + + +class ErrorResponse(msrest.serialization.Model): + """Describes the format of Error response. + + :param code: Error code. + :type code: str + :param message: Error message indicating why the operation failed. + :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(ErrorResponse, self).__init__(**kwargs) + self.code = code + self.message = message + + +class KeyVaultKeyReference(msrest.serialization.Model): + """Describes a reference to Key Vault Key. + + All required parameters must be populated in order to send to Azure. + + :param key_url: Required. The URL referencing a key encryption key in Key Vault. + :type key_url: str + :param source_vault: Required. Describes a resource Id to source Key Vault. + :type source_vault: ~azure.mgmt.storagecache.models.KeyVaultKeyReferenceSourceVault + """ + + _validation = { + 'key_url': {'required': True}, + 'source_vault': {'required': True}, + } + + _attribute_map = { + 'key_url': {'key': 'keyUrl', 'type': 'str'}, + 'source_vault': {'key': 'sourceVault', 'type': 'KeyVaultKeyReferenceSourceVault'}, + } + + def __init__( + self, + *, + key_url: str, + source_vault: "KeyVaultKeyReferenceSourceVault", + **kwargs + ): + super(KeyVaultKeyReference, self).__init__(**kwargs) + self.key_url = key_url + self.source_vault = source_vault + + +class KeyVaultKeyReferenceSourceVault(msrest.serialization.Model): + """Describes a resource Id to source Key Vault. + + :param id: Resource Id. + :type id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): + super(KeyVaultKeyReferenceSourceVault, self).__init__(**kwargs) + self.id = id + + +class NamespaceJunction(msrest.serialization.Model): + """A namespace junction. + + :param namespace_path: Namespace path on a Cache for a Storage Target. + :type namespace_path: str + :param target_path: Path in Storage Target to which namespacePath points. + :type target_path: str + :param nfs_export: NFS export where targetPath exists. + :type nfs_export: str + """ + + _attribute_map = { + 'namespace_path': {'key': 'namespacePath', 'type': 'str'}, + 'target_path': {'key': 'targetPath', 'type': 'str'}, + 'nfs_export': {'key': 'nfsExport', 'type': 'str'}, + } + + def __init__( + self, + *, + namespace_path: Optional[str] = None, + target_path: Optional[str] = None, + nfs_export: Optional[str] = None, + **kwargs + ): + super(NamespaceJunction, self).__init__(**kwargs) + self.namespace_path = namespace_path + self.target_path = target_path + self.nfs_export = nfs_export + + +class Nfs3Target(msrest.serialization.Model): + """Properties pertained to Nfs3Target. + + :param target: IP address or host name of an NFSv3 host (e.g., 10.0.44.44). + :type target: str + :param usage_model: Identifies the primary usage model to be used for this Storage Target. Get + choices from .../usageModels. + :type usage_model: str + """ + + _validation = { + 'target': {'pattern': r'^[-.0-9a-zA-Z]+$'}, + } + + _attribute_map = { + 'target': {'key': 'target', 'type': 'str'}, + 'usage_model': {'key': 'usageModel', 'type': 'str'}, + } + + def __init__( + self, + *, + target: Optional[str] = None, + usage_model: Optional[str] = None, + **kwargs + ): + super(Nfs3Target, self).__init__(**kwargs) + self.target = target + self.usage_model = usage_model + + +class Nfs3TargetProperties(StorageTargetProperties): + """An NFSv3 mount point for use as a Storage Target. + + All required parameters must be populated in order to send to Azure. + + :param target_base_type: Required. Type of the Storage Target.Constant filled by server. + Possible values include: "nfs3", "clfs", "unknown". + :type target_base_type: str or ~azure.mgmt.storagecache.models.StorageTargetType + :param junctions: List of Cache namespace junctions to target for namespace associations. + :type junctions: list[~azure.mgmt.storagecache.models.NamespaceJunction] + :param target_type: Type of the Storage Target. + :type target_type: str + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: + "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", "Updating". + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param nfs3: Properties when targetType is nfs3. + :type nfs3: ~azure.mgmt.storagecache.models.Nfs3Target + :param clfs: Properties when targetType is clfs. + :type clfs: ~azure.mgmt.storagecache.models.ClfsTarget + :param unknown: Properties when targetType is unknown. + :type unknown: ~azure.mgmt.storagecache.models.UnknownTarget + """ + + _validation = { + 'target_base_type': {'required': True}, + } + + _attribute_map = { + 'target_base_type': {'key': 'targetBaseType', 'type': 'str'}, + 'junctions': {'key': 'junctions', 'type': '[NamespaceJunction]'}, + 'target_type': {'key': 'targetType', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'nfs3': {'key': 'nfs3', 'type': 'Nfs3Target'}, + 'clfs': {'key': 'clfs', 'type': 'ClfsTarget'}, + 'unknown': {'key': 'unknown', 'type': 'UnknownTarget'}, + } + + def __init__( + self, + *, + junctions: Optional[List["NamespaceJunction"]] = None, + target_type: Optional[str] = None, + provisioning_state: Optional[Union[str, "ProvisioningStateType"]] = None, + nfs3: Optional["Nfs3Target"] = None, + clfs: Optional["ClfsTarget"] = None, + unknown: Optional["UnknownTarget"] = None, + **kwargs + ): + super(Nfs3TargetProperties, self).__init__(junctions=junctions, target_type=target_type, provisioning_state=provisioning_state, nfs3=nfs3, clfs=clfs, unknown=unknown, **kwargs) + self.target_base_type = 'nfs3' + + +class ResourceSku(msrest.serialization.Model): + """A resource SKU. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_type: The type of resource the SKU applies to. + :vartype resource_type: str + :param capabilities: A list of capabilities of this SKU, such as throughput or ops/sec. + :type capabilities: list[~azure.mgmt.storagecache.models.ResourceSkuCapabilities] + :ivar locations: The set of locations that the SKU is available. This will be supported and + registered Azure Geo Regions (e.g., West US, East US, Southeast Asia, etc.). + :vartype locations: list[str] + :param location_info: The set of locations that the SKU is available. + :type location_info: list[~azure.mgmt.storagecache.models.ResourceSkuLocationInfo] + :param name: The name of this SKU. + :type name: str + :param restrictions: The restrictions preventing this SKU from being used. This is empty if + there are no restrictions. + :type restrictions: list[~azure.mgmt.storagecache.models.Restriction] + """ + + _validation = { + 'resource_type': {'readonly': True}, + 'locations': {'readonly': True}, + } + + _attribute_map = { + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'capabilities': {'key': 'capabilities', 'type': '[ResourceSkuCapabilities]'}, + 'locations': {'key': 'locations', 'type': '[str]'}, + 'location_info': {'key': 'locationInfo', 'type': '[ResourceSkuLocationInfo]'}, + 'name': {'key': 'name', 'type': 'str'}, + 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + } + + def __init__( + self, + *, + capabilities: Optional[List["ResourceSkuCapabilities"]] = None, + location_info: Optional[List["ResourceSkuLocationInfo"]] = None, + name: Optional[str] = None, + restrictions: Optional[List["Restriction"]] = None, + **kwargs + ): + super(ResourceSku, self).__init__(**kwargs) + self.resource_type = None + self.capabilities = capabilities + self.locations = None + self.location_info = location_info + self.name = name + self.restrictions = restrictions + + +class ResourceSkuCapabilities(msrest.serialization.Model): + """A resource SKU capability. + + :param name: Name of a capability, such as ops/sec. + :type name: str + :param value: Quantity, if the capability is measured by quantity. + :type value: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + value: Optional[str] = None, + **kwargs + ): + super(ResourceSkuCapabilities, self).__init__(**kwargs) + self.name = name + self.value = value + + +class ResourceSkuLocationInfo(msrest.serialization.Model): + """Resource SKU location information. + + :param location: Location where this SKU is available. + :type location: str + :param zones: Zones if any. + :type zones: list[str] + """ + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'zones': {'key': 'zones', 'type': '[str]'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + zones: Optional[List[str]] = None, + **kwargs + ): + super(ResourceSkuLocationInfo, self).__init__(**kwargs) + self.location = location + self.zones = zones + + +class ResourceSkusResult(msrest.serialization.Model): + """The response from the List Cache SKUs operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param next_link: The URI to fetch the next page of Cache SKUs. + :type next_link: str + :ivar value: The list of SKUs available for the subscription. + :vartype value: list[~azure.mgmt.storagecache.models.ResourceSku] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[ResourceSku]'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + **kwargs + ): + super(ResourceSkusResult, self).__init__(**kwargs) + self.next_link = next_link + self.value = None + + +class Restriction(msrest.serialization.Model): + """The restrictions preventing this SKU from being used. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The type of restrictions. In this version, the only possible value for this is + location. + :vartype type: str + :ivar values: The value of restrictions. If the restriction type is set to location, then this + would be the different locations where the SKU is restricted. + :vartype values: list[str] + :param reason_code: The reason for the restriction. As of now this can be "QuotaId" or + "NotAvailableForSubscription". "QuotaId" is set when the SKU has requiredQuotas parameter as + the subscription does not belong to that quota. "NotAvailableForSubscription" is related to + capacity at the datacenter. Possible values include: "QuotaId", "NotAvailableForSubscription". + :type reason_code: str or ~azure.mgmt.storagecache.models.ReasonCode + """ + + _validation = { + 'type': {'readonly': True}, + 'values': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + } + + def __init__( + self, + *, + reason_code: Optional[Union[str, "ReasonCode"]] = None, + **kwargs + ): + super(Restriction, self).__init__(**kwargs) + self.type = None + self.values = None + self.reason_code = reason_code + + +class StorageTargetResource(msrest.serialization.Model): + """Resource used by a Cache. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Storage Target. + :vartype name: str + :ivar id: Resource ID of the Storage Target. + :vartype id: str + :ivar type: Type of the Storage Target; Microsoft.StorageCache/Cache/StorageTarget. + :vartype type: str + """ + + _validation = { + 'name': {'readonly': True, 'pattern': r'^[-0-9a-zA-Z_]{1,80}$'}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(StorageTargetResource, self).__init__(**kwargs) + self.name = None + self.id = None + self.type = None + + +class StorageTarget(StorageTargetResource): + """Type of the Storage Target. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Storage Target. + :vartype name: str + :ivar id: Resource ID of the Storage Target. + :vartype id: str + :ivar type: Type of the Storage Target; Microsoft.StorageCache/Cache/StorageTarget. + :vartype type: str + :param target_base_type: Type of the Storage Target.Constant filled by server. Possible values + include: "nfs3", "clfs", "unknown". + :type target_base_type: str or ~azure.mgmt.storagecache.models.StorageTargetType + :param junctions: List of Cache namespace junctions to target for namespace associations. + :type junctions: list[~azure.mgmt.storagecache.models.NamespaceJunction] + :param target_type: Type of the Storage Target. + :type target_type: str + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: + "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", "Updating". + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param nfs3: Properties when targetType is nfs3. + :type nfs3: ~azure.mgmt.storagecache.models.Nfs3Target + :param clfs: Properties when targetType is clfs. + :type clfs: ~azure.mgmt.storagecache.models.ClfsTarget + :param unknown: Properties when targetType is unknown. + :type unknown: ~azure.mgmt.storagecache.models.UnknownTarget + """ + + _validation = { + 'name': {'readonly': True, 'pattern': r'^[-0-9a-zA-Z_]{1,80}$'}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'target_base_type': {'key': 'properties.targetBaseType', 'type': 'str'}, + 'junctions': {'key': 'properties.junctions', 'type': '[NamespaceJunction]'}, + 'target_type': {'key': 'properties.targetType', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'nfs3': {'key': 'properties.nfs3', 'type': 'Nfs3Target'}, + 'clfs': {'key': 'properties.clfs', 'type': 'ClfsTarget'}, + 'unknown': {'key': 'properties.unknown', 'type': 'UnknownTarget'}, + } + + def __init__( + self, + *, + junctions: Optional[List["NamespaceJunction"]] = None, + target_type: Optional[str] = None, + provisioning_state: Optional[Union[str, "ProvisioningStateType"]] = None, + nfs3: Optional["Nfs3Target"] = None, + clfs: Optional["ClfsTarget"] = None, + unknown: Optional["UnknownTarget"] = None, + **kwargs + ): + super(StorageTarget, self).__init__(**kwargs) + self.target_base_type = None + self.junctions = junctions + self.target_type = target_type + self.provisioning_state = provisioning_state + self.nfs3 = nfs3 + self.clfs = clfs + self.unknown = unknown + + +class StorageTargetsResult(msrest.serialization.Model): + """A list of Storage Targets. + + :param next_link: The URI to fetch the next page of Storage Targets. + :type next_link: str + :param value: The list of Storage Targets defined for the Cache. + :type value: list[~azure.mgmt.storagecache.models.StorageTarget] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[StorageTarget]'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[List["StorageTarget"]] = None, + **kwargs + ): + super(StorageTargetsResult, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class UnknownTarget(msrest.serialization.Model): + """Properties pertained to UnknownTarget. + + :param unknown_map: Dictionary of string->string pairs containing information about the Storage + Target. + :type unknown_map: dict[str, str] + """ + + _attribute_map = { + 'unknown_map': {'key': 'unknownMap', 'type': '{str}'}, + } + + def __init__( + self, + *, + unknown_map: Optional[Dict[str, str]] = None, + **kwargs + ): + super(UnknownTarget, self).__init__(**kwargs) + self.unknown_map = unknown_map + + +class UnknownTargetProperties(StorageTargetProperties): + """Storage container for use as an Unknown Storage Target. + + All required parameters must be populated in order to send to Azure. + + :param target_base_type: Required. Type of the Storage Target.Constant filled by server. + Possible values include: "nfs3", "clfs", "unknown". + :type target_base_type: str or ~azure.mgmt.storagecache.models.StorageTargetType + :param junctions: List of Cache namespace junctions to target for namespace associations. + :type junctions: list[~azure.mgmt.storagecache.models.NamespaceJunction] + :param target_type: Type of the Storage Target. + :type target_type: str + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. Possible values include: + "Succeeded", "Failed", "Cancelled", "Creating", "Deleting", "Updating". + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param nfs3: Properties when targetType is nfs3. + :type nfs3: ~azure.mgmt.storagecache.models.Nfs3Target + :param clfs: Properties when targetType is clfs. + :type clfs: ~azure.mgmt.storagecache.models.ClfsTarget + :param unknown: Properties when targetType is unknown. + :type unknown: ~azure.mgmt.storagecache.models.UnknownTarget + """ + + _validation = { + 'target_base_type': {'required': True}, + } + + _attribute_map = { + 'target_base_type': {'key': 'targetBaseType', 'type': 'str'}, + 'junctions': {'key': 'junctions', 'type': '[NamespaceJunction]'}, + 'target_type': {'key': 'targetType', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'nfs3': {'key': 'nfs3', 'type': 'Nfs3Target'}, + 'clfs': {'key': 'clfs', 'type': 'ClfsTarget'}, + 'unknown': {'key': 'unknown', 'type': 'UnknownTarget'}, + } + + def __init__( + self, + *, + junctions: Optional[List["NamespaceJunction"]] = None, + target_type: Optional[str] = None, + provisioning_state: Optional[Union[str, "ProvisioningStateType"]] = None, + nfs3: Optional["Nfs3Target"] = None, + clfs: Optional["ClfsTarget"] = None, + unknown: Optional["UnknownTarget"] = None, + **kwargs + ): + super(UnknownTargetProperties, self).__init__(junctions=junctions, target_type=target_type, provisioning_state=provisioning_state, nfs3=nfs3, clfs=clfs, unknown=unknown, **kwargs) + self.target_base_type = 'unknown' + + +class UsageModel(msrest.serialization.Model): + """A usage model. + + :param display: Localized information describing this usage model. + :type display: ~azure.mgmt.storagecache.models.UsageModelDisplay + :param model_name: Non-localized keyword name for this usage model. + :type model_name: str + :param target_type: The type of Storage Target to which this model is applicable (only nfs3 as + of this version). + :type target_type: str + """ + + _attribute_map = { + 'display': {'key': 'display', 'type': 'UsageModelDisplay'}, + 'model_name': {'key': 'modelName', 'type': 'str'}, + 'target_type': {'key': 'targetType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["UsageModelDisplay"] = None, + model_name: Optional[str] = None, + target_type: Optional[str] = None, + **kwargs + ): + super(UsageModel, self).__init__(**kwargs) + self.display = display + self.model_name = model_name + self.target_type = target_type + + +class UsageModelDisplay(msrest.serialization.Model): + """Localized information describing this usage model. + + :param description: String to display for this usage model. + :type description: str + """ + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + **kwargs + ): + super(UsageModelDisplay, self).__init__(**kwargs) + self.description = description + + +class UsageModelsResult(msrest.serialization.Model): + """A list of Cache usage models. + + :param next_link: The URI to fetch the next page of Cache usage models. + :type next_link: str + :param value: The list of usage models available for the subscription. + :type value: list[~azure.mgmt.storagecache.models.UsageModel] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[UsageModel]'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[List["UsageModel"]] = None, + **kwargs + ): + super(UsageModelsResult, self).__init__(**kwargs) + self.next_link = next_link + self.value = value diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/models/_storage_cache_management_client_enums.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/models/_storage_cache_management_client_enums.py new file mode 100644 index 00000000000..0df80c1c973 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/models/_storage_cache_management_client_enums.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum + +class CacheIdentityType(str, Enum): + """The type of identity used for the cache + """ + + system_assigned = "SystemAssigned" + none = "None" + +class FirmwareStatusType(str, Enum): + """True if there is a firmware update ready to install on this Cache. The firmware will + automatically be installed after firmwareUpdateDeadline if not triggered earlier via the + upgrade operation. + """ + + available = "available" + unavailable = "unavailable" + +class HealthStateType(str, Enum): + """List of Cache health states. + """ + + unknown = "Unknown" + healthy = "Healthy" + degraded = "Degraded" + down = "Down" + transitioning = "Transitioning" + stopping = "Stopping" + stopped = "Stopped" + upgrading = "Upgrading" + flushing = "Flushing" + +class ProvisioningStateType(str, Enum): + """ARM provisioning state, see https://github.com/Azure/azure-resource-manager- + rpc/blob/master/v1.0/Addendum.md#provisioningstate-property + """ + + succeeded = "Succeeded" + failed = "Failed" + cancelled = "Cancelled" + creating = "Creating" + deleting = "Deleting" + updating = "Updating" + +class ReasonCode(str, Enum): + """The reason for the restriction. As of now this can be "QuotaId" or + "NotAvailableForSubscription". "QuotaId" is set when the SKU has requiredQuotas parameter as + the subscription does not belong to that quota. "NotAvailableForSubscription" is related to + capacity at the datacenter. + """ + + quota_id = "QuotaId" + not_available_for_subscription = "NotAvailableForSubscription" + +class StorageTargetType(str, Enum): + """Type of the Storage Target. + """ + + nfs3 = "nfs3" + clfs = "clfs" + unknown = "unknown" diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/__init__.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/__init__.py new file mode 100644 index 00000000000..f3ad75917da --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/__init__.py @@ -0,0 +1,23 @@ +# 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 ._operation_operations import OperationOperations +from ._sku_operations import SkuOperations +from ._usage_model_operations import UsageModelOperations +from ._asc_operation_operations import AscOperationOperations +from ._cache_operations import CacheOperations +from ._storage_target_operations import StorageTargetOperations + +__all__ = [ + 'OperationOperations', + 'SkuOperations', + 'UsageModelOperations', + 'AscOperationOperations', + 'CacheOperations', + 'StorageTargetOperations', +] diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_asc_operation_operations.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_asc_operation_operations.py new file mode 100644 index 00000000000..aead770e4e6 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_asc_operation_operations.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AscOperationOperations(object): + """AscOperationOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.storagecache.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + location, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.AscOperation" + """Gets the status of an asynchronous operation for the Azure HPC cache. + + :param location: The region name which the operation will lookup into. + :type location: str + :param operation_id: The operation id which uniquely identifies the asynchronous operation. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AscOperation or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.AscOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AscOperation"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'operationId': self._serialize.url("operation_id", operation_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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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('AscOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/locations/{location}/ascOperations/{operationId}'} diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_cache_operations.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_cache_operations.py new file mode 100644 index 00000000000..7d32b06243c --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_cache_operations.py @@ -0,0 +1,1013 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class CacheOperations(object): + """CacheOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.storagecache.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: (...) -> "models.CachesListResult" + """Returns all Caches the user has access to under a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CachesListResult or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.CachesListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CachesListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + 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) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('CachesListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/caches'} + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.CachesListResult" + """Returns all Caches the user has access to under a resource group. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CachesListResult or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.CachesListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CachesListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('CachesListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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.StorageCache/caches'} + + def _delete_initial( + self, + resource_group_name, # type: str + cache_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> object + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self._delete_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + '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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} + + def begin_delete( + self, + resource_group_name, # type: str + cache_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> object + """Schedules a Cache for deletion. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :return: An instance of LROPoller that returns + :rtype: ~azure.core.polling.LROPoller[object] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[object] + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} + + def get( + self, + resource_group_name, # type: str + cache_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Cache" + """Returns a Cache. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cache or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.Cache + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Cache"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + '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') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + 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('Cache', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} + + def _create_or_update_initial( + self, + resource_group_name, # type: str + cache_name, # type: str + tags=None, # type: Optional[object] + location=None, # type: Optional[str] + identity=None, # type: Optional["models.CacheIdentity"] + sku=None, # type: Optional["models.CacheSku"] + cache_size_gb=None, # type: Optional[int] + provisioning_state=None, # type: Optional[Union[str, "models.ProvisioningStateType"]] + subnet=None, # type: Optional[str] + upgrade_status=None, # type: Optional["models.CacheUpgradeStatus"] + network_settings=None, # type: Optional["models.CacheNetworkSettings"] + encryption_settings=None, # type: Optional["models.CacheEncryptionSettings"] + security_settings=None, # type: Optional["models.CacheSecuritySettings"] + **kwargs # type: Any + ): + # type: (...) -> "models.Cache" + cls = kwargs.pop('cls', None) # type: ClsType["models.Cache"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _cache = models.Cache(tags=tags, location=location, identity=identity, sku=sku, cache_size_gb=cache_size_gb, provisioning_state=provisioning_state, subnet=subnet, upgrade_status=upgrade_status, network_settings=network_settings, encryption_settings=encryption_settings, security_settings=security_settings) + api_version = "2020-03-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_or_update_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + if _cache is not None: + body_content = self._serialize.body(_cache, 'Cache') + 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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Cache', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Cache', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} + + def begin_create_or_update( + self, + resource_group_name, # type: str + cache_name, # type: str + tags=None, # type: Optional[object] + location=None, # type: Optional[str] + identity=None, # type: Optional["models.CacheIdentity"] + sku=None, # type: Optional["models.CacheSku"] + cache_size_gb=None, # type: Optional[int] + provisioning_state=None, # type: Optional[Union[str, "models.ProvisioningStateType"]] + subnet=None, # type: Optional[str] + upgrade_status=None, # type: Optional["models.CacheUpgradeStatus"] + network_settings=None, # type: Optional["models.CacheNetworkSettings"] + encryption_settings=None, # type: Optional["models.CacheEncryptionSettings"] + security_settings=None, # type: Optional["models.CacheSecuritySettings"] + **kwargs # type: Any + ): + # type: (...) -> "models.Cache" + """Create or update a Cache. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :param tags: ARM tags as name/value pairs. + :type tags: object + :param location: Region name string. + :type location: str + :param identity: The identity of the cache, if configured. + :type identity: ~azure.mgmt.storagecache.models.CacheIdentity + :param sku: SKU for the Cache. + :type sku: ~azure.mgmt.storagecache.models.CacheSku + :param cache_size_gb: The size of this Cache, in GB. + :type cache_size_gb: int + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param subnet: Subnet used for the Cache. + :type subnet: str + :param upgrade_status: Upgrade status of the Cache. + :type upgrade_status: ~azure.mgmt.storagecache.models.CacheUpgradeStatus + :param network_settings: Specifies network settings of the cache. + :type network_settings: ~azure.mgmt.storagecache.models.CacheNetworkSettings + :param encryption_settings: Specifies encryption settings of the cache. + :type encryption_settings: ~azure.mgmt.storagecache.models.CacheEncryptionSettings + :param security_settings: Specifies security settings of the cache. + :type security_settings: ~azure.mgmt.storagecache.models.CacheSecuritySettings + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :return: An instance of LROPoller that returns Cache + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storagecache.models.Cache] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.Cache"] + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + tags=tags, + location=location, + identity=identity, + sku=sku, + cache_size_gb=cache_size_gb, + provisioning_state=provisioning_state, + subnet=subnet, + upgrade_status=upgrade_status, + network_settings=network_settings, + encryption_settings=encryption_settings, + security_settings=security_settings, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Cache', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} + + def update( + self, + resource_group_name, # type: str + cache_name, # type: str + tags=None, # type: Optional[object] + location=None, # type: Optional[str] + identity=None, # type: Optional["models.CacheIdentity"] + sku=None, # type: Optional["models.CacheSku"] + cache_size_gb=None, # type: Optional[int] + provisioning_state=None, # type: Optional[Union[str, "models.ProvisioningStateType"]] + subnet=None, # type: Optional[str] + upgrade_status=None, # type: Optional["models.CacheUpgradeStatus"] + network_settings=None, # type: Optional["models.CacheNetworkSettings"] + encryption_settings=None, # type: Optional["models.CacheEncryptionSettings"] + security_settings=None, # type: Optional["models.CacheSecuritySettings"] + **kwargs # type: Any + ): + # type: (...) -> "models.Cache" + """Update a Cache instance. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :param tags: ARM tags as name/value pairs. + :type tags: object + :param location: Region name string. + :type location: str + :param identity: The identity of the cache, if configured. + :type identity: ~azure.mgmt.storagecache.models.CacheIdentity + :param sku: SKU for the Cache. + :type sku: ~azure.mgmt.storagecache.models.CacheSku + :param cache_size_gb: The size of this Cache, in GB. + :type cache_size_gb: int + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param subnet: Subnet used for the Cache. + :type subnet: str + :param upgrade_status: Upgrade status of the Cache. + :type upgrade_status: ~azure.mgmt.storagecache.models.CacheUpgradeStatus + :param network_settings: Specifies network settings of the cache. + :type network_settings: ~azure.mgmt.storagecache.models.CacheNetworkSettings + :param encryption_settings: Specifies encryption settings of the cache. + :type encryption_settings: ~azure.mgmt.storagecache.models.CacheEncryptionSettings + :param security_settings: Specifies security settings of the cache. + :type security_settings: ~azure.mgmt.storagecache.models.CacheSecuritySettings + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cache or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.Cache + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Cache"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _cache = models.Cache(tags=tags, location=location, identity=identity, sku=sku, cache_size_gb=cache_size_gb, provisioning_state=provisioning_state, subnet=subnet, upgrade_status=upgrade_status, network_settings=network_settings, encryption_settings=encryption_settings, security_settings=security_settings) + api_version = "2020-03-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + if _cache is not None: + body_content = self._serialize.body(_cache, 'Cache') + 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('Cache', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}'} + + def _flush_initial( + self, + resource_group_name, # type: str + cache_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> object + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self._flush_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + request = self._client.post(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _flush_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/flush'} + + def begin_flush( + self, + resource_group_name, # type: str + cache_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> object + """Tells a Cache to write all dirty data to the Storage Target(s). During the flush, clients will see errors returned until the flush is complete. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :return: An instance of LROPoller that returns + :rtype: ~azure.core.polling.LROPoller[object] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[object] + raw_result = self._flush_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_flush.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/flush'} + + def _start_initial( + self, + resource_group_name, # type: str + cache_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> object + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self._start_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + request = self._client.post(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/start'} + + def begin_start( + self, + resource_group_name, # type: str + cache_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> object + """Tells a Stopped state Cache to transition to Active state. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :return: An instance of LROPoller that returns + :rtype: ~azure.core.polling.LROPoller[object] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[object] + raw_result = self._start_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/start'} + + def _stop_initial( + self, + resource_group_name, # type: str + cache_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> object + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self._stop_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + request = self._client.post(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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stop'} + + def begin_stop( + self, + resource_group_name, # type: str + cache_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> object + """Tells an Active Cache to transition to Stopped state. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :return: An instance of LROPoller that returns + :rtype: ~azure.core.polling.LROPoller[object] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[object] + raw_result = self._stop_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/stop'} + + def _upgrade_firmware_initial( + self, + resource_group_name, # type: str + cache_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> object + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self._upgrade_firmware_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 201: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _upgrade_firmware_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/upgrade'} + + def begin_upgrade_firmware( + self, + resource_group_name, # type: str + cache_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> object + """Upgrade a Cache's firmware if a new version is available. Otherwise, this operation has no effect. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :return: An instance of LROPoller that returns + :rtype: ~azure.core.polling.LROPoller[object] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[object] + raw_result = self._upgrade_firmware_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_upgrade_firmware.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/upgrade'} diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_operation_operations.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_operation_operations.py new file mode 100644 index 00000000000..9dc22284ed0 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_operation_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations(object): + """OperationOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.storagecache.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: (...) -> "models.ApiOperationListResult" + """Lists all of the available Resource Provider operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiOperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.ApiOperationListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiOperationListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ApiOperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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.StorageCache/operations'} diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_sku_operations.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_sku_operations.py new file mode 100644 index 00000000000..293271659b8 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_sku_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class SkuOperations(object): + """SkuOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.storagecache.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: (...) -> "models.ResourceSkusResult" + """Get the list of StorageCache.Cache SKUs available to this subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceSkusResult or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.ResourceSkusResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceSkusResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + 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) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceSkusResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/skus'} diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_storage_target_operations.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_storage_target_operations.py new file mode 100644 index 00000000000..fa1c355ccf4 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_storage_target_operations.py @@ -0,0 +1,443 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class StorageTargetOperations(object): + """StorageTargetOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.storagecache.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_by_cache( + self, + resource_group_name, # type: str + cache_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.StorageTargetsResult" + """Returns a list of Storage Targets for the specified Cache. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageTargetsResult or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.StorageTargetsResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.StorageTargetsResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_cache.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('StorageTargetsResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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_cache.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets'} + + def _delete_initial( + self, + resource_group_name, # type: str + cache_name, # type: str + storage_target_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> object + cls = kwargs.pop('cls', None) # type: ClsType[object] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self._delete_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + 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, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('object', pipeline_response) + + if response.status_code == 204: + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} + + def begin_delete( + self, + resource_group_name, # type: str + cache_name, # type: str + storage_target_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> object + """Removes a Storage Target from a Cache. This operation is allowed at any time, but if the Cache is down or unhealthy, the actual removal of the Storage Target may be delayed until the Cache is healthy again. Note that if the Cache has data to flush to the Storage Target, the data will be flushed before the Storage Target will be deleted. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :param storage_target_name: Name of Storage Target. + :type storage_target_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :return: An instance of LROPoller that returns + :rtype: ~azure.core.polling.LROPoller[object] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[object] + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + storage_target_name=storage_target_name, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('object', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} + + def get( + self, + resource_group_name, # type: str + cache_name, # type: str + storage_target_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.StorageTarget" + """Returns a Storage Target from a Cache. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :param storage_target_name: Name of the Storage Target. Length of name must be not greater than + 80 and chars must be in list of [-0-9a-zA-Z_] char class. + :type storage_target_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageTarget or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.StorageTarget + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.StorageTarget"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + 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('StorageTarget', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} + + def _create_or_update_initial( + self, + resource_group_name, # type: str + cache_name, # type: str + storage_target_name, # type: str + target_base_type=None, # type: Optional[Union[str, "models.StorageTargetType"]] + junctions=None, # type: Optional[List["NamespaceJunction"]] + target_type=None, # type: Optional[str] + provisioning_state=None, # type: Optional[Union[str, "models.ProvisioningStateType"]] + nfs3=None, # type: Optional["models.Nfs3Target"] + clfs=None, # type: Optional["models.ClfsTarget"] + unknown=None, # type: Optional["models.UnknownTarget"] + **kwargs # type: Any + ): + # type: (...) -> "models.StorageTarget" + cls = kwargs.pop('cls', None) # type: ClsType["models.StorageTarget"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _storagetarget = models.StorageTarget(target_base_type=target_base_type, junctions=junctions, target_type=target_type, provisioning_state=provisioning_state, nfs3=nfs3, clfs=clfs, unknown=unknown) + api_version = "2020-03-01" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_or_update_initial.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'cacheName': self._serialize.url("cache_name", cache_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + 'storageTargetName': self._serialize.url("storage_target_name", storage_target_name, 'str', pattern=r'^[-0-9a-zA-Z_]{1,80}$'), + } + 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'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + if _storagetarget is not None: + body_content = self._serialize.body(_storagetarget, 'StorageTarget') + 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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('StorageTarget', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('StorageTarget', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} + + def begin_create_or_update( + self, + resource_group_name, # type: str + cache_name, # type: str + storage_target_name, # type: str + target_base_type=None, # type: Optional[Union[str, "models.StorageTargetType"]] + junctions=None, # type: Optional[List["NamespaceJunction"]] + target_type=None, # type: Optional[str] + provisioning_state=None, # type: Optional[Union[str, "models.ProvisioningStateType"]] + nfs3=None, # type: Optional["models.Nfs3Target"] + clfs=None, # type: Optional["models.ClfsTarget"] + unknown=None, # type: Optional["models.UnknownTarget"] + **kwargs # type: Any + ): + # type: (...) -> "models.StorageTarget" + """Create or update a Storage Target. This operation is allowed at any time, but if the Cache is down or unhealthy, the actual creation/modification of the Storage Target may be delayed until the Cache is healthy again. + + :param resource_group_name: Target resource group. + :type resource_group_name: str + :param cache_name: Name of Cache. Length of name must be not greater than 80 and chars must be + in list of [-0-9a-zA-Z_] char class. + :type cache_name: str + :param storage_target_name: Name of the Storage Target. Length of name must be not greater than + 80 and chars must be in list of [-0-9a-zA-Z_] char class. + :type storage_target_name: str + :param target_base_type: Type of the Storage Target. + :type target_base_type: str or ~azure.mgmt.storagecache.models.StorageTargetType + :param junctions: List of Cache namespace junctions to target for namespace associations. + :type junctions: list[~azure.mgmt.storagecache.models.NamespaceJunction] + :param target_type: Type of the Storage Target. + :type target_type: str + :param provisioning_state: ARM provisioning state, see https://github.com/Azure/azure-resource- + manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property. + :type provisioning_state: str or ~azure.mgmt.storagecache.models.ProvisioningStateType + :param nfs3: Properties when targetType is nfs3. + :type nfs3: ~azure.mgmt.storagecache.models.Nfs3Target + :param clfs: Properties when targetType is clfs. + :type clfs: ~azure.mgmt.storagecache.models.ClfsTarget + :param unknown: Properties when targetType is unknown. + :type unknown: ~azure.mgmt.storagecache.models.UnknownTarget + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :return: An instance of LROPoller that returns StorageTarget + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storagecache.models.StorageTarget] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.StorageTarget"] + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + cache_name=cache_name, + storage_target_name=storage_target_name, + target_base_type=target_base_type, + junctions=junctions, + target_type=target_type, + provisioning_state=provisioning_state, + nfs3=nfs3, + clfs=clfs, + unknown=unknown, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('StorageTarget', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'} diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_usage_model_operations.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_usage_model_operations.py new file mode 100644 index 00000000000..4f3cd072593 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/operations/_usage_model_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class UsageModelOperations(object): + """UsageModelOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.storagecache.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: (...) -> "models.UsageModelsResult" + """Get the list of Cache Usage Models available to this subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UsageModelsResult or the result of cls(response) + :rtype: ~azure.mgmt.storagecache.models.UsageModelsResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UsageModelsResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2020-03-01" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + 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) + else: + url = next_link + + # 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'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('UsageModelsResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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': '/subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/usageModels'} diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/py.typed b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/storagecache/azext_storagecache/vendored_sdks/storagecache/setup.py b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/setup.py new file mode 100644 index 00000000000..6e0c5475e11 --- /dev/null +++ b/src/storagecache/azext_storagecache/vendored_sdks/storagecache/setup.py @@ -0,0 +1,37 @@ +# 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. +# -------------------------------------------------------------------------- +# coding: utf-8 + +from setuptools import setup, find_packages + +NAME = "storagecachemanagementclient" +VERSION = "0.1.0" + +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = ["msrest>=0.6.0", "azure-core<2.0.0,>=1.2.0"] + +setup( + name=NAME, + version=VERSION, + description="StorageCacheManagementClient", + author_email="", + url="", + keywords=["Swagger", "StorageCacheManagementClient"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + A Storage Cache provides scalable caching service for NAS clients, serving data from either NFSv3 or Blob at-rest storage (referred to as "Storage Targets"). These operations allow you to manage Caches. + """ +) diff --git a/src/storagecache/report.md b/src/storagecache/report.md new file mode 100644 index 00000000000..9d0e2a45563 --- /dev/null +++ b/src/storagecache/report.md @@ -0,0 +1,173 @@ +# Azure CLI Module Creation Report + +### storagecache asc-operation show + +show a storagecache asc-operation. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--location**|string|The region name which the operation will lookup into.|location| +|**--operation-id**|string|The operation id which uniquely identifies the asynchronous operation.|operation_id| +### storagecache cache create + +create a storagecache cache. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +|**--cache-name**|string|Name of Cache. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|cache_name| +|**--tags**|any|ARM tags as name/value pairs.|tags| +|**--location**|string|Region name string.|location| +|**--identity**|object|The identity of the cache, if configured.|identity| +|**--sku**|object|SKU for the Cache.|sku| +|**--cache-size-gb**|integer|The size of this Cache, in GB.|cache_size_gb| +|**--provisioning-state**|choice|ARM provisioning state, see https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property|provisioning_state| +|**--subnet**|string|Subnet used for the Cache.|subnet| +|**--upgrade-status**|object|Upgrade status of the Cache.|upgrade_status| +|**--network-settings**|object|Specifies network settings of the cache.|network_settings| +|**--encryption-settings**|object|Specifies encryption settings of the cache.|encryption_settings| +|**--security-settings**|object|Specifies security settings of the cache.|security_settings| +### storagecache cache delete + +delete a storagecache cache. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +|**--cache-name**|string|Name of Cache. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|cache_name| +### storagecache cache flush + +flush a storagecache cache. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +|**--cache-name**|string|Name of Cache. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|cache_name| +### storagecache cache list + +list a storagecache cache. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +### storagecache cache show + +show a storagecache cache. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +|**--cache-name**|string|Name of Cache. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|cache_name| +### storagecache cache start + +start a storagecache cache. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +|**--cache-name**|string|Name of Cache. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|cache_name| +### storagecache cache stop + +stop a storagecache cache. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +|**--cache-name**|string|Name of Cache. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|cache_name| +### storagecache cache update + +update a storagecache cache. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +|**--cache-name**|string|Name of Cache. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|cache_name| +|**--tags**|any|ARM tags as name/value pairs.|tags| +|**--location**|string|Region name string.|location| +|**--identity**|object|The identity of the cache, if configured.|identity| +|**--sku**|object|SKU for the Cache.|sku| +|**--cache-size-gb**|integer|The size of this Cache, in GB.|cache_size_gb| +|**--provisioning-state**|choice|ARM provisioning state, see https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property|provisioning_state| +|**--subnet**|string|Subnet used for the Cache.|subnet| +|**--upgrade-status**|object|Upgrade status of the Cache.|upgrade_status| +|**--network-settings**|object|Specifies network settings of the cache.|network_settings| +|**--encryption-settings**|object|Specifies encryption settings of the cache.|encryption_settings| +|**--security-settings**|object|Specifies security settings of the cache.|security_settings| +### storagecache cache upgrade-firmware + +upgrade-firmware a storagecache cache. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +|**--cache-name**|string|Name of Cache. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|cache_name| +### storagecache sku list + +list a storagecache sku. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +### storagecache storage-target create + +create a storagecache storage-target. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +|**--cache-name**|string|Name of Cache. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|cache_name| +|**--storage-target-name**|string|Name of the Storage Target. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|storage_target_name| +|**--target-base-type**|choice|Type of the Storage Target.|target_base_type| +|**--junctions**|array|List of Cache namespace junctions to target for namespace associations.|junctions| +|**--target-type**|string|Type of the Storage Target.|target_type| +|**--provisioning-state**|choice|ARM provisioning state, see https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property|provisioning_state| +|**--nfs3**|object|Properties when targetType is nfs3.|nfs3| +|**--clfs**|object|Properties when targetType is clfs.|clfs| +|**--unknown**|object|Properties when targetType is unknown.|unknown| +### storagecache storage-target delete + +delete a storagecache storage-target. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +|**--cache-name**|string|Name of Cache. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|cache_name| +|**--storage-target-name**|string|Name of Storage Target.|storage_target_name| +### storagecache storage-target list + +list a storagecache storage-target. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +|**--cache-name**|string|Name of Cache. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|cache_name| +### storagecache storage-target show + +show a storagecache storage-target. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +|**--cache-name**|string|Name of Cache. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|cache_name| +|**--storage-target-name**|string|Name of the Storage Target. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|storage_target_name| +### storagecache storage-target update + +create a storagecache storage-target. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Target resource group.|resource_group_name| +|**--cache-name**|string|Name of Cache. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|cache_name| +|**--storage-target-name**|string|Name of the Storage Target. Length of name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_] char class.|storage_target_name| +|**--target-base-type**|choice|Type of the Storage Target.|target_base_type| +|**--junctions**|array|List of Cache namespace junctions to target for namespace associations.|junctions| +|**--target-type**|string|Type of the Storage Target.|target_type| +|**--provisioning-state**|choice|ARM provisioning state, see https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#provisioningstate-property|provisioning_state| +|**--nfs3**|object|Properties when targetType is nfs3.|nfs3| +|**--clfs**|object|Properties when targetType is clfs.|clfs| +|**--unknown**|object|Properties when targetType is unknown.|unknown| +### storagecache usage-model list + +list a storagecache usage-model. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| \ No newline at end of file diff --git a/src/storagecache/setup.cfg b/src/storagecache/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/storagecache/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/storagecache/setup.py b/src/storagecache/setup.py new file mode 100644 index 00000000000..c37521b5c26 --- /dev/null +++ b/src/storagecache/setup.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages + +# TODO: Confirm this is the right version number you want and it matches your +# HISTORY.rst entry. +VERSION = '0.1.0' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +# TODO: Add any additional SDK dependencies here +DEPENDENCIES = [] + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='storagecache', + version=VERSION, + description='Microsoft Azure Command-Line Tools StorageCacheManagementClient Extension', + # TODO: Update author and email, if applicable + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + # TODO: consider pointing directly to your source code instead of the generic repo + url='https://github.com/Azure/azure-cli-extensions', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_storagecache': ['azext_metadata.json']}, +)