Exemple #1
0
def get_subscription_service_client(cli_ctx):
    return _get_mgmt_service_client(
        cli_ctx,
        get_client_class(ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS),
        subscription_bound=False,
        api_version=get_api_version(cli_ctx,
                                    ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS))
Exemple #2
0
def get_mgmt_service_client(cli_ctx, client_or_resource_type, subscription_id=None, api_version=None,
                            aux_subscriptions=None, **kwargs):
    """
     :params subscription_id: the current account's subscription
     :param aux_subscriptions: mainly for cross tenant scenarios, say vnet peering.
    """
    if not subscription_id and 'subscription_id' in cli_ctx.data:
        subscription_id = cli_ctx.data['subscription_id']

    sdk_profile = None
    if isinstance(client_or_resource_type, (ResourceType, CustomResourceType)):
        # Get the versioned client
        client_type = get_client_class(client_or_resource_type)
        api_version = api_version or get_api_version(cli_ctx, client_or_resource_type, as_sdk_profile=True)
        if isinstance(api_version, SDKProfile):
            sdk_profile = api_version.profile
            api_version = None
    else:
        # Get the non-versioned client
        client_type = client_or_resource_type
    client, _ = _get_mgmt_service_client(cli_ctx, client_type, subscription_id=subscription_id,
                                         api_version=api_version, sdk_profile=sdk_profile,
                                         aux_subscriptions=aux_subscriptions,
                                         **kwargs)
    return client
Exemple #3
0
def get_mgmt_service_client(cli_ctx,
                            client_or_resource_type,
                            subscription_id=None,
                            api_version=None,
                            aux_subscriptions=None,
                            aux_tenants=None,
                            **kwargs):
    """
     :params subscription_id: the current account's subscription
     :param aux_subscriptions: mainly for cross tenant scenarios, say vnet peering.
    """
    if not subscription_id and 'subscription_id' in cli_ctx.data:
        subscription_id = cli_ctx.data['subscription_id']

    sdk_profile = None
    if isinstance(client_or_resource_type, (ResourceType, CustomResourceType)):
        # Get the versioned client
        client_type = get_client_class(client_or_resource_type)
        api_version = api_version or get_api_version(
            cli_ctx, client_or_resource_type, as_sdk_profile=True)
        if isinstance(api_version, SDKProfile):
            sdk_profile = api_version.profile
            api_version = None
    else:
        # Get the non-versioned client
        client_type = client_or_resource_type
    client, _ = _get_mgmt_service_client(cli_ctx,
                                         client_type,
                                         subscription_id=subscription_id,
                                         api_version=api_version,
                                         sdk_profile=sdk_profile,
                                         aux_subscriptions=aux_subscriptions,
                                         aux_tenants=aux_tenants,
                                         **kwargs)
    return client
Exemple #4
0
 def create_arm_client_factory(credentials):
     if arm_client_factory:
         return arm_client_factory(credentials)
     from azure.cli.core.profiles._shared import get_client_class
     from azure.cli.core.profiles import get_api_version, ResourceType
     from azure.cli.core._debug import change_ssl_cert_verification
     client_type = get_client_class(ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS)
     api_version = get_api_version(ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS)
     return change_ssl_cert_verification(client_type(credentials, api_version=api_version,
                                                     base_url=CLOUD.endpoints.resource_manager))
Exemple #5
0
 def create_arm_client_factory(credentials):
     if arm_client_factory:
         return arm_client_factory(credentials)
     from azure.cli.core.profiles._shared import get_client_class
     from azure.cli.core.profiles import ResourceType, get_api_version
     from azure.cli.core._debug import change_ssl_cert_verification
     client_type = get_client_class(ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS)
     api_version = get_api_version(cli_ctx, ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS)
     return change_ssl_cert_verification(client_type(credentials, api_version=api_version,
                                                     base_url=self.cli_ctx.cloud.endpoints.resource_manager))
def get_mgmt_service_client(client_or_resource_type, subscription_id=None, api_version=None,
                            **kwargs):
    if isinstance(client_or_resource_type, ResourceType):
        # Get the versioned client
        client_type = get_client_class(client_or_resource_type)
        api_version = api_version or get_api_version(client_or_resource_type)
    else:
        # Get the non-versioned client
        client_type = client_or_resource_type
    client, _ = _get_mgmt_service_client(client_type, subscription_id=subscription_id,
                                         api_version=api_version, **kwargs)
    return client
Exemple #7
0
def get_mgmt_service_client(client_or_resource_type,
                            subscription_id=None,
                            api_version=None,
                            **kwargs):
    if isinstance(client_or_resource_type, ResourceType):
        # Get the versioned client
        client_type = get_client_class(client_or_resource_type)
        api_version = api_version or get_api_version(client_or_resource_type)
    else:
        # Get the non-versioned client
        client_type = client_or_resource_type
    client, _ = _get_mgmt_service_client(client_type,
                                         subscription_id=subscription_id,
                                         api_version=api_version,
                                         **kwargs)
    return client
def get_mgmt_service_client(cli_ctx, client_or_resource_type, subscription_id=None, api_version=None,
                            **kwargs):
    sdk_profile = None
    if isinstance(client_or_resource_type, (ResourceType, CustomResourceType)):
        # Get the versioned client
        client_type = get_client_class(client_or_resource_type)
        api_version = api_version or get_api_version(cli_ctx, client_or_resource_type, as_sdk_profile=True)
        if isinstance(api_version, SDKProfile):
            sdk_profile = api_version.profile
            api_version = None
    else:
        # Get the non-versioned client
        client_type = client_or_resource_type
    client, _ = _get_mgmt_service_client(cli_ctx, client_type, subscription_id=subscription_id,
                                         api_version=api_version, sdk_profile=sdk_profile, **kwargs)
    return client
def get_mgmt_service_client(client_or_resource_type,
                            subscription_id=None,
                            api_version=None,
                            **kwargs):
    sdk_profile = None
    if isinstance(client_or_resource_type, ResourceType):
        # Get the versioned client
        client_type = get_client_class(client_or_resource_type)
        api_version = api_version or get_api_version(client_or_resource_type,
                                                     as_sdk_profile=True)
        if isinstance(api_version, SDKProfile):
            sdk_profile = api_version.profile
            api_version = api_version.default_api_version
    else:
        # Get the non-versioned client
        client_type = client_or_resource_type
    client, _ = _get_mgmt_service_client(client_type,
                                         subscription_id=subscription_id,
                                         api_version=api_version,
                                         sdk_profile=sdk_profile,
                                         **kwargs)
    return client
Exemple #10
0
    def _create_subscription_client(self, credential):
        from azure.cli.core.profiles import ResourceType, get_api_version
        from azure.cli.core.profiles._shared import get_client_class
        from azure.cli.core.commands.client_factory import _prepare_mgmt_client_kwargs_track2

        client_type = get_client_class(
            ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS)
        if client_type is None:
            from azure.cli.core.azclierror import CLIInternalError
            raise CLIInternalError("Unable to get '{}' in profile '{}'".format(
                ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS,
                self.cli_ctx.cloud.profile))
        api_version = get_api_version(self.cli_ctx,
                                      ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS)
        client_kwargs = _prepare_mgmt_client_kwargs_track2(
            self.cli_ctx, credential)

        client = client_type(
            credential,
            api_version=api_version,
            base_url=self.cli_ctx.cloud.endpoints.resource_manager,
            **client_kwargs)
        return client
def get_subscription_service_client():
    return _get_mgmt_service_client(get_client_class(ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS),
                                    subscription_bound=False,
                                    api_version=get_api_version(ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS))