Skip to content

Commit

Permalink
[DataBox] Migrate to track2 (#3347)
Browse files Browse the repository at this point in the history
  • Loading branch information
00Kai0 authored May 19, 2021
1 parent 970e9f0 commit 394d08d
Show file tree
Hide file tree
Showing 40 changed files with 7,432 additions and 3,968 deletions.
5 changes: 5 additions & 0 deletions src/databox/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Release History
===============

0.1.2
++++++
* Migrate to track2 SDK

0.1.1
++++++
* GA databox module.
Expand Down
8 changes: 4 additions & 4 deletions src/databox/azext_databox/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def create_databox_job(client,

body.setdefault('details', {})['destination_account_details'] = destination_account_details

return client.create(resource_group_name=resource_group_name, job_name=job_name, job_resource=body)
return client.begin_create(resource_group_name=resource_group_name, job_name=job_name, job_resource=body)


def update_databox_job(client,
Expand Down Expand Up @@ -100,13 +100,13 @@ def update_databox_job(client,
body.setdefault('details', {}).setdefault('shipping_address', {})[
'company_name'] = shipping_address.company_name if company_name is None else company_name # str

return client.update(resource_group_name=resource_group_name, job_name=job_name, job_resource_update_parameter=body)
return client.begin_update(resource_group_name=resource_group_name, job_name=job_name, job_resource_update_parameter=body)


def delete_databox_job(client,
resource_group_name,
job_name):
return client.delete(resource_group_name=resource_group_name, job_name=job_name)
return client.begin_delete(resource_group_name=resource_group_name, job_name=job_name)


def get_databox_job(client,
Expand All @@ -126,7 +126,7 @@ def cancel_databox_job(client,
resource_group_name,
job_name,
reason):
return client.cancel(resource_group_name=resource_group_name, job_name=job_name, reason=reason)
return client.cancel(resource_group_name=resource_group_name, job_name=job_name, cancellation_reason={'reason': reason})


def list_credentials_databox_job(client,
Expand Down
1,588 changes: 1,018 additions & 570 deletions src/databox/azext_databox/tests/latest/recordings/test_databox.yaml

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/databox/azext_databox/tests/latest/test_databox_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ class DataBoxScenarioTest(ScenarioTest):
@StorageAccountPreparer(parameter_name='storage_account_2')
def test_databox(self, storage_account_1, storage_account_2):
job_name = self.create_random_name('job', 24)
job_name_2 = self.create_random_name('job', 24)
self.kwargs.update({
'job_name': job_name,
'job_name_2': job_name_2,
'storage_account_1': storage_account_1,
'storage_account_2': storage_account_2
})
Expand Down Expand Up @@ -93,7 +95,7 @@ def test_databox(self, storage_account_1, storage_account_2):
# Create another databox job with sku 'DataBoxDisk'.
self.cmd('databox job create '
'--resource-group {rg} '
'--name {job_name} '
'--name {job_name_2} '
'--location westus '
'--sku DataBoxDisk '
'--expected-data-size 1 '
Expand All @@ -111,20 +113,20 @@ def test_databox(self, storage_account_1, storage_account_2):

self.cmd('databox job cancel '
'--resource-group {rg} '
'--name {job_name} '
'--name {job_name_2} '
'--reason "CancelTest" '
'-y',
checks=[])

self.cmd('databox job delete '
'--resource-group {rg} '
'--name {job_name} '
'--name {job_name_2} '
'-y',
checks=[])

self.cmd('databox job show '
'--resource-group {rg} '
'--name {job_name}',
'--name {job_name_2}',
expect_failure=True)

# DataBox service will create a lock 'DATABOX_SERVICE' on the storage account under the resource group when creating a job. In order to clean up the resource group, we need delete the lock first.
Expand Down
19 changes: 8 additions & 11 deletions src/databox/azext_databox/vendored_sdks/databox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# 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.
#
# 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.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._configuration import DataBoxManagementClientConfiguration
from ._data_box_management_client import DataBoxManagementClient
__all__ = ['DataBoxManagementClient', 'DataBoxManagementClientConfiguration']

from .version import VERSION

__version__ = VERSION
__all__ = ['DataBoxManagementClient']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
66 changes: 42 additions & 24 deletions src/databox/azext_databox/vendored_sdks/databox/_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,59 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
from msrestazure import AzureConfiguration
from typing import Any

from .version import VERSION
from azure.core.configuration import Configuration
from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMHttpLoggingPolicy

from ._version import VERSION


class DataBoxManagementClientConfiguration(Configuration):
"""Configuration for DataBoxManagementClient.
class DataBoxManagementClientConfiguration(AzureConfiguration):
"""Configuration for DataBoxManagementClient
Note that all parameters used to create this instance are saved as instance
attributes.
:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
:param subscription_id: The Subscription Id
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The Subscription Id.
:type subscription_id: str
:param str base_url: Service URL
"""

def __init__(
self, credentials, subscription_id, base_url=None):

if credentials is None:
raise ValueError("Parameter 'credentials' must not be None.")
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.")
if not base_url:
base_url = 'https://management.azure.com'

super(DataBoxManagementClientConfiguration, self).__init__(base_url)
super(DataBoxManagementClientConfiguration, self).__init__(**kwargs)

# Starting Autorest.Python 4.0.64, make connection pool activated by default
self.keep_alive = True

self.add_user_agent('azure-mgmt-databox/{}'.format(VERSION))
self.add_user_agent('Azure-SDK-For-Python')

self.credentials = credentials
self.credential = credential
self.subscription_id = subscription_id
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
kwargs.setdefault('sdk_moniker', 'azure-mgmt-databox/{}'.format(VERSION))
self._configure(**kwargs)

def _configure(
self,
**kwargs # type: Any
):
# type: (...) -> None
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
if self.credential and not self.authentication_policy:
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
Loading

0 comments on commit 394d08d

Please sign in to comment.