Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR databox] Adding support of Export, Cmk and BYOK features with version upgrade. #176

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 134 additions & 79 deletions src/databox/azext_databox/generated/_help.py

Large diffs are not rendered by default.

38 changes: 25 additions & 13 deletions src/databox/azext_databox/generated/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from azure.cli.core.commands.validators import get_default_location_from_resource_group
from azext_databox.action import (
AddSku,
AddDestinationAccountDetails,
AddDataBoxScheduleAvailabilityRequest,
AddDiskScheduleAvailabilityRequest,
AddHeavyScheduleAvailabilityRequest,
Expand Down Expand Up @@ -53,6 +52,9 @@ def load_arguments(self, _):
validator=get_default_location_from_resource_group)
c.argument('tags', tags_type)
c.argument('sku', action=AddSku, nargs='+', help='The sku type.')
c.argument('identity_type', help='Identity type')
c.argument('transfer_type', arg_type=get_enum_type(['ImportToAzure', 'ExportFromAzure']), help='Type of the dat'
'a transfer.')
c.argument('details', arg_type=CLIArgumentType(options_list=['--details'], help='Details of a job run. This fie'
'ld will only be sent for expand details filter. Expected value: json-string/@json-file.'))
c.argument('delivery_type', arg_type=get_enum_type(['NonScheduled', 'Scheduled']),
Expand All @@ -67,10 +69,9 @@ def load_arguments(self, _):
c.argument('if_match', help='Defines the If-Match condition. The patch will be performed only if the ETag of th'
'e job on the server matches this value.')
c.argument('tags', tags_type)
c.argument('identity_type', help='Identity type')
c.argument('details', arg_type=CLIArgumentType(options_list=['--details'], help='Details of a job to be updated'
'. Expected value: json-string/@json-file.'))
c.argument('destination_account_details', action=AddDestinationAccountDetails, nargs='+', help='Destination acc'
'ount details.')

with self.argument_context('databox job delete') as c:
c.argument('resource_group_name', resource_group_name_type)
Expand Down Expand Up @@ -110,17 +111,12 @@ def load_arguments(self, _):
c.argument('expand', help='$expand is supported on details parameter for job, which provides details on the job'
' stages.')

with self.argument_context('databox service list-available-sku') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx),
validator=get_default_location_from_resource_group)
c.argument('country', help='ISO country code. Country for hardware shipment. For codes check: https://en.wikipe'
'dia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements')
c.argument('sku_names', nargs='+', help='Sku Names to filter for available skus')

with self.argument_context('databox service list-available-sku-by-resource-group') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('location', arg_type=get_location_type(self.cli_ctx),
validator=get_default_location_from_resource_group)
c.argument('transfer_type', arg_type=get_enum_type(['ImportToAzure', 'ExportFromAzure']), help='Type of the tra'
'nsfer.')
c.argument('country', help='ISO country code. Country for hardware shipment. For codes check: https://en.wikipe'
'dia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements')
c.argument('sku_names', nargs='+', help='Sku Names to filter for available skus')
Expand All @@ -140,12 +136,28 @@ def load_arguments(self, _):
c.argument('transport_availability_request_sku_name', arg_type=get_enum_type(['DataBox', 'DataBoxDisk', 'DataBo'
'xHeavy']), help='Type of the device.')

with self.argument_context('databox service region-configuration-by-resource-group') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('location', arg_type=get_location_type(self.cli_ctx),
validator=get_default_location_from_resource_group, id_part='name')
c.argument('data_box_schedule_availability_request', action=AddDataBoxScheduleAvailabilityRequest, nargs='+',
help='Request body to get the availability for scheduling data box orders orders.', arg_group='Sched'
'uleAvailabilityRequest')
c.argument('disk_schedule_availability_request', action=AddDiskScheduleAvailabilityRequest, nargs='+', help='Re'
'quest body to get the availability for scheduling disk orders.', arg_group='ScheduleAvailabilityReq'
'uest')
c.argument('heavy_schedule_availability_request', action=AddHeavyScheduleAvailabilityRequest, nargs='+', help=
'Request body to get the availability for scheduling heavy orders.', arg_group='ScheduleAvailability'
'Request')
c.argument('transport_availability_request_sku_name', arg_type=get_enum_type(['DataBox', 'DataBoxDisk', 'DataBo'
'xHeavy']), help='Type of the device.')

with self.argument_context('databox service validate-address') as c:
c.argument('location', arg_type=get_location_type(self.cli_ctx),
validator=get_default_location_from_resource_group, id_part='name')
c.argument('validation_type', arg_type=get_enum_type(['ValidateAddress', 'ValidateDataDestinationDetails', 'Val'
'idateSubscriptionIsAllowedToCreateJob', 'ValidatePreferences', 'ValidateCreateOrderLimit', 'Validat'
'eSkuAvailability']), help='Identifies the type of validation request.')
c.argument('validation_type', arg_type=get_enum_type(['ValidateAddress', 'ValidateSubscriptionIsAllowedToCreate'
'Job', 'ValidatePreferences', 'ValidateCreateOrderLimit', 'ValidateSkuAvailability', 'ValidateDataTr'
'ansferDetails']), help='Identifies the type of validation request.')
c.argument('shipping_address', action=AddShippingAddress, nargs='+', help='Shipping address of the customer.')
c.argument('device_type', arg_type=get_enum_type(['DataBox', 'DataBoxDisk', 'DataBoxHeavy']), help='Device type'
' to be used for the job.')
Expand Down
32 changes: 6 additions & 26 deletions src/databox/azext_databox/generated/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,6 @@ def get_action(self, values, option_string): # pylint: disable=no-self-use
return d


