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

[Databricks] Migrate databricks to track2 SDK #3688

Merged
merged 5 commits into from
Jul 28, 2021
Merged
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
4 changes: 4 additions & 0 deletions src/databricks/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.7.3
+++++
* Migrate databricks to track2 SDK

0.7.2
+++++
* az databricks workspace create: Add --enable-no-public-ip to allow creating workspace with no public ip
Expand Down
4 changes: 2 additions & 2 deletions src/databricks/azext_databricks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def __init__(self, cli_ctx=None):
databricks_custom = CliCommandType(
operations_tmpl='azext_databricks.custom#{}',
client_factory=cf_databricks)
super(DatabricksClientCommandsLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=databricks_custom)
super().__init__(cli_ctx=cli_ctx,
custom_command_type=databricks_custom)

def load_command_table(self, args):
from azext_databricks.commands import load_command_table
Expand Down
12 changes: 6 additions & 6 deletions src/databricks/azext_databricks/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def create_databricks_workspace(cmd, client,
_set_parameter_value(parameters, 'enable_no_public_ip', enable_no_public_ip)
body['parameters'] = parameters

return sdk_no_wait(no_wait, client.create_or_update,
return sdk_no_wait(no_wait, client.begin_create_or_update,
resource_group_name=resource_group_name,
workspace_name=workspace_name,
parameters=body)
Expand Down Expand Up @@ -80,7 +80,7 @@ def update_databricks_workspace(cmd, client, # pylint: disable=too-many-branche
encryption['key_vault_uri'] = encryption_key_vault
_set_parameter_value(parameters, 'encryption', encryption)

return sdk_no_wait(no_wait, client.create_or_update,
return sdk_no_wait(no_wait, client.begin_create_or_update,
resource_group_name=resource_group_name,
workspace_name=workspace_name,
parameters=body)
Expand All @@ -89,7 +89,7 @@ def update_databricks_workspace(cmd, client, # pylint: disable=too-many-branche
def delete_databricks_workspace(cmd, client, resource_group_name,
workspace_name,
no_wait=False):
return sdk_no_wait(no_wait, client.delete,
return sdk_no_wait(no_wait, client.begin_delete,
resource_group_name=resource_group_name,
workspace_name=workspace_name)

Expand Down Expand Up @@ -130,7 +130,7 @@ def create_databricks_vnet_peering(client, resource_group_name, workspace_name,
if use_remote_gateways is not None:
peering.use_remote_gateways = use_remote_gateways

return sdk_no_wait(no_wait, client.create_or_update,
return sdk_no_wait(no_wait, client.begin_create_or_update,
virtual_network_peering_parameters=peering,
resource_group_name=resource_group_name,
workspace_name=workspace_name,
Expand Down Expand Up @@ -158,15 +158,15 @@ def update_databricks_vnet_peering(client, resource_group_name, workspace_name,
if use_remote_gateways is not None:
peering.use_remote_gateways = use_remote_gateways

return sdk_no_wait(no_wait, client.create_or_update,
return sdk_no_wait(no_wait, client.begin_create_or_update,
virtual_network_peering_parameters=peering,
resource_group_name=resource_group_name,
workspace_name=workspace_name,
peering_name=peering_name)


def delete_databricks_vnet_peering(client, resource_group_name, workspace_name, peering_name, no_wait=False):
return sdk_no_wait(no_wait, client.delete,
return sdk_no_wait(no_wait, client.begin_delete,
resource_group_name=resource_group_name,
workspace_name=workspace_name,
peering_name=peering_name)
1,459 changes: 957 additions & 502 deletions src/databricks/azext_databricks/tests/latest/recordings/test_databricks.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,19 +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.
#
# 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 DatabricksClientConfiguration
from ._databricks_client import DatabricksClient
__all__ = ['DatabricksClient', 'DatabricksClientConfiguration']

from .version import VERSION
from ._version import VERSION

__version__ = VERSION
__all__ = ['DatabricksClient']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
@@ -1,48 +1,71 @@
# 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 msrestazure import AzureConfiguration

from .version import VERSION
from typing import TYPE_CHECKING

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

from ._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

from azure.core.credentials import TokenCredential


class DatabricksClientConfiguration(Configuration):
"""Configuration for DatabricksClient.

class DatabricksClientConfiguration(AzureConfiguration):
"""Configuration for DatabricksClient
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 credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription.
: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(DatabricksClientConfiguration, self).__init__(base_url)

# Starting Autorest.Python 4.0.64, make connection pool activated by default
self.keep_alive = True
super(DatabricksClientConfiguration, self).__init__(**kwargs)

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

self.credentials = credentials
self.credential = credential
self.subscription_id = subscription_id
self.api_version = "2018-04-01"
self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default'])
kwargs.setdefault('sdk_moniker', 'mgmt-databricks/{}'.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)
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# 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 msrest.service_client import SDKClient
from msrest import Serializer, Deserializer
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 azure.core.credentials import TokenCredential

from ._configuration import DatabricksClientConfiguration
from .operations import WorkspacesOperations
Expand All @@ -19,41 +24,57 @@
from . import models


class DatabricksClient(SDKClient):
"""ARM Databricks
class DatabricksClient(object):
"""ARM Databricks.

:ivar config: Configuration for client.
:vartype config: DatabricksClientConfiguration

:ivar workspaces: Workspaces operations
:ivar workspaces: WorkspacesOperations operations
:vartype workspaces: azure.mgmt.databricks.operations.WorkspacesOperations
:ivar vnet_peering: VNetPeering operations
:ivar vnet_peering: VNetPeeringOperations operations
:vartype vnet_peering: azure.mgmt.databricks.operations.VNetPeeringOperations
:ivar operations: Operations operations
:vartype operations: azure.mgmt.databricks.operations.Operations

:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription.
:type subscription_id: str
:param str base_url: Service URL
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
"""

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

self.config = DatabricksClientConfiguration(credentials, subscription_id, base_url)
super(DatabricksClient, self).__init__(self.config.credentials, self.config)
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 = DatabricksClientConfiguration(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.api_version = '2018-04-01'
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)

self.workspaces = WorkspacesOperations(
self._client, self.config, self._serialize, self._deserialize)
self._client, self._config, self._serialize, self._deserialize)
self.vnet_peering = VNetPeeringOperations(
self._client, self.config, self._serialize, self._deserialize)
self._client, self._config, self._serialize, self._deserialize)
self.operations = Operations(
self._client, self.config, self._serialize, self._deserialize)
self._client, self._config, self._serialize, self._deserialize)

def close(self):
# type: () -> None
self._client.close()

def __enter__(self):
# type: () -> DatabricksClient
self._client.__enter__()
return self

def __exit__(self, *exc_details):
# type: (Any) -> None
self._client.__exit__(*exc_details)
Original file line number Diff line number Diff line change
@@ -1,13 +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.
#
# 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.
# --------------------------------------------------------------------------

VERSION = "0.1.0"

VERSION = "1.0.0"
Original file line number Diff line number Diff line change
@@ -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 ._databricks_client import DatabricksClient
__all__ = ['DatabricksClient']
Loading