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

[ReleasePR datashare] [Datashare]Add sorting query parameters #2075

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
206 changes: 5 additions & 201 deletions src/datashare/README.md
Original file line number Diff line number Diff line change
@@ -1,201 +1,5 @@
# Azure CLI datashare Extension #
This package is for the 'datashare' extension, i.e. 'az datashare'. More info on what is [Data Share](https://docs.microsoft.com/azure/data-share/).

### How to use ###
Install this extension using the below CLI command
```
az extension add --name datashare
```

Register DataShare Resource Provider for your default susbcription.
```
az provider register -n "Microsoft.DataShare"
```

### Included Features
#### Datashare Account Management
*Examples:*

##### Create a Datashare Account

```
az datashare account create \
--location "West US 2" \
--tags tag1=Red tag2=White \
--name "cli_test_account" \
--resource-group "datashare_provider_rg"
```

##### Wait for the Datashare Account to be provisioned
```
az datashare account wait \
--name "cli_test_account" \
--resource-group "datashare_provider_rg" \
--created
```

#### Datashare Resource Management for a Provider
*Examples:*

##### Create a Datashare
```
az datashare create \
--account-name "cli_test_account" \
--resource-group "datashare_provider_rg" \
--description "share description" \
--share-kind "CopyBased" \
--terms "Confidential" \
--name "cli_test_share"
```

##### Create a Data Set
```
az datashare dataset create \
--account-name "cli_test_account" \
--name "cli_test_data_set" \
--resource-group "datashare_provider_rg" \
--share-name "cli_test_share" \
--dataset "{\"container_name\":\"mycontainer\",\"storage_account_name\":\"mysa\",\"kind\":\"Container\"}"
```

Please make sure the datashare account has the right permission of the data source when creating a data set upon it.
For instance, you can use `az datashare account show` to get 'identity.principalId' of the account, then assign the right role to it.
```
az role assignment create \
--role "Storage Blob Data Reader" \
--assignee-object-id {DatashareAccountPrincipalId} \
--assignee-principal-type ServicePrincipal \
--scope {StorageAccountId}
```

##### Create a Synchronization Setting
```
az datashare synchronization-setting create \
--account-name cli_test_account \
--resource-group datashare_provider_rg \
--share-name cli_test_share \
--name cli_test_synchronization_setting \
--recurrence-interval Day \
--synchronization-time "2020-04-05 10:50:00 +00:00" \
--kind ScheduleBased
```

##### List Synchronization History
```
az datashare synchronization list \
--account-name "cli_test_account" \
--resource-group "datashare_provider_rg" \
--share-name "cli_test_share"
```

##### Create a Datashare Invitation
```
az datashare invitation create \
--account-name "cli_test_account" \
--target-email "myname@microsoft.com" \
--name "cli_test_invitation" \
--resource-group "datashare_provider_rg" \
--share-name "cli_test_share"
```

##### List Share Subscriptions
```
az datashare provider-share-subscription list \
--account-name "cli_test_account" \
--resource-group "datashare_provider_rg" \
--share-name "cli_test_share"
```
Share subscriptions are created by Datashare consumers when they accept invitations.

##### Revoke Datashare for a Share Subscription
```
az datashare provider-share-subscription revoke \
--account-name "cli_test_account" \
--share-subscription "{ProviderShareSubscriptionObjectId}" \
--resource-group "datashare_provider_rg" \
--share-name "cli_test_share"
```

##### Reinstate Datashare for a Share Subscription
```
az datashare provider-share-subscription reinstate \
--account-name "cli_test_account" \
--share-subscription "{ProviderShareSubscriptionObjectId}" \
--resource-group "datashare_provider_rg" \
--share-name "cli_test_share"
```

#### Datashare Resource Management for a Consumer
*Examples:*

##### List received Invitations
```
az datashare consumer invitation list
```

##### Create a Share Subscription from an Invitation
```
az datashare consumer share-subscription create \
--account-name "cli_test_consumer_account" \
--resource-group "datashare_consumer_rg" \
--invitation-id "{InvitationId1}" \
--source-share-location "sourceShareLocation" \
--name "cli_test_share_subscription"
```

##### List Source Data Sets in the Share Subscription
```
az datashare consumer share-subscription list-source-dataset \
--account-name "cli_test_consumer_account" \
--resource-group "datashare_consumer_rg" \
--share-subscription-name "cli_test_share_subscription"
```

##### Create a Data Set Mapping of the Source Data Set
```
az datashare consumer dataset-mapping create \
--account-name "cli_test_consumer_account" \
--name "cli_test_data_set_mapping" \
--resource-group "datashare_consumer_rg" \
--share-subscription-name "cli_test_share_subscription" \
--mapping "{\"data_set_id\":\"2036a39f-add6-4347-9c82-a424dfaf4e8d\", \
\"container_name\":\"newcontainer\", \"storage_account_name\":\"consumersa\", \
\"kind\":\"BlobFolder\",\"prefix\":\"myprefix\"}"
```
Please make sure the datashare consumer account has the right permission of the data target when creating a data set mapping on it. For instance, you can use `az datashare account show` to get 'identity.principalId' of the account, then assign the right role to it.
```
az role assignment create \
--role "Storage Blob Data Contributor" \
--assignee-object-id "{ConsumerDatashareAccountPrincipalId}" \
--assignee-principal-type ServicePrincipal \
--scope "{ConsumerStorageAccountId}"
```

##### List the synchronization settings of the Source Datashare
```
az datashare consumer share-subscription list-source-share-synchronization-setting \
--account-name "cli_test_consumer_account" \
--resource-group "datashare_consumer_rg" \
--share-subscription-name "cli_test_share_subscription"
```

##### Create a trigger for the Share Subsciption
```
az datashare consumer trigger create \
--account-name "cli_test_consumer_account" \
--resource-group "datashare_consumer_rg" \
--share-subscription-name "cli_test_share_subscription" \
--name "cli_test_trigger" \
--recurrence-interval Day \
--synchronization-time "2020-04-05 10:50:00 +00:00" \
--kind ScheduleBased
```

##### Start a synchronization for the Share Subscription
```
az datashare consumer share-subscription synchronization start \
--account-name "cli_test_consumer_account" \
--resource-group "datashare_consumer_rg" \
--share-subscription-name "cli_test_share_subscription" \
--synchronization-mode "Incremental"
```
Microsoft Azure CLI 'datashare' Extension
==========================================

This package is for the 'datashare' extension.
i.e. 'az datashare'
35 changes: 16 additions & 19 deletions src/datashare/azext_datashare/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=unused-argument
# pylint: disable=unused-import
# 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_datashare._help import helps
from azext_datashare.generated._help import helps # pylint: disable=unused-import


class DataShareManagementClientCommandsLoader(AzCommandsLoader):
Expand All @@ -15,17 +18,14 @@ def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_datashare.generated._client_factory import cf_datashare
datashare_custom = CliCommandType(
operations_tmpl='azext_datashare.manual.custom#{}', # modified
operations_tmpl='azext_datashare.custom#{}',
client_factory=cf_datashare)
super(DataShareManagementClientCommandsLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=datashare_custom)
parent = super(DataShareManagementClientCommandsLoader, self)
parent.__init__(cli_ctx=cli_ctx, custom_command_type=datashare_custom)

def load_command_table(self, args):
try:
from azext_datashare.generated.commands import load_command_table
load_command_table(self, args)
except ImportError:
pass
from azext_datashare.generated.commands import load_command_table
load_command_table(self, args)
try:
from azext_datashare.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
Expand All @@ -34,11 +34,8 @@ def load_command_table(self, args):
return self.command_table

def load_arguments(self, command):
try:
from azext_datashare.generated._params import load_arguments
load_arguments(self, command)
except ImportError:
pass
from azext_datashare.generated._params import load_arguments
load_arguments(self, command)
try:
from azext_datashare.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
Expand Down
16 changes: 0 additions & 16 deletions src/datashare/azext_datashare/_params.py

This file was deleted.

17 changes: 9 additions & 8 deletions src/datashare/azext_datashare/action.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

try:
from .generated.action import * # noqa: F403
except ImportError:
pass

from .generated.action import * # noqa: F403
try:
from .manual.action import * # noqa: F403
except ImportError:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

# try:
# from .generated._help import * # noqa: F403
# except ImportError:
# pass

try:
from .manual._help import * # noqa: F403
except ImportError:
pass
# --------------------------------------------------------------------------
# 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
24 changes: 12 additions & 12 deletions src/datashare/azext_datashare/generated/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +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__)
# 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__)
11 changes: 8 additions & 3 deletions src/datashare/azext_datashare/generated/_client_factory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# --------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------


def cf_datashare(cli_ctx, *_):
Expand Down
Loading