class AddDestinationAccountDetails(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
super(AddDestinationAccountDetails, 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 == 'data-destination-type':
d['data_destination_type'] = v[0]
elif kl == 'account-id':
d['account_id'] = v[0]
elif kl == 'share-password':
d['share_password'] = v[0]
return d


class AddDataBoxScheduleAvailabilityRequest(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
Expand All @@ -85,6 +59,8 @@ def get_action(self, values, option_string): # pylint: disable=no-self-use
v = properties[k]
if kl == 'storage-location':
d['storage_location'] = v[0]
elif kl == 'country':
d['country'] = v[0]
d['sku_name'] = 'DataBox'
return d

Expand All @@ -110,6 +86,8 @@ def get_action(self, values, option_string): # pylint: disable=no-self-use
d['expected_data_size_in_terabytes'] = v[0]
elif kl == 'storage-location':
d['storage_location'] = v[0]
elif kl == 'country':
d['country'] = v[0]
d['sku_name'] = 'DataBoxDisk'
return d

Expand All @@ -133,6 +111,8 @@ def get_action(self, values, option_string): # pylint: disable=no-self-use
v = properties[k]
if kl == 'storage-location':
d['storage_location'] = v[0]
elif kl == 'country':
d['country'] = v[0]
d['sku_name'] = 'DataBoxHeavy'
return d

Expand Down
3 changes: 2 additions & 1 deletion src/databox/azext_databox/generated/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ def load_command_table(self, _):
operations_tmpl='azext_databox.vendored_sdks.databox.operations._service_operations#ServiceOperations.{}',
client_factory=cf_service)
with self.command_group('databox service', databox_service, client_factory=cf_service, is_experimental=True) as g:
g.custom_command('list-available-sku', 'databox_service_list_available_sku')
g.custom_command('list-available-sku-by-resource-group',
'databox_service_list_available_sku_by_resource_group')
g.custom_command('region-configuration', 'databox_service_region_configuration')
g.custom_command('region-configuration-by-resource-group', 'databox_service_region_configuration_by_resource_gr'
'oup')
g.custom_command('validate-address', 'databox_service_validate_address')
g.custom_command('validate-input', 'databox_service_validate_input')
g.custom_command('validate-input-by-resource-group', 'databox_service_validate_input_by_resource_group')
46 changes: 33 additions & 13 deletions src/databox/azext_databox/generated/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def databox_job_create(client,
job_name,
location,
sku,
transfer_type,
tags=None,
identity_type=None,
details=None,
delivery_type=None,
delivery_info_scheduled_date_time=None,
Expand All @@ -52,6 +54,8 @@ def databox_job_create(client,
location=location,
tags=tags,
sku=sku,
type=identity_type,
transfer_type=transfer_type,
details=details,
delivery_type=delivery_type,
scheduled_date_time=delivery_info_scheduled_date_time)
Expand All @@ -62,8 +66,8 @@ def databox_job_update(client,
job_name,
if_match=None,
tags=None,
identity_type=None,
details=None,
destination_account_details=None,
no_wait=False):
if isinstance(details, str):
details = json.loads(details)
Expand All @@ -73,8 +77,8 @@ def databox_job_update(client,
job_name=job_name,
if_match=if_match,
tags=tags,
details=details,
destination_account_details=destination_account_details)
type=identity_type,
details=details)


def databox_job_delete(client,
Expand Down Expand Up @@ -116,23 +120,15 @@ def databox_job_list_credentials(client,
job_name=job_name)


def databox_service_list_available_sku(client,
country,
location=None,
sku_names=None):
return client.list_available_sku(location=location,
country=country,
available_sku_request_location=location,
sku_names=sku_names)


def databox_service_list_available_sku_by_resource_group(client,
resource_group_name,
transfer_type,
country,
location=None,
sku_names=None):
return client.list_available_sku_by_resource_group(resource_group_name=resource_group_name,
location=location,
transfer_type=transfer_type,
country=country,
available_sku_request_location=location,
sku_names=sku_names)
Expand Down Expand Up @@ -160,6 +156,30 @@ def databox_service_region_configuration(client,
sku_name=transport_availability_request_sku_name)


def databox_service_region_configuration_by_resource_group(client,
resource_group_name,
location,
data_box_schedule_availability_request=None,
disk_schedule_availability_request=None,
heavy_schedule_availability_request=None,
transport_availability_request_sku_name=None):
all_schedule_availability_request = []
if data_box_schedule_availability_request is not None:
all_schedule_availability_request.append(data_box_schedule_availability_request)
if disk_schedule_availability_request is not None:
all_schedule_availability_request.append(disk_schedule_availability_request)
if heavy_schedule_availability_request is not None:
all_schedule_availability_request.append(heavy_schedule_availability_request)
if len(all_schedule_availability_request) > 1:
raise CLIError('at most one of data_box_schedule_availability_request, disk_schedule_availability_request, hea'
'vy_schedule_availability_request is needed for schedule_availability_request!')
schedule_availability_request = all_schedule_availability_request[0] if len(all_schedule_availability_request) == 1 else None
return client.region_configuration_by_resource_group(resource_group_name=resource_group_name,
location=location,
schedule_availability_request=schedule_availability_request,
sku_name=transport_availability_request_sku_name)


def databox_service_validate_address(client,
location,
validation_type,
Expand Down
Loading