From b43fa4183b8b07b0bb19d5ec733d5cb15774a436 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Wed, 22 Apr 2020 04:54:53 +0000 Subject: [PATCH] Generated from 3dc65df09a9d1da28d608a8319e568b568899514 Merge branch 'master' into dev-kubernetesconfiguration-Microsoft.KubernetesConfiguration-2019-11-01-preview --- src/devops/HISTORY.rst | 8 + src/devops/README.md | 5 + src/devops/azext_devops/__init__.py | 46 ++ src/devops/azext_devops/action.py | 17 + src/devops/azext_devops/azext_metadata.json | 4 + src/devops/azext_devops/custom.py | 17 + src/devops/azext_devops/generated/__init__.py | 12 + .../azext_devops/generated/_client_factory.py | 23 + src/devops/azext_devops/generated/_help.py | 87 +++ src/devops/azext_devops/generated/_params.py | 76 +++ .../azext_devops/generated/_validators.py | 23 + src/devops/azext_devops/generated/action.py | 126 ++++ src/devops/azext_devops/generated/commands.py | 36 ++ src/devops/azext_devops/generated/custom.py | 74 +++ src/devops/azext_devops/manual/__init__.py | 12 + src/devops/azext_devops/tests/__init__.py | 49 ++ .../azext_devops/tests/latest/__init__.py | 12 + .../azext_devops/tests/latest/preparers.py | 116 ++++ .../tests/latest/test_devops_scenario.py | 124 ++++ .../azext_devops/vendored_sdks/__init__.py | 12 + .../vendored_sdks/devops/__init__.py | 19 + .../vendored_sdks/devops/_azure_dev_ops.py | 76 +++ .../vendored_sdks/devops/_configuration.py | 69 +++ .../vendored_sdks/devops/_version.py | 9 + .../vendored_sdks/devops/aio/__init__.py | 10 + .../devops/aio/_azure_dev_ops_async.py | 68 +++ .../devops/aio/_configuration_async.py | 65 +++ .../devops/aio/operations_async/__init__.py | 17 + .../_operation_operations_async.py | 100 ++++ .../_pipeline_operations_async.py | 503 ++++++++++++++++ ...ne_template_definition_operations_async.py | 100 ++++ .../vendored_sdks/devops/models/__init__.py | 59 ++ .../devops/models/_azure_dev_ops_enums.py | 26 + .../vendored_sdks/devops/models/_models.py | 487 ++++++++++++++++ .../devops/models/_models_py3.py | 537 ++++++++++++++++++ .../devops/operations/__init__.py | 17 + .../operations/_operation_operations.py | 105 ++++ .../devops/operations/_pipeline_operations.py | 514 +++++++++++++++++ ...pipeline_template_definition_operations.py | 105 ++++ .../vendored_sdks/devops/py.typed | 1 + src/devops/report.md | 59 ++ src/devops/setup.cfg | 1 + src/devops/setup.py | 53 ++ 43 files changed, 3879 insertions(+) create mode 100644 src/devops/HISTORY.rst create mode 100644 src/devops/README.md create mode 100644 src/devops/azext_devops/__init__.py create mode 100644 src/devops/azext_devops/action.py create mode 100644 src/devops/azext_devops/azext_metadata.json create mode 100644 src/devops/azext_devops/custom.py create mode 100644 src/devops/azext_devops/generated/__init__.py create mode 100644 src/devops/azext_devops/generated/_client_factory.py create mode 100644 src/devops/azext_devops/generated/_help.py create mode 100644 src/devops/azext_devops/generated/_params.py create mode 100644 src/devops/azext_devops/generated/_validators.py create mode 100644 src/devops/azext_devops/generated/action.py create mode 100644 src/devops/azext_devops/generated/commands.py create mode 100644 src/devops/azext_devops/generated/custom.py create mode 100644 src/devops/azext_devops/manual/__init__.py create mode 100644 src/devops/azext_devops/tests/__init__.py create mode 100644 src/devops/azext_devops/tests/latest/__init__.py create mode 100644 src/devops/azext_devops/tests/latest/preparers.py create mode 100644 src/devops/azext_devops/tests/latest/test_devops_scenario.py create mode 100644 src/devops/azext_devops/vendored_sdks/__init__.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/__init__.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/_azure_dev_ops.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/_configuration.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/_version.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/aio/__init__.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/aio/_azure_dev_ops_async.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/aio/_configuration_async.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/__init__.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/_operation_operations_async.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/_pipeline_operations_async.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/_pipeline_template_definition_operations_async.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/models/__init__.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/models/_azure_dev_ops_enums.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/models/_models.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/models/_models_py3.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/operations/__init__.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/operations/_operation_operations.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/operations/_pipeline_operations.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/operations/_pipeline_template_definition_operations.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/py.typed create mode 100644 src/devops/report.md create mode 100644 src/devops/setup.cfg create mode 100644 src/devops/setup.py diff --git a/src/devops/HISTORY.rst b/src/devops/HISTORY.rst new file mode 100644 index 00000000000..27f152061e8 --- /dev/null +++ b/src/devops/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. diff --git a/src/devops/README.md b/src/devops/README.md new file mode 100644 index 00000000000..c619d0f8a11 --- /dev/null +++ b/src/devops/README.md @@ -0,0 +1,5 @@ +Microsoft Azure CLI 'devops' Extension +========================================== + +This package is for the 'devops' extension. +i.e. 'az devops' diff --git a/src/devops/azext_devops/__init__.py b/src/devops/azext_devops/__init__.py new file mode 100644 index 00000000000..625b460503f --- /dev/null +++ b/src/devops/azext_devops/__init__.py @@ -0,0 +1,46 @@ +# -------------------------------------------------------------------------- +# 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 azure.cli.core import AzCommandsLoader +from azext_devops.generated._help import helps # pylint: disable=unused-import + + +class AzureDevOpsCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from azext_devops.generated._client_factory import cf_devops + devops_custom = CliCommandType( + operations_tmpl='azext_devops.custom#{}', + client_factory=cf_devops) + super(AzureDevOpsCommandsLoader, self).__init__(cli_ctx=cli_ctx, + custom_command_type=devops_custom) + + def load_command_table(self, args): + from azext_devops.generated.commands import load_command_table + load_command_table(self, args) + try: + from azext_devops.manual.commands import load_command_table as load_command_table_manual + load_command_table_manual(self, args) + except ImportError: + pass + return self.command_table + + def load_arguments(self, command): + from azext_devops.generated._params import load_arguments + load_arguments(self, command) + try: + from azext_devops.manual._params import load_arguments as load_arguments_manual + load_arguments_manual(self, command) + except ImportError: + pass + + +COMMAND_LOADER_CLS = AzureDevOpsCommandsLoader diff --git a/src/devops/azext_devops/action.py b/src/devops/azext_devops/action.py new file mode 100644 index 00000000000..a846b2766c4 --- /dev/null +++ b/src/devops/azext_devops/action.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# 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.action import * # noqa: F403 +try: + from .manual.action import * # noqa: F403 +except ImportError: + pass diff --git a/src/devops/azext_devops/azext_metadata.json b/src/devops/azext_devops/azext_metadata.json new file mode 100644 index 00000000000..7b56fb1e11a --- /dev/null +++ b/src/devops/azext_devops/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isExperimental": true, + "azext.minCliCoreVersion": "2.3.1" +} \ No newline at end of file diff --git a/src/devops/azext_devops/custom.py b/src/devops/azext_devops/custom.py new file mode 100644 index 00000000000..7f31674ce96 --- /dev/null +++ b/src/devops/azext_devops/custom.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# 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 diff --git a/src/devops/azext_devops/generated/__init__.py b/src/devops/azext_devops/generated/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/devops/azext_devops/generated/__init__.py @@ -0,0 +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__) diff --git a/src/devops/azext_devops/generated/_client_factory.py b/src/devops/azext_devops/generated/_client_factory.py new file mode 100644 index 00000000000..c1daa170387 --- /dev/null +++ b/src/devops/azext_devops/generated/_client_factory.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + + +def cf_devops(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from ..vendored_sdks.devops import AzureDevOps + return get_mgmt_service_client(cli_ctx, AzureDevOps) + + +def cf_pipeline_template_definition(cli_ctx, *_): + return cf_devops(cli_ctx).pipeline_template_definition + + +def cf_pipeline(cli_ctx, *_): + return cf_devops(cli_ctx).pipeline diff --git a/src/devops/azext_devops/generated/_help.py b/src/devops/azext_devops/generated/_help.py new file mode 100644 index 00000000000..08107bddd80 --- /dev/null +++ b/src/devops/azext_devops/generated/_help.py @@ -0,0 +1,87 @@ +# -------------------------------------------------------------------------- +# 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=too-many-lines + +from knack.help_files import helps + + +helps['devops pipeline-template-definition'] = """ + type: group + short-summary: devops pipeline-template-definition +""" + +helps['devops pipeline-template-definition list'] = """ + type: command + short-summary: Lists all pipeline templates which can be used to configure an Azure Pipeline. + examples: + - name: Get the list of pipeline template definitions + text: |- + az devops pipeline-template-definition list +""" + +helps['devops pipeline'] = """ + type: group + short-summary: devops pipeline +""" + +helps['devops pipeline list'] = """ + type: command + short-summary: Lists all Azure Pipelines under the specified subscription. + examples: + - name: List all Azure Pipelines under the specified resource group + text: |- + az devops pipeline list --resource-group "myAspNetWebAppPipeline-rg" +""" + +helps['devops pipeline show'] = """ + type: command + short-summary: Gets an existing Azure Pipeline. + examples: + - name: Get an existing Azure pipeline + text: |- + az devops pipeline show --pipeline-name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipelin\ +e-rg" +""" + +helps['devops pipeline create'] = """ + type: command + short-summary: Creates or updates an Azure Pipeline. + examples: + - name: Create an Azure pipeline to deploy a sample ASP.Net application to Azure web-app + text: |- + az devops pipeline create --location "South India" --bootstrap-configuration-repository-properties boots\ +trapConfiguration={"template":{"id":"ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp","parameters":{\ +"appInsightLocation":"South India","appServicePlan":"S1 Standard","azureAuth":"{\\"scheme\\":\\"ServicePrincipal\\",\\"\ +parameters\\":{\\"tenantid\\":\\"{subscriptionTenantId}\\",\\"objectid\\":\\"{appObjectId}\\",\\"serviceprincipalid\\":\ +\\"{appId}\\",\\"serviceprincipalkey\\":\\"{appSecret}\\"}}","location":"South India","resourceGroup":"myAspNetWebAppPi\ +peline-rg","subscriptionId":"{subscriptionId}","webAppName":"myAspNetWebApp"}}} organization={"name":"myAspNetWebAppPip\ +eline-org"} project={"name":"myAspNetWebAppPipeline-project"} --pipeline-name "myAspNetWebAppPipeline" --resource-group\ + "myAspNetWebAppPipeline-rg" +""" + +helps['devops pipeline update'] = """ + type: command + short-summary: Updates the properties of an Azure Pipeline. Currently, only tags can be updated. + examples: + - name: Get an existing Azure pipeline + text: |- + az devops pipeline update --pipeline-name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipel\ +ine-rg" --tags tagKey="tagvalue" +""" + +helps['devops pipeline delete'] = """ + type: command + short-summary: Deletes an Azure Pipeline. + examples: + - name: Get an existing Azure pipeline + text: |- + az devops pipeline delete --pipeline-name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipel\ +ine-rg" +""" diff --git a/src/devops/azext_devops/generated/_params.py b/src/devops/azext_devops/generated/_params.py new file mode 100644 index 00000000000..36e1429ca52 --- /dev/null +++ b/src/devops/azext_devops/generated/_params.py @@ -0,0 +1,76 @@ +# -------------------------------------------------------------------------- +# 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=too-many-lines +# pylint: disable=too-many-statements + +from knack.arguments import CLIArgumentType +from azure.cli.core.commands.parameters import ( + tags_type, + get_enum_type, + resource_group_name_type, + get_location_type +) +from azure.cli.core.commands.validators import get_default_location_from_resource_group +from azext_devops.action import ( + AddOrganization, + AddProject, + AddBootstrapConfigurationTemplateParameters, + AddBootstrapConfigurationRepositoryProperties, + AddBootstrapConfigurationRepositoryAuthorizationParameters +) + + +def load_arguments(self, _): + + with self.argument_context('devops pipeline-template-definition list') as c: + pass + + with self.argument_context('devops pipeline list') as c: + c.argument('resource_group_name', resource_group_name_type) + + with self.argument_context('devops pipeline show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('pipeline_name', help='The name of the Azure Pipeline resource in ARM.') + + with self.argument_context('devops pipeline create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('pipeline_name', help='The name of the Azure Pipeline resource in ARM.') + c.argument('tags', tags_type) + c.argument('location', arg_type=get_location_type(self.cli_ctx), + validator=get_default_location_from_resource_group) + c.argument('organization', action=AddOrganization, nargs='+', help='Reference to the Azure DevOps Organization ' + 'containing the Pipeline. Expect value: name=xx.') + c.argument('project', action=AddProject, nargs='+', help='Reference to the Azure DevOps Project containing the ' + 'Pipeline. Expect value: name=xx.') + c.argument('bootstrap_configuration_template_id', help='Unique identifier of the pipeline template.') + c.argument('bootstrap_configuration_template_parameters', action=AddBootstrapConfigurationTemplateParameters, + nargs='+', help='Dictionary of input parameters used in the pipeline template. Expect value: KEY1=VA' + 'LUE1 KEY2=VALUE2 ...') + c.argument('bootstrap_configuration_repository_repository_type', arg_type=get_enum_type(['gitHub', 'vstsGit']), + help='Type of code repository.') + c.argument('bootstrap_configuration_repository_id', + help='Unique immutable identifier of the code repository.') + c.argument('bootstrap_configuration_repository_default_branch', help='Default branch used to configure Continuo' + 'us Integration (CI) in the pipeline.') + c.argument('bootstrap_configuration_repository_properties', + action=AddBootstrapConfigurationRepositoryProperties, nargs='+', help='Repository-specific propertie' + 's. Expect value: KEY1=VALUE1 KEY2=VALUE2 ...') + c.argument('bootstrap_configuration_repository_authorization_parameters', + action=AddBootstrapConfigurationRepositoryAuthorizationParameters, nargs='+', help='Authorization pa' + 'rameters corresponding to the authorization type. Expect value: KEY1=VALUE1 KEY2=VALUE2 ...') + + with self.argument_context('devops pipeline update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('pipeline_name', help='The name of the Azure Pipeline resource.') + c.argument('tags', tags_type) + + with self.argument_context('devops pipeline delete') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('pipeline_name', help='The name of the Azure Pipeline resource.') diff --git a/src/devops/azext_devops/generated/_validators.py b/src/devops/azext_devops/generated/_validators.py new file mode 100644 index 00000000000..7536d0531ea --- /dev/null +++ b/src/devops/azext_devops/generated/_validators.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + + +def example_name_or_id_validator(cmd, namespace): + from azure.cli.core.commands.client_factory import get_subscription_id + from msrestazure.tools import is_valid_resource_id, resource_id + if namespace.storage_account: + if not is_valid_resource_id(namespace.RESOURCE): + namespace.storage_account = resource_id( + subscription=get_subscription_id(cmd.cli_ctx), + resource_group=namespace.resource_group_name, + namespace='Microsoft.Storage', + type='storageAccounts', + name=namespace.storage_account + ) diff --git a/src/devops/azext_devops/generated/action.py b/src/devops/azext_devops/generated/action.py new file mode 100644 index 00000000000..9fb61297585 --- /dev/null +++ b/src/devops/azext_devops/generated/action.py @@ -0,0 +1,126 @@ +# -------------------------------------------------------------------------- +# 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=protected-access + +import argparse +from knack.util import CLIError +from collections import defaultdict + + +class AddOrganization(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.organization = action + + + 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 == 'name': + d['name'] = v[0] + return d + + +class AddProject(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.project = action + + + 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 == 'name': + d['name'] = v[0] + return d + + +class AddBootstrapConfigurationTemplateParameters(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.bootstrap_configuration_template_parameters = action + + + 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] + d[k] = v + return d + + +class AddBootstrapConfigurationRepositoryProperties(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.bootstrap_configuration_repository_properties = action + + + 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] + d[k] = v + return d + + +class AddBootstrapConfigurationRepositoryAuthorizationParameters(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.bootstrap_configuration_repository_authorization_parameters = action + + + 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] + d[k] = v + return d diff --git a/src/devops/azext_devops/generated/commands.py b/src/devops/azext_devops/generated/commands.py new file mode 100644 index 00000000000..5ec0a3f8e84 --- /dev/null +++ b/src/devops/azext_devops/generated/commands.py @@ -0,0 +1,36 @@ +# -------------------------------------------------------------------------- +# 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 azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): + + from azext_devops.generated._client_factory import cf_pipeline_template_definition + devops_pipeline_template_definition = CliCommandType( + operations_tmpl='azext_devops.vendored_sdks.devops.operations._pipeline_template_definition_operations#Pipeline' + 'TemplateDefinitionOperations.{}', + client_factory=cf_pipeline_template_definition) + with self.command_group('devops pipeline-template-definition', devops_pipeline_template_definition, + client_factory=cf_pipeline_template_definition, is_experimental=True) as g: + g.custom_command('list', 'devops_pipeline_template_definition_list') + + from azext_devops.generated._client_factory import cf_pipeline + devops_pipeline = CliCommandType( + operations_tmpl='azext_devops.vendored_sdks.devops.operations._pipeline_operations#PipelineOperations.{}', + client_factory=cf_pipeline) + with self.command_group('devops pipeline', devops_pipeline, client_factory=cf_pipeline, + is_experimental=True) as g: + g.custom_command('list', 'devops_pipeline_list') + g.custom_show_command('show', 'devops_pipeline_show') + g.custom_command('create', 'devops_pipeline_create', supports_no_wait=True) + g.custom_command('update', 'devops_pipeline_update') + g.custom_command('delete', 'devops_pipeline_delete') + g.wait_command('wait') diff --git a/src/devops/azext_devops/generated/custom.py b/src/devops/azext_devops/generated/custom.py new file mode 100644 index 00000000000..dda8173e7e8 --- /dev/null +++ b/src/devops/azext_devops/generated/custom.py @@ -0,0 +1,74 @@ +# -------------------------------------------------------------------------- +# 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=line-too-long +# pylint: disable=too-many-lines + + +def devops_pipeline_template_definition_list(cmd, client): + return client.list() + + +def devops_pipeline_list(cmd, client, + resource_group_name=None): + if resource_group_name is not None: + return client.list_by_resource_group(resource_group_name=resource_group_name) + return client.list_by_subscription() + + +def devops_pipeline_show(cmd, client, + resource_group_name, + pipeline_name): + return client.get(resource_group_name=resource_group_name, + pipeline_name=pipeline_name) + + +def devops_pipeline_create(cmd, client, + resource_group_name, + pipeline_name, + organization, + project, + bootstrap_configuration_template_id, + tags=None, + location=None, + bootstrap_configuration_template_parameters=None, + bootstrap_configuration_repository_repository_type=None, + bootstrap_configuration_repository_id=None, + bootstrap_configuration_repository_default_branch=None, + bootstrap_configuration_repository_properties=None, + bootstrap_configuration_repository_authorization_parameters=None): + return client.begin_create_or_update(resource_group_name=resource_group_name, + pipeline_name=pipeline_name, + tags=tags, + location=location, + organization=organization, + project=project, + id=bootstrap_configuration_template_id, + parameters=bootstrap_configuration_template_parameters, + repository_type=bootstrap_configuration_repository_repository_type, + code_repository_id=bootstrap_configuration_repository_id, + default_branch=bootstrap_configuration_repository_default_branch, + properties=bootstrap_configuration_repository_properties, + authorization_parameters=bootstrap_configuration_repository_authorization_parameters) + + +def devops_pipeline_update(cmd, client, + resource_group_name, + pipeline_name, + tags=None): + return client.update(resource_group_name=resource_group_name, + pipeline_name=pipeline_name, + tags=tags) + + +def devops_pipeline_delete(cmd, client, + resource_group_name, + pipeline_name): + return client.delete(resource_group_name=resource_group_name, + pipeline_name=pipeline_name) diff --git a/src/devops/azext_devops/manual/__init__.py b/src/devops/azext_devops/manual/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/devops/azext_devops/manual/__init__.py @@ -0,0 +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__) diff --git a/src/devops/azext_devops/tests/__init__.py b/src/devops/azext_devops/tests/__init__.py new file mode 100644 index 00000000000..fe1bd438b46 --- /dev/null +++ b/src/devops/azext_devops/tests/__init__.py @@ -0,0 +1,49 @@ +# 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. +# -------------------------------------------------------------------------- +import inspect +import os + + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) + + +def try_manual(func): + def import_manual_function(origin_func): + from importlib import import_module + decorated_path = inspect.getfile(origin_func) + module_path = __path__[0] + if not decorated_path.startswith(module_path): + raise Exception("Decorator can only be used in submodules!") + manual_path = os.path.join( + decorated_path[module_path.rfind(os.path.sep) + 1:]) + manual_file_path, manual_file_name = os.path.split(manual_path) + module_name, _ = os.path.splitext(manual_file_name) + manual_module = "..manual." + \ + ".".join(manual_file_path.split(os.path.sep) + [module_name, ]) + return getattr(import_module(manual_module, package=__name__), origin_func.__name__) + + def get_func_to_call(): + func_to_call = func + try: + func_to_call = import_manual_function(func) + except (ImportError, AttributeError): + pass + return func_to_call + + def wrapper(*args, **kwargs): + func_to_call = get_func_to_call() + print("running {}()...".format(func.__name__)) + return func_to_call(*args, **kwargs) + + if inspect.isclass(func): + return get_func_to_call() + else: + return wrapper diff --git a/src/devops/azext_devops/tests/latest/__init__.py b/src/devops/azext_devops/tests/latest/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/devops/azext_devops/tests/latest/__init__.py @@ -0,0 +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__) diff --git a/src/devops/azext_devops/tests/latest/preparers.py b/src/devops/azext_devops/tests/latest/preparers.py new file mode 100644 index 00000000000..3d6672de64f --- /dev/null +++ b/src/devops/azext_devops/tests/latest/preparers.py @@ -0,0 +1,116 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +import os +from datetime import datetime +from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer +from azure_devtools.scenario_tests import SingleValueReplacer +from azure.cli.testsdk.exceptions import CliTestError +from azure.cli.testsdk.reverse_dependency import get_dummy_cli + + +KEY_RESOURCE_GROUP = 'rg' +KEY_VIRTUAL_NETWORK = 'vnet' +KEY_VNET_SUBNET = 'subnet' + + +class VirtualNetworkPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='virtual_network', + resource_group_name=None, + resource_group_key=KEY_RESOURCE_GROUP, + dev_setting_name='AZURE_CLI_TEST_DEV_VIRTUAL_NETWORK_NAME', + random_name_length=24, key=KEY_VIRTUAL_NETWORK): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VirtualNetworkPreparer, self).__init__( + name_prefix, random_name_length) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group_name = resource_group_name + self.resource_group_key = resource_group_key + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **kwargs): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group_name: + self.resource_group_name = self.test_class_instance.kwargs.get( + self.resource_group_key) + if not self.resource_group_name: + raise CliTestError("Error: No resource group configured!") + + tags = {'product': 'azurecli', 'cause': 'automation', + 'date': datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')} + if 'ENV_JOB_NAME' in os.environ: + tags['job'] = os.environ['ENV_JOB_NAME'] + tags = ' '.join(['{}={}'.format(key, value) + for key, value in tags.items()]) + template = 'az network vnet create --resource-group {} --name {} --tag ' + tags + self.live_only_execute(self.cli_ctx, template.format( + self.resource_group_name, name)) + + self.test_class_instance.kwargs[self.key] = name + return {self.parameter_name: name} + + def remove_resource(self, name, **kwargs): + # delete vnet if test is being recorded and if the vnet is not a dev rg + if not self.dev_setting_name: + self.live_only_execute( + self.cli_ctx, 'az network vnet delete --name {} --resource-group {}'.format(name, self.resource_group_name)) + + +class VnetSubnetPreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest.vn', + parameter_name='subnet', + resource_group_name=None, + resource_group_key=KEY_RESOURCE_GROUP, + vnet_name=None, + vnet_key=KEY_VIRTUAL_NETWORK, + address_prefixes="11.0.0.0/24", + dev_setting_name='AZURE_CLI_TEST_DEV_VNET_SUBNET_NAME', + random_name_length=24, key=KEY_VNET_SUBNET): + if ' ' in name_prefix: + raise CliTestError( + 'Error: Space character in name prefix \'%s\'' % name_prefix) + super(VnetSubnetPreparer, self).__init__( + name_prefix, random_name_length) + self.cli_ctx = get_dummy_cli() + self.parameter_name = parameter_name + self.key = key + self.resource_group_name = resource_group_name + self.resource_group_key = resource_group_key + self.vnet_name = vnet_name + self.vnet_key = vnet_key + self.address_prefixes = address_prefixes + self.dev_setting_name = os.environ.get(dev_setting_name, None) + + def create_resource(self, name, **kwargs): + if self.dev_setting_name: + return {self.parameter_name: self.dev_setting_name, } + + if not self.resource_group_name: + self.resource_group_name = self.test_class_instance.kwargs.get( + self.resource_group_key) + if not self.resource_group_name: + raise CliTestError("Error: No resource group configured!") + if not self.vnet_name: + self.vnet_name = self.test_class_instance.kwargs.get(self.vnet_key) + if not self.vnet_name: + raise CliTestError("Error: No vnet configured!") + + self.test_class_instance.kwargs[self.key] = 'default' + return {self.parameter_name: name} + + def remove_resource(self, name, **kwargs): + pass diff --git a/src/devops/azext_devops/tests/latest/test_devops_scenario.py b/src/devops/azext_devops/tests/latest/test_devops_scenario.py new file mode 100644 index 00000000000..ff1f7b09957 --- /dev/null +++ b/src/devops/azext_devops/tests/latest/test_devops_scenario.py @@ -0,0 +1,124 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +import os +import unittest + +from azure_devtools.scenario_tests import AllowLargeResponse +from azure.cli.testsdk import ScenarioTest +from .. import try_manual +from azure.cli.testsdk import ResourceGroupPreparer + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +@try_manual +def setup(test, rg): + pass + + +# EXAMPLE: /PipelineTemplateDefinitions/get/Get the list of pipeline template definitions +@try_manual +def step__pipelinetemplatedefinitions_get_get_the_list_of_pipeline_template_definitions(test, rg): + test.cmd('az devops pipeline-template-definition list', + checks=[]) + + +# EXAMPLE: /Pipelines/put/Create an Azure pipeline to deploy a sample ASP.Net application to Azure web-app +@try_manual +def step__pipelines_put_create_an_azure_pipeline_to_deploy_a_sample_asp_net_application_to_azure_web_app(test, rg): + test.cmd('az devops pipeline create ' + '--location "South India" ' + '--bootstrap-configuration-repository-properties bootstrapConfiguration={{"template":{{"id":"ms.vss-contin' + 'uous-delivery-pipeline-templates.aspnet-windowswebapp","parameters":{{"appInsightLocation":"South India",' + '"appServicePlan":"S1 Standard","azureAuth":"{{\\"scheme\\":\\"ServicePrincipal\\",\\"parameters\\":{{\\"t' + 'enantid\\":\\"{{subscriptionTenantId}}\\",\\"objectid\\":\\"{{appObjectId}}\\",\\"serviceprincipalid\\":' + '\\"{{appId}}\\",\\"serviceprincipalkey\\":\\"{{appSecret}}\\"}}}}","location":"South India","resourceGrou' + 'p":"myAspNetWebAppPipeline-rg","subscriptionId":"{{subscriptionId}}","webAppName":"myAspNetWebApp"}}}}}} ' + 'organization={{"name":"myAspNetWebAppPipeline-org"}} project={{"name":"myAspNetWebAppPipeline-project"}} ' + '' + '--pipeline-name "{myAspNetWebAppPipeline}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Pipelines/get/Get an existing Azure pipeline +@try_manual +def step__pipelines_get_get_an_existing_azure_pipeline(test, rg): + test.cmd('az devops pipeline show ' + '--pipeline-name "{myAspNetWebAppPipeline}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Pipelines/get/List all Azure Pipelines under the specified resource group +@try_manual +def step__pipelines_get_list_all_azure_pipelines_under_the_specified_resource_group(test, rg): + test.cmd('az devops pipeline list ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /Pipelines/get/List all Azure pipelines under the specified subscription +@try_manual +def step__pipelines_get_list_all_azure_pipelines_under_the_specified_subscription(test, rg): + test.cmd('az devops pipeline list', + checks=[]) + + +# EXAMPLE: /Pipelines/patch/Get an existing Azure pipeline +@try_manual +def step__pipelines_patch_get_an_existing_azure_pipeline(test, rg): + test.cmd('az devops pipeline update ' + '--pipeline-name "{myAspNetWebAppPipeline}" ' + '--resource-group "{rg}" ' + '--tags tagKey="tagvalue"', + checks=[]) + + +# EXAMPLE: /Pipelines/delete/Get an existing Azure pipeline +@try_manual +def step__pipelines_delete_get_an_existing_azure_pipeline(test, rg): + test.cmd('az devops pipeline delete ' + '--pipeline-name "{myAspNetWebAppPipeline}" ' + '--resource-group "{rg}"', + checks=[]) + + +@try_manual +def cleanup(test, rg): + pass + + +@try_manual +def call_scenario(test, rg): + setup(test, rg) + step__pipelinetemplatedefinitions_get_get_the_list_of_pipeline_template_definitions(test, rg) + step__pipelines_put_create_an_azure_pipeline_to_deploy_a_sample_asp_net_application_to_azure_web_app(test, rg) + step__pipelines_get_get_an_existing_azure_pipeline(test, rg) + step__pipelines_get_list_all_azure_pipelines_under_the_specified_resource_group(test, rg) + step__pipelines_get_list_all_azure_pipelines_under_the_specified_subscription(test, rg) + step__pipelines_patch_get_an_existing_azure_pipeline(test, rg) + step__pipelines_delete_get_an_existing_azure_pipeline(test, rg) + cleanup(test, rg) + + +@try_manual +class AzureDevOpsScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='clitestdevops_myAspNetWebAppPipeline-rg'[:7], key='rg', parameter_name='rg') + def test_devops(self, rg): + + self.kwargs.update({ + 'myAspNetWebAppPipeline': 'myAspNetWebAppPipeline', + }) + + call_scenario(self, rg) diff --git a/src/devops/azext_devops/vendored_sdks/__init__.py b/src/devops/azext_devops/vendored_sdks/__init__.py new file mode 100644 index 00000000000..ee0c4f36bd0 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/__init__.py @@ -0,0 +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__) diff --git a/src/devops/azext_devops/vendored_sdks/devops/__init__.py b/src/devops/azext_devops/vendored_sdks/devops/__init__.py new file mode 100644 index 00000000000..51457a4d4fd --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/__init__.py @@ -0,0 +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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._azure_dev_ops import AzureDevOps +from ._version import VERSION + +__version__ = VERSION +__all__ = ['AzureDevOps'] + +try: + from .patch import patch_sdk + patch_sdk() +except ImportError: + pass diff --git a/src/devops/azext_devops/vendored_sdks/devops/_azure_dev_ops.py b/src/devops/azext_devops/vendored_sdks/devops/_azure_dev_ops.py new file mode 100644 index 00000000000..1f37bc8019f --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/_azure_dev_ops.py @@ -0,0 +1,76 @@ +# 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 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 ._configuration import AzureDevOpsConfiguration +from .operations import OperationOperations +from .operations import PipelineTemplateDefinitionOperations +from .operations import PipelineOperations +from . import models + + +class AzureDevOps(object): + """Azure DevOps Resource Provider. + + :ivar operation: OperationOperations operations + :vartype operation: azure.mgmt.devops.operations.OperationOperations + :ivar pipeline_template_definition: PipelineTemplateDefinitionOperations operations + :vartype pipeline_template_definition: azure.mgmt.devops.operations.PipelineTemplateDefinitionOperations + :ivar pipeline: PipelineOperations operations + :vartype pipeline: azure.mgmt.devops.operations.PipelineOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + 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 = AzureDevOpsConfiguration(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._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.pipeline_template_definition = PipelineTemplateDefinitionOperations( + self._client, self._config, self._serialize, self._deserialize) + self.pipeline = PipelineOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AzureDevOps + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/devops/azext_devops/vendored_sdks/devops/_configuration.py b/src/devops/azext_devops/vendored_sdks/devops/_configuration.py new file mode 100644 index 00000000000..ca6d0ccdc91 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/_configuration.py @@ -0,0 +1,69 @@ +# 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 typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class AzureDevOpsConfiguration(Configuration): + """Configuration for AzureDevOps. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + """ + + def __init__( + 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.") + super(AzureDevOpsConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2019-07-01-preview" + self.credential_scopes = ['https://management.azure.com/.default'] + kwargs.setdefault('sdk_moniker', 'mgmt-devops/{}'.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.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) diff --git a/src/devops/azext_devops/vendored_sdks/devops/_version.py b/src/devops/azext_devops/vendored_sdks/devops/_version.py new file mode 100644 index 00000000000..51deab6604e --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/_version.py @@ -0,0 +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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "2019-07-01-preview" diff --git a/src/devops/azext_devops/vendored_sdks/devops/aio/__init__.py b/src/devops/azext_devops/vendored_sdks/devops/aio/__init__.py new file mode 100644 index 00000000000..ba454671b4c --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/aio/__init__.py @@ -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 ._azure_dev_ops_async import AzureDevOps +__all__ = ['AzureDevOps'] diff --git a/src/devops/azext_devops/vendored_sdks/devops/aio/_azure_dev_ops_async.py b/src/devops/azext_devops/vendored_sdks/devops/aio/_azure_dev_ops_async.py new file mode 100644 index 00000000000..2dd3b27557c --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/aio/_azure_dev_ops_async.py @@ -0,0 +1,68 @@ +# 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 typing import Any, Optional + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from ._configuration_async import AzureDevOpsConfiguration +from .operations_async import OperationOperations +from .operations_async import PipelineTemplateDefinitionOperations +from .operations_async import PipelineOperations +from .. import models + + +class AzureDevOps(object): + """Azure DevOps Resource Provider. + + :ivar operation: OperationOperations operations + :vartype operation: azure.mgmt.devops.aio.operations_async.OperationOperations + :ivar pipeline_template_definition: PipelineTemplateDefinitionOperations operations + :vartype pipeline_template_definition: azure.mgmt.devops.aio.operations_async.PipelineTemplateDefinitionOperations + :ivar pipeline: PipelineOperations operations + :vartype pipeline: azure.mgmt.devops.aio.operations_async.PipelineOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = AzureDevOpsConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.pipeline_template_definition = PipelineTemplateDefinitionOperations( + self._client, self._config, self._serialize, self._deserialize) + self.pipeline = PipelineOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AzureDevOps": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/devops/azext_devops/vendored_sdks/devops/aio/_configuration_async.py b/src/devops/azext_devops/vendored_sdks/devops/aio/_configuration_async.py new file mode 100644 index 00000000000..154ea9df13e --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/aio/_configuration_async.py @@ -0,0 +1,65 @@ +# 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 typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class AzureDevOpsConfiguration(Configuration): + """Configuration for AzureDevOps. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> 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.") + super(AzureDevOpsConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2019-07-01-preview" + self.credential_scopes = ['https://management.azure.com/.default'] + kwargs.setdefault('sdk_moniker', 'mgmt-devops/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> 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.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/__init__.py b/src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/__init__.py new file mode 100644 index 00000000000..3cecb61db65 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/__init__.py @@ -0,0 +1,17 @@ +# 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 ._operation_operations_async import OperationOperations +from ._pipeline_template_definition_operations_async import PipelineTemplateDefinitionOperations +from ._pipeline_operations_async import PipelineOperations + +__all__ = [ + 'OperationOperations', + 'PipelineTemplateDefinitionOperations', + 'PipelineOperations', +] diff --git a/src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/_operation_operations_async.py b/src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/_operation_operations_async.py new file mode 100644 index 00000000000..8575e22df60 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/_operation_operations_async.py @@ -0,0 +1,100 @@ +# 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 typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations: + """OperationOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.devops.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> "models.OperationListResult": + """Lists all the operations supported by Microsoft.DevOps resource provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.devops.models.OperationListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-07-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + else: + url = next_link + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.DevOps/operations'} diff --git a/src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/_pipeline_operations_async.py b/src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/_pipeline_operations_async.py new file mode 100644 index 00000000000..32e14be385c --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/_pipeline_operations_async.py @@ -0,0 +1,503 @@ +# 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 typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod, async_poller +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PipelineOperations: + """PipelineOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.devops.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_or_update_initial( + self, + resource_group_name: str, + pipeline_name: str, + organization: "models.OrganizationReference", + project: "models.ProjectReference", + id: str, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + parameters: Optional[Dict[str, str]] = None, + repository_type: Optional[Union[str, "models.CodeRepositoryType"]] = None, + code_repository_id: Optional[str] = None, + default_branch: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + authorization_parameters: Optional[Dict[str, str]] = None, + **kwargs + ) -> "models.Pipeline": + cls = kwargs.pop('cls', None) # type: ClsType["models.Pipeline"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _create_operation_parameters = models.Pipeline(tags=tags, location=location, organization=organization, project=project, id_properties_bootstrap_configuration_template_id=id, parameters_properties_bootstrap_configuration_template_parameters=parameters, repository_type=repository_type, id_properties_bootstrap_configuration_repository_id=code_repository_id, default_branch=default_branch, properties=properties, parameters_properties_bootstrap_configuration_repository_authorization_parameters=authorization_parameters) + api_version = "2019-07-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_or_update_initial.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'pipelineName': self._serialize.url("pipeline_name", pipeline_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_create_operation_parameters, 'Pipeline') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Pipeline', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOps/pipelines/{pipelineName}'} + + async def create_or_update( + self, + resource_group_name: str, + pipeline_name: str, + organization: "models.OrganizationReference", + project: "models.ProjectReference", + id: str, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + parameters: Optional[Dict[str, str]] = None, + repository_type: Optional[Union[str, "models.CodeRepositoryType"]] = None, + code_repository_id: Optional[str] = None, + default_branch: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + authorization_parameters: Optional[Dict[str, str]] = None, + **kwargs + ) -> "models.Pipeline": + """Creates or updates an Azure Pipeline. + + :param resource_group_name: Name of the resource group within the Azure subscription. + :type resource_group_name: str + :param pipeline_name: The name of the Azure Pipeline resource in ARM. + :type pipeline_name: str + :param organization: Reference to the Azure DevOps Organization containing the Pipeline. + :type organization: ~azure.mgmt.devops.models.OrganizationReference + :param project: Reference to the Azure DevOps Project containing the Pipeline. + :type project: ~azure.mgmt.devops.models.ProjectReference + :param id: Unique identifier of the pipeline template. + :type id: str + :param tags: Resource Tags. + :type tags: dict[str, str] + :param location: Resource Location. + :type location: str + :param parameters: Dictionary of input parameters used in the pipeline template. + :type parameters: dict[str, str] + :param repository_type: Type of code repository. + :type repository_type: str or ~azure.mgmt.devops.models.CodeRepositoryType + :param code_repository_id: Unique immutable identifier of the code repository. + :type code_repository_id: str + :param default_branch: Default branch used to configure Continuous Integration (CI) in the + pipeline. + :type default_branch: str + :param properties: Repository-specific properties. + :type properties: dict[str, str] + :param authorization_parameters: Authorization parameters corresponding to the authorization + type. + :type authorization_parameters: dict[str, str] + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :return: An instance of LROPoller that returns Pipeline + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devops.models.Pipeline] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.Pipeline"] + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + pipeline_name=pipeline_name, + organization=organization, + project=project, + id=id, + tags=tags, + location=location, + parameters=parameters, + repository_type=repository_type, + code_repository_id=code_repository_id, + default_branch=default_branch, + properties=properties, + authorization_parameters=authorization_parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Pipeline', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + return await async_poller(self._client, raw_result, get_long_running_output, polling_method) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOps/pipelines/{pipelineName}'} + + async def get( + self, + resource_group_name: str, + pipeline_name: str, + **kwargs + ) -> "models.Pipeline": + """Gets an existing Azure Pipeline. + + :param resource_group_name: Name of the resource group within the Azure subscription. + :type resource_group_name: str + :param pipeline_name: The name of the Azure Pipeline resource in ARM. + :type pipeline_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pipeline or the result of cls(response) + :rtype: ~azure.mgmt.devops.models.Pipeline + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Pipeline"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-07-01-preview" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'pipelineName': self._serialize.url("pipeline_name", pipeline_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Pipeline', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOps/pipelines/{pipelineName}'} + + async def update( + self, + resource_group_name: str, + pipeline_name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ) -> "models.Pipeline": + """Updates the properties of an Azure Pipeline. Currently, only tags can be updated. + + :param resource_group_name: Name of the resource group within the Azure subscription. + :type resource_group_name: str + :param pipeline_name: The name of the Azure Pipeline resource. + :type pipeline_name: str + :param tags: Dictionary of key-value pairs to be set as tags on the Azure Pipeline. This will + overwrite any existing tags. + :type tags: dict[str, str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pipeline or the result of cls(response) + :rtype: ~azure.mgmt.devops.models.Pipeline + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Pipeline"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _update_operation_parameters = models.PipelineUpdateParameters(tags=tags) + api_version = "2019-07-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'pipelineName': self._serialize.url("pipeline_name", pipeline_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_update_operation_parameters, 'PipelineUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Pipeline', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOps/pipelines/{pipelineName}'} + + async def delete( + self, + resource_group_name: str, + pipeline_name: str, + **kwargs + ) -> None: + """Deletes an Azure Pipeline. + + :param resource_group_name: Name of the resource group within the Azure subscription. + :type resource_group_name: str + :param pipeline_name: The name of the Azure Pipeline resource. + :type pipeline_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-07-01-preview" + + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'pipelineName': self._serialize.url("pipeline_name", pipeline_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOps/pipelines/{pipelineName}'} + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> "models.PipelineListResult": + """Lists all Azure Pipelines under the specified resource group. + + :param resource_group_name: Name of the resource group within the Azure subscription. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PipelineListResult or the result of cls(response) + :rtype: ~azure.mgmt.devops.models.PipelineListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PipelineListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-07-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PipelineListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOps/pipelines'} + + def list_by_subscription( + self, + **kwargs + ) -> "models.PipelineListResult": + """Lists all Azure Pipelines under the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PipelineListResult or the result of cls(response) + :rtype: ~azure.mgmt.devops.models.PipelineListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PipelineListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-07-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PipelineListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DevOps/pipelines'} diff --git a/src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/_pipeline_template_definition_operations_async.py b/src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/_pipeline_template_definition_operations_async.py new file mode 100644 index 00000000000..3be88009078 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/aio/operations_async/_pipeline_template_definition_operations_async.py @@ -0,0 +1,100 @@ +# 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 typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PipelineTemplateDefinitionOperations: + """PipelineTemplateDefinitionOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.devops.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> "models.PipelineTemplateDefinitionListResult": + """Lists all pipeline templates which can be used to configure an Azure Pipeline. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PipelineTemplateDefinitionListResult or the result of cls(response) + :rtype: ~azure.mgmt.devops.models.PipelineTemplateDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PipelineTemplateDefinitionListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-07-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + else: + url = next_link + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('PipelineTemplateDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.DevOps/pipelineTemplateDefinitions'} diff --git a/src/devops/azext_devops/vendored_sdks/devops/models/__init__.py b/src/devops/azext_devops/vendored_sdks/devops/models/__init__.py new file mode 100644 index 00000000000..8a35d229a16 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/models/__init__.py @@ -0,0 +1,59 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import CloudErrorBody + from ._models_py3 import InputDescriptor + from ._models_py3 import InputValue + from ._models_py3 import Operation + from ._models_py3 import OperationListResult + from ._models_py3 import OrganizationReference + from ._models_py3 import Pipeline + from ._models_py3 import PipelineListResult + from ._models_py3 import PipelineTemplateDefinition + from ._models_py3 import PipelineTemplateDefinitionListResult + from ._models_py3 import PipelineUpdateParameters + from ._models_py3 import ProjectReference + from ._models_py3 import Resource +except (SyntaxError, ImportError): + from ._models import CloudErrorBody # type: ignore + from ._models import InputDescriptor # type: ignore + from ._models import InputValue # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import OrganizationReference # type: ignore + from ._models import Pipeline # type: ignore + from ._models import PipelineListResult # type: ignore + from ._models import PipelineTemplateDefinition # type: ignore + from ._models import PipelineTemplateDefinitionListResult # type: ignore + from ._models import PipelineUpdateParameters # type: ignore + from ._models import ProjectReference # type: ignore + from ._models import Resource # type: ignore + +from ._azure_dev_ops_enums import ( + CodeRepositoryType, + InputDataType, +) + +__all__ = [ + 'CloudErrorBody', + 'InputDescriptor', + 'InputValue', + 'Operation', + 'OperationListResult', + 'OrganizationReference', + 'Pipeline', + 'PipelineListResult', + 'PipelineTemplateDefinition', + 'PipelineTemplateDefinitionListResult', + 'PipelineUpdateParameters', + 'ProjectReference', + 'Resource', + 'CodeRepositoryType', + 'InputDataType', +] diff --git a/src/devops/azext_devops/vendored_sdks/devops/models/_azure_dev_ops_enums.py b/src/devops/azext_devops/vendored_sdks/devops/models/_azure_dev_ops_enums.py new file mode 100644 index 00000000000..eff829ccb27 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/models/_azure_dev_ops_enums.py @@ -0,0 +1,26 @@ +# 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 enum import Enum + +class CodeRepositoryType(str, Enum): + """Type of code repository. + """ + + git_hub = "gitHub" + vsts_git = "vstsGit" + +class InputDataType(str, Enum): + """Data type of the value of the input parameter. + """ + + string = "String" + secure_string = "SecureString" + int = "Int" + bool = "Bool" + authorization = "Authorization" diff --git a/src/devops/azext_devops/vendored_sdks/devops/models/_models.py b/src/devops/azext_devops/vendored_sdks/devops/models/_models.py new file mode 100644 index 00000000000..17a9e6a8417 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/models/_models.py @@ -0,0 +1,487 @@ +# 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. +# -------------------------------------------------------------------------- + +import msrest.serialization + + +class CloudErrorBody(msrest.serialization.Model): + """An error response from the Pipelines Resource Provider. + + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :type code: str + :param message: A message describing the error, intended to be suitable for display in a user + interface. + :type message: str + :param target: The target of the particular error. For example, the name of the property in + error or the method where the error occurred. + :type target: str + :param details: A list of additional details about the error. + :type details: list[~azure.mgmt.devops.models.CloudErrorBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + } + + def __init__( + self, + **kwargs + ): + super(CloudErrorBody, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.target = kwargs.get('target', None) + self.details = kwargs.get('details', None) + + +class InputDescriptor(msrest.serialization.Model): + """Representation of a pipeline template input parameter. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Identifier of the input parameter. + :type id: str + :param description: Description of the input parameter. + :type description: str + :param type: Required. Data type of the value of the input parameter. Possible values include: + "String", "SecureString", "Int", "Bool", "Authorization". + :type type: str or ~azure.mgmt.devops.models.InputDataType + :param possible_values: List of possible values for the input parameter. + :type possible_values: list[~azure.mgmt.devops.models.InputValue] + """ + + _validation = { + 'id': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'possible_values': {'key': 'possibleValues', 'type': '[InputValue]'}, + } + + def __init__( + self, + **kwargs + ): + super(InputDescriptor, self).__init__(**kwargs) + self.id = kwargs['id'] + self.description = kwargs.get('description', None) + self.type = kwargs['type'] + self.possible_values = kwargs.get('possible_values', None) + + +class InputValue(msrest.serialization.Model): + """Representation of a pipeline template input parameter value. + + :param value: Value of an input parameter. + :type value: str + :param display_value: Description of the input parameter value. + :type display_value: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': 'str'}, + 'display_value': {'key': 'displayValue', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(InputValue, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.display_value = kwargs.get('display_value', None) + + +class Operation(msrest.serialization.Model): + """Properties of an Operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the operation. + :vartype name: str + :param is_data_action: Indicates whether the operation applies to data-plane. + :type is_data_action: str + :ivar operation: Friendly name of the operation. + :vartype operation: str + :ivar resource: Friendly name of the resource type the operation applies to. + :vartype resource: str + :ivar description: Friendly description of the operation. + :vartype description: str + :ivar provider: Friendly name of the resource provider. + :vartype provider: str + """ + + _validation = { + 'name': {'readonly': True}, + 'operation': {'readonly': True}, + 'resource': {'readonly': True}, + 'description': {'readonly': True}, + 'provider': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'str'}, + 'operation': {'key': 'display.operation', 'type': 'str'}, + 'resource': {'key': 'display.resource', 'type': 'str'}, + 'description': {'key': 'display.description', 'type': 'str'}, + 'provider': {'key': 'display.provider', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = kwargs.get('is_data_action', None) + self.operation = None + self.resource = None + self.description = None + self.provider = None + + +class OperationListResult(msrest.serialization.Model): + """Result of a request to list all operations supported by Microsoft.DevOps resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by Microsoft.DevOps resource provider. + :vartype value: list[~azure.mgmt.devops.models.Operation] + :param next_link: The URL to get the next set of operations, if there are any. + :type next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = kwargs.get('next_link', None) + + +class OrganizationReference(msrest.serialization.Model): + """Reference to an Azure DevOps Organization. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Unique immutable identifier for the Azure DevOps Organization. + :vartype id: str + :param name: Required. Name of the Azure DevOps Organization. + :type name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OrganizationReference, self).__init__(**kwargs) + self.id = None + self.name = kwargs['name'] + + +class Resource(msrest.serialization.Model): + """An Azure Resource Manager (ARM) resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar type: Resource Type. + :vartype type: str + :param tags: A set of tags. Resource Tags. + :type tags: dict[str, str] + :param location: Resource Location. + :type location: str + :ivar name: Resource Name. + :vartype name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.type = None + self.tags = kwargs.get('tags', None) + self.location = kwargs.get('location', None) + self.name = None + + +class Pipeline(Resource): + """Azure DevOps Pipeline used to configure Continuous Integration (CI) & Continuous Delivery (CD) for Azure resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource Id. + :vartype id: str + :ivar type: Resource Type. + :vartype type: str + :param tags: A set of tags. Resource Tags. + :type tags: dict[str, str] + :param location: Resource Location. + :type location: str + :ivar name: Resource Name. + :vartype name: str + :ivar pipeline_id: Unique identifier of the Azure Pipeline within the Azure DevOps Project. + :vartype pipeline_id: int + :param organization: Required. Reference to the Azure DevOps Organization containing the + Pipeline. + :type organization: ~azure.mgmt.devops.models.OrganizationReference + :param project: Required. Reference to the Azure DevOps Project containing the Pipeline. + :type project: ~azure.mgmt.devops.models.ProjectReference + :param id_properties_bootstrap_configuration_template_id: Required. Unique identifier of the + pipeline template. + :type id_properties_bootstrap_configuration_template_id: str + :param parameters_properties_bootstrap_configuration_template_parameters: Dictionary of input + parameters used in the pipeline template. + :type parameters_properties_bootstrap_configuration_template_parameters: dict[str, str] + :param repository_type: Type of code repository. Possible values include: "gitHub", "vstsGit". + :type repository_type: str or ~azure.mgmt.devops.models.CodeRepositoryType + :param id_properties_bootstrap_configuration_repository_id: Unique immutable identifier of the + code repository. + :type id_properties_bootstrap_configuration_repository_id: str + :param default_branch: Default branch used to configure Continuous Integration (CI) in the + pipeline. + :type default_branch: str + :param properties: Repository-specific properties. + :type properties: dict[str, str] + :ivar authorization_type: Type of authorization. Default value: "personalAccessToken". + :vartype authorization_type: str + :param parameters_properties_bootstrap_configuration_repository_authorization_parameters: + Authorization parameters corresponding to the authorization type. + :type parameters_properties_bootstrap_configuration_repository_authorization_parameters: + dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'pipeline_id': {'readonly': True}, + 'organization': {'required': True}, + 'project': {'required': True}, + 'id_properties_bootstrap_configuration_template_id': {'required': True}, + 'authorization_type': {'constant': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'pipeline_id': {'key': 'properties.pipelineId', 'type': 'int'}, + 'organization': {'key': 'properties.organization', 'type': 'OrganizationReference'}, + 'project': {'key': 'properties.project', 'type': 'ProjectReference'}, + 'id_properties_bootstrap_configuration_template_id': {'key': 'properties.bootstrapConfiguration.template.id', 'type': 'str'}, + 'parameters_properties_bootstrap_configuration_template_parameters': {'key': 'properties.bootstrapConfiguration.template.parameters', 'type': '{str}'}, + 'repository_type': {'key': 'properties.bootstrapConfiguration.repository.repositoryType', 'type': 'str'}, + 'id_properties_bootstrap_configuration_repository_id': {'key': 'properties.bootstrapConfiguration.repository.id', 'type': 'str'}, + 'default_branch': {'key': 'properties.bootstrapConfiguration.repository.defaultBranch', 'type': 'str'}, + 'properties': {'key': 'properties.bootstrapConfiguration.repository.properties', 'type': '{str}'}, + 'authorization_type': {'key': 'properties.bootstrapConfiguration.repository.authorization.authorizationType', 'type': 'str'}, + 'parameters_properties_bootstrap_configuration_repository_authorization_parameters': {'key': 'properties.bootstrapConfiguration.repository.authorization.parameters', 'type': '{str}'}, + } + + authorization_type = "personalAccessToken" + + def __init__( + self, + **kwargs + ): + super(Pipeline, self).__init__(**kwargs) + self.pipeline_id = None + self.organization = kwargs['organization'] + self.project = kwargs['project'] + self.id_properties_bootstrap_configuration_template_id = kwargs['id_properties_bootstrap_configuration_template_id'] + self.parameters_properties_bootstrap_configuration_template_parameters = kwargs.get('parameters_properties_bootstrap_configuration_template_parameters', None) + self.repository_type = kwargs.get('repository_type', None) + self.id_properties_bootstrap_configuration_repository_id = kwargs.get('id_properties_bootstrap_configuration_repository_id', None) + self.default_branch = kwargs.get('default_branch', None) + self.properties = kwargs.get('properties', None) + self.parameters_properties_bootstrap_configuration_repository_authorization_parameters = kwargs.get('parameters_properties_bootstrap_configuration_repository_authorization_parameters', None) + + +class PipelineListResult(msrest.serialization.Model): + """Result of a request to list all Azure Pipelines under a given scope. + + :param value: List of pipelines. + :type value: list[~azure.mgmt.devops.models.Pipeline] + :param next_link: URL to get the next set of Pipelines, if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Pipeline]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PipelineListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PipelineTemplateDefinition(msrest.serialization.Model): + """Definition of a pipeline template. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Unique identifier of the pipeline template. + :type id: str + :param description: Description of the pipeline enabled by the template. + :type description: str + :param inputs: List of input parameters required by the template to create a pipeline. + :type inputs: list[~azure.mgmt.devops.models.InputDescriptor] + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'inputs': {'key': 'inputs', 'type': '[InputDescriptor]'}, + } + + def __init__( + self, + **kwargs + ): + super(PipelineTemplateDefinition, self).__init__(**kwargs) + self.id = kwargs['id'] + self.description = kwargs.get('description', None) + self.inputs = kwargs.get('inputs', None) + + +class PipelineTemplateDefinitionListResult(msrest.serialization.Model): + """Result of a request to list all pipeline template definitions. + + :param value: List of pipeline template definitions. + :type value: list[~azure.mgmt.devops.models.PipelineTemplateDefinition] + :param next_link: The URL to get the next set of pipeline template definitions, if there are + any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PipelineTemplateDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PipelineTemplateDefinitionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class PipelineUpdateParameters(msrest.serialization.Model): + """Request payload used to update an existing Azure Pipeline. + + :param tags: A set of tags. Dictionary of key-value pairs to be set as tags on the Azure + Pipeline. This will overwrite any existing tags. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + **kwargs + ): + super(PipelineUpdateParameters, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + + +class ProjectReference(msrest.serialization.Model): + """Reference to an Azure DevOps Project. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Unique immutable identifier of the Azure DevOps Project. + :vartype id: str + :param name: Required. Name of the Azure DevOps Project. + :type name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProjectReference, self).__init__(**kwargs) + self.id = None + self.name = kwargs['name'] diff --git a/src/devops/azext_devops/vendored_sdks/devops/models/_models_py3.py b/src/devops/azext_devops/vendored_sdks/devops/models/_models_py3.py new file mode 100644 index 00000000000..926e4bf1e3a --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/models/_models_py3.py @@ -0,0 +1,537 @@ +# 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 typing import Dict, List, Optional, Union + +import msrest.serialization + + +class CloudErrorBody(msrest.serialization.Model): + """An error response from the Pipelines Resource Provider. + + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :type code: str + :param message: A message describing the error, intended to be suitable for display in a user + interface. + :type message: str + :param target: The target of the particular error. For example, the name of the property in + error or the method where the error occurred. + :type target: str + :param details: A list of additional details about the error. + :type details: list[~azure.mgmt.devops.models.CloudErrorBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["CloudErrorBody"]] = None, + **kwargs + ): + super(CloudErrorBody, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class InputDescriptor(msrest.serialization.Model): + """Representation of a pipeline template input parameter. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Identifier of the input parameter. + :type id: str + :param description: Description of the input parameter. + :type description: str + :param type: Required. Data type of the value of the input parameter. Possible values include: + "String", "SecureString", "Int", "Bool", "Authorization". + :type type: str or ~azure.mgmt.devops.models.InputDataType + :param possible_values: List of possible values for the input parameter. + :type possible_values: list[~azure.mgmt.devops.models.InputValue] + """ + + _validation = { + 'id': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'possible_values': {'key': 'possibleValues', 'type': '[InputValue]'}, + } + + def __init__( + self, + *, + id: str, + type: Union[str, "InputDataType"], + description: Optional[str] = None, + possible_values: Optional[List["InputValue"]] = None, + **kwargs + ): + super(InputDescriptor, self).__init__(**kwargs) + self.id = id + self.description = description + self.type = type + self.possible_values = possible_values + + +class InputValue(msrest.serialization.Model): + """Representation of a pipeline template input parameter value. + + :param value: Value of an input parameter. + :type value: str + :param display_value: Description of the input parameter value. + :type display_value: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': 'str'}, + 'display_value': {'key': 'displayValue', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[str] = None, + display_value: Optional[str] = None, + **kwargs + ): + super(InputValue, self).__init__(**kwargs) + self.value = value + self.display_value = display_value + + +class Operation(msrest.serialization.Model): + """Properties of an Operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the operation. + :vartype name: str + :param is_data_action: Indicates whether the operation applies to data-plane. + :type is_data_action: str + :ivar operation: Friendly name of the operation. + :vartype operation: str + :ivar resource: Friendly name of the resource type the operation applies to. + :vartype resource: str + :ivar description: Friendly description of the operation. + :vartype description: str + :ivar provider: Friendly name of the resource provider. + :vartype provider: str + """ + + _validation = { + 'name': {'readonly': True}, + 'operation': {'readonly': True}, + 'resource': {'readonly': True}, + 'description': {'readonly': True}, + 'provider': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'str'}, + 'operation': {'key': 'display.operation', 'type': 'str'}, + 'resource': {'key': 'display.resource', 'type': 'str'}, + 'description': {'key': 'display.description', 'type': 'str'}, + 'provider': {'key': 'display.provider', 'type': 'str'}, + } + + def __init__( + self, + *, + is_data_action: Optional[str] = None, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = is_data_action + self.operation = None + self.resource = None + self.description = None + self.provider = None + + +class OperationListResult(msrest.serialization.Model): + """Result of a request to list all operations supported by Microsoft.DevOps resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by Microsoft.DevOps resource provider. + :vartype value: list[~azure.mgmt.devops.models.Operation] + :param next_link: The URL to get the next set of operations, if there are any. + :type next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = next_link + + +class OrganizationReference(msrest.serialization.Model): + """Reference to an Azure DevOps Organization. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Unique immutable identifier for the Azure DevOps Organization. + :vartype id: str + :param name: Required. Name of the Azure DevOps Organization. + :type name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + **kwargs + ): + super(OrganizationReference, self).__init__(**kwargs) + self.id = None + self.name = name + + +class Resource(msrest.serialization.Model): + """An Azure Resource Manager (ARM) resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar type: Resource Type. + :vartype type: str + :param tags: A set of tags. Resource Tags. + :type tags: dict[str, str] + :param location: Resource Location. + :type location: str + :ivar name: Resource Name. + :vartype name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.type = None + self.tags = tags + self.location = location + self.name = None + + +class Pipeline(Resource): + """Azure DevOps Pipeline used to configure Continuous Integration (CI) & Continuous Delivery (CD) for Azure resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource Id. + :vartype id: str + :ivar type: Resource Type. + :vartype type: str + :param tags: A set of tags. Resource Tags. + :type tags: dict[str, str] + :param location: Resource Location. + :type location: str + :ivar name: Resource Name. + :vartype name: str + :ivar pipeline_id: Unique identifier of the Azure Pipeline within the Azure DevOps Project. + :vartype pipeline_id: int + :param organization: Required. Reference to the Azure DevOps Organization containing the + Pipeline. + :type organization: ~azure.mgmt.devops.models.OrganizationReference + :param project: Required. Reference to the Azure DevOps Project containing the Pipeline. + :type project: ~azure.mgmt.devops.models.ProjectReference + :param id_properties_bootstrap_configuration_template_id: Required. Unique identifier of the + pipeline template. + :type id_properties_bootstrap_configuration_template_id: str + :param parameters_properties_bootstrap_configuration_template_parameters: Dictionary of input + parameters used in the pipeline template. + :type parameters_properties_bootstrap_configuration_template_parameters: dict[str, str] + :param repository_type: Type of code repository. Possible values include: "gitHub", "vstsGit". + :type repository_type: str or ~azure.mgmt.devops.models.CodeRepositoryType + :param id_properties_bootstrap_configuration_repository_id: Unique immutable identifier of the + code repository. + :type id_properties_bootstrap_configuration_repository_id: str + :param default_branch: Default branch used to configure Continuous Integration (CI) in the + pipeline. + :type default_branch: str + :param properties: Repository-specific properties. + :type properties: dict[str, str] + :ivar authorization_type: Type of authorization. Default value: "personalAccessToken". + :vartype authorization_type: str + :param parameters_properties_bootstrap_configuration_repository_authorization_parameters: + Authorization parameters corresponding to the authorization type. + :type parameters_properties_bootstrap_configuration_repository_authorization_parameters: + dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'pipeline_id': {'readonly': True}, + 'organization': {'required': True}, + 'project': {'required': True}, + 'id_properties_bootstrap_configuration_template_id': {'required': True}, + 'authorization_type': {'constant': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'pipeline_id': {'key': 'properties.pipelineId', 'type': 'int'}, + 'organization': {'key': 'properties.organization', 'type': 'OrganizationReference'}, + 'project': {'key': 'properties.project', 'type': 'ProjectReference'}, + 'id_properties_bootstrap_configuration_template_id': {'key': 'properties.bootstrapConfiguration.template.id', 'type': 'str'}, + 'parameters_properties_bootstrap_configuration_template_parameters': {'key': 'properties.bootstrapConfiguration.template.parameters', 'type': '{str}'}, + 'repository_type': {'key': 'properties.bootstrapConfiguration.repository.repositoryType', 'type': 'str'}, + 'id_properties_bootstrap_configuration_repository_id': {'key': 'properties.bootstrapConfiguration.repository.id', 'type': 'str'}, + 'default_branch': {'key': 'properties.bootstrapConfiguration.repository.defaultBranch', 'type': 'str'}, + 'properties': {'key': 'properties.bootstrapConfiguration.repository.properties', 'type': '{str}'}, + 'authorization_type': {'key': 'properties.bootstrapConfiguration.repository.authorization.authorizationType', 'type': 'str'}, + 'parameters_properties_bootstrap_configuration_repository_authorization_parameters': {'key': 'properties.bootstrapConfiguration.repository.authorization.parameters', 'type': '{str}'}, + } + + authorization_type = "personalAccessToken" + + def __init__( + self, + *, + organization: "OrganizationReference", + project: "ProjectReference", + id_properties_bootstrap_configuration_template_id: str, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + parameters_properties_bootstrap_configuration_template_parameters: Optional[Dict[str, str]] = None, + repository_type: Optional[Union[str, "CodeRepositoryType"]] = None, + id_properties_bootstrap_configuration_repository_id: Optional[str] = None, + default_branch: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + parameters_properties_bootstrap_configuration_repository_authorization_parameters: Optional[Dict[str, str]] = None, + **kwargs + ): + super(Pipeline, self).__init__(tags=tags, location=location, **kwargs) + self.pipeline_id = None + self.organization = organization + self.project = project + self.id_properties_bootstrap_configuration_template_id = id_properties_bootstrap_configuration_template_id + self.parameters_properties_bootstrap_configuration_template_parameters = parameters_properties_bootstrap_configuration_template_parameters + self.repository_type = repository_type + self.id_properties_bootstrap_configuration_repository_id = id_properties_bootstrap_configuration_repository_id + self.default_branch = default_branch + self.properties = properties + self.parameters_properties_bootstrap_configuration_repository_authorization_parameters = parameters_properties_bootstrap_configuration_repository_authorization_parameters + + +class PipelineListResult(msrest.serialization.Model): + """Result of a request to list all Azure Pipelines under a given scope. + + :param value: List of pipelines. + :type value: list[~azure.mgmt.devops.models.Pipeline] + :param next_link: URL to get the next set of Pipelines, if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Pipeline]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Pipeline"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PipelineListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PipelineTemplateDefinition(msrest.serialization.Model): + """Definition of a pipeline template. + + All required parameters must be populated in order to send to Azure. + + :param id: Required. Unique identifier of the pipeline template. + :type id: str + :param description: Description of the pipeline enabled by the template. + :type description: str + :param inputs: List of input parameters required by the template to create a pipeline. + :type inputs: list[~azure.mgmt.devops.models.InputDescriptor] + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'inputs': {'key': 'inputs', 'type': '[InputDescriptor]'}, + } + + def __init__( + self, + *, + id: str, + description: Optional[str] = None, + inputs: Optional[List["InputDescriptor"]] = None, + **kwargs + ): + super(PipelineTemplateDefinition, self).__init__(**kwargs) + self.id = id + self.description = description + self.inputs = inputs + + +class PipelineTemplateDefinitionListResult(msrest.serialization.Model): + """Result of a request to list all pipeline template definitions. + + :param value: List of pipeline template definitions. + :type value: list[~azure.mgmt.devops.models.PipelineTemplateDefinition] + :param next_link: The URL to get the next set of pipeline template definitions, if there are + any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PipelineTemplateDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PipelineTemplateDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(PipelineTemplateDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PipelineUpdateParameters(msrest.serialization.Model): + """Request payload used to update an existing Azure Pipeline. + + :param tags: A set of tags. Dictionary of key-value pairs to be set as tags on the Azure + Pipeline. This will overwrite any existing tags. + :type tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(PipelineUpdateParameters, self).__init__(**kwargs) + self.tags = tags + + +class ProjectReference(msrest.serialization.Model): + """Reference to an Azure DevOps Project. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Unique immutable identifier of the Azure DevOps Project. + :vartype id: str + :param name: Required. Name of the Azure DevOps Project. + :type name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + **kwargs + ): + super(ProjectReference, self).__init__(**kwargs) + self.id = None + self.name = name diff --git a/src/devops/azext_devops/vendored_sdks/devops/operations/__init__.py b/src/devops/azext_devops/vendored_sdks/devops/operations/__init__.py new file mode 100644 index 00000000000..7492a3c538b --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/operations/__init__.py @@ -0,0 +1,17 @@ +# 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 ._operation_operations import OperationOperations +from ._pipeline_template_definition_operations import PipelineTemplateDefinitionOperations +from ._pipeline_operations import PipelineOperations + +__all__ = [ + 'OperationOperations', + 'PipelineTemplateDefinitionOperations', + 'PipelineOperations', +] diff --git a/src/devops/azext_devops/vendored_sdks/devops/operations/_operation_operations.py b/src/devops/azext_devops/vendored_sdks/devops/operations/_operation_operations.py new file mode 100644 index 00000000000..82fa3d66ac7 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/operations/_operation_operations.py @@ -0,0 +1,105 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations(object): + """OperationOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.devops.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> "models.OperationListResult" + """Lists all the operations supported by Microsoft.DevOps resource provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.devops.models.OperationListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-07-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + else: + url = next_link + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.DevOps/operations'} diff --git a/src/devops/azext_devops/vendored_sdks/devops/operations/_pipeline_operations.py b/src/devops/azext_devops/vendored_sdks/devops/operations/_pipeline_operations.py new file mode 100644 index 00000000000..ef36df75e4d --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/operations/_pipeline_operations.py @@ -0,0 +1,514 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class PipelineOperations(object): + """PipelineOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.devops.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _create_or_update_initial( + self, + resource_group_name, # type: str + pipeline_name, # type: str + organization, # type: "models.OrganizationReference" + project, # type: "models.ProjectReference" + id, # type: str + tags=None, # type: Optional[Dict[str, str]] + location=None, # type: Optional[str] + parameters=None, # type: Optional[Dict[str, str]] + repository_type=None, # type: Optional[Union[str, "models.CodeRepositoryType"]] + code_repository_id=None, # type: Optional[str] + default_branch=None, # type: Optional[str] + properties=None, # type: Optional[Dict[str, str]] + authorization_parameters=None, # type: Optional[Dict[str, str]] + **kwargs # type: Any + ): + # type: (...) -> "models.Pipeline" + cls = kwargs.pop('cls', None) # type: ClsType["models.Pipeline"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _create_operation_parameters = models.Pipeline(tags=tags, location=location, organization=organization, project=project, id_properties_bootstrap_configuration_template_id=id, parameters_properties_bootstrap_configuration_template_parameters=parameters, repository_type=repository_type, id_properties_bootstrap_configuration_repository_id=code_repository_id, default_branch=default_branch, properties=properties, parameters_properties_bootstrap_configuration_repository_authorization_parameters=authorization_parameters) + api_version = "2019-07-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self._create_or_update_initial.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'pipelineName': self._serialize.url("pipeline_name", pipeline_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_create_operation_parameters, 'Pipeline') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Pipeline', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOps/pipelines/{pipelineName}'} + + def begin_create_or_update( + self, + resource_group_name, # type: str + pipeline_name, # type: str + organization, # type: "models.OrganizationReference" + project, # type: "models.ProjectReference" + id, # type: str + tags=None, # type: Optional[Dict[str, str]] + location=None, # type: Optional[str] + parameters=None, # type: Optional[Dict[str, str]] + repository_type=None, # type: Optional[Union[str, "models.CodeRepositoryType"]] + code_repository_id=None, # type: Optional[str] + default_branch=None, # type: Optional[str] + properties=None, # type: Optional[Dict[str, str]] + authorization_parameters=None, # type: Optional[Dict[str, str]] + **kwargs # type: Any + ): + # type: (...) -> "models.Pipeline" + """Creates or updates an Azure Pipeline. + + :param resource_group_name: Name of the resource group within the Azure subscription. + :type resource_group_name: str + :param pipeline_name: The name of the Azure Pipeline resource in ARM. + :type pipeline_name: str + :param organization: Reference to the Azure DevOps Organization containing the Pipeline. + :type organization: ~azure.mgmt.devops.models.OrganizationReference + :param project: Reference to the Azure DevOps Project containing the Pipeline. + :type project: ~azure.mgmt.devops.models.ProjectReference + :param id: Unique identifier of the pipeline template. + :type id: str + :param tags: Resource Tags. + :type tags: dict[str, str] + :param location: Resource Location. + :type location: str + :param parameters: Dictionary of input parameters used in the pipeline template. + :type parameters: dict[str, str] + :param repository_type: Type of code repository. + :type repository_type: str or ~azure.mgmt.devops.models.CodeRepositoryType + :param code_repository_id: Unique immutable identifier of the code repository. + :type code_repository_id: str + :param default_branch: Default branch used to configure Continuous Integration (CI) in the + pipeline. + :type default_branch: str + :param properties: Repository-specific properties. + :type properties: dict[str, str] + :param authorization_parameters: Authorization parameters corresponding to the authorization + type. + :type authorization_parameters: dict[str, str] + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :return: An instance of LROPoller that returns Pipeline + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.devops.models.Pipeline] + + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.Pipeline"] + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + pipeline_name=pipeline_name, + organization=organization, + project=project, + id=id, + tags=tags, + location=location, + parameters=parameters, + repository_type=repository_type, + code_repository_id=code_repository_id, + default_branch=default_branch, + properties=properties, + authorization_parameters=authorization_parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Pipeline', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + lro_delay = kwargs.get( + 'polling_interval', + self._config.polling_interval + ) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOps/pipelines/{pipelineName}'} + + def get( + self, + resource_group_name, # type: str + pipeline_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.Pipeline" + """Gets an existing Azure Pipeline. + + :param resource_group_name: Name of the resource group within the Azure subscription. + :type resource_group_name: str + :param pipeline_name: The name of the Azure Pipeline resource in ARM. + :type pipeline_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pipeline or the result of cls(response) + :rtype: ~azure.mgmt.devops.models.Pipeline + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Pipeline"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-07-01-preview" + + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'pipelineName': self._serialize.url("pipeline_name", pipeline_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Pipeline', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOps/pipelines/{pipelineName}'} + + def update( + self, + resource_group_name, # type: str + pipeline_name, # type: str + tags=None, # type: Optional[Dict[str, str]] + **kwargs # type: Any + ): + # type: (...) -> "models.Pipeline" + """Updates the properties of an Azure Pipeline. Currently, only tags can be updated. + + :param resource_group_name: Name of the resource group within the Azure subscription. + :type resource_group_name: str + :param pipeline_name: The name of the Azure Pipeline resource. + :type pipeline_name: str + :param tags: Dictionary of key-value pairs to be set as tags on the Azure Pipeline. This will + overwrite any existing tags. + :type tags: dict[str, str] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pipeline or the result of cls(response) + :rtype: ~azure.mgmt.devops.models.Pipeline + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Pipeline"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + + _update_operation_parameters = models.PipelineUpdateParameters(tags=tags) + api_version = "2019-07-01-preview" + content_type = kwargs.pop("content_type", "application/json") + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'pipelineName': self._serialize.url("pipeline_name", pipeline_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = 'application/json' + + # Construct and send request + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_update_operation_parameters, 'PipelineUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Pipeline', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOps/pipelines/{pipelineName}'} + + def delete( + self, + resource_group_name, # type: str + pipeline_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes an Azure Pipeline. + + :param resource_group_name: Name of the resource group within the Azure subscription. + :type resource_group_name: str + :param pipeline_name: The name of the Azure Pipeline resource. + :type pipeline_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-07-01-preview" + + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'pipelineName': self._serialize.url("pipeline_name", pipeline_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOps/pipelines/{pipelineName}'} + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PipelineListResult" + """Lists all Azure Pipelines under the specified resource group. + + :param resource_group_name: Name of the resource group within the Azure subscription. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PipelineListResult or the result of cls(response) + :rtype: ~azure.mgmt.devops.models.PipelineListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PipelineListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-07-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('PipelineListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevOps/pipelines'} + + def list_by_subscription( + self, + **kwargs # type: Any + ): + # type: (...) -> "models.PipelineListResult" + """Lists all Azure Pipelines under the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PipelineListResult or the result of cls(response) + :rtype: ~azure.mgmt.devops.models.PipelineListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PipelineListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-07-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + else: + url = next_link + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('PipelineListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DevOps/pipelines'} diff --git a/src/devops/azext_devops/vendored_sdks/devops/operations/_pipeline_template_definition_operations.py b/src/devops/azext_devops/vendored_sdks/devops/operations/_pipeline_template_definition_operations.py new file mode 100644 index 00000000000..b9a53f8a92b --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/operations/_pipeline_template_definition_operations.py @@ -0,0 +1,105 @@ +# 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 typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class PipelineTemplateDefinitionOperations(object): + """PipelineTemplateDefinitionOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.devops.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> "models.PipelineTemplateDefinitionListResult" + """Lists all pipeline templates which can be used to configure an Azure Pipeline. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PipelineTemplateDefinitionListResult or the result of cls(response) + :rtype: ~azure.mgmt.devops.models.PipelineTemplateDefinitionListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PipelineTemplateDefinitionListResult"] + error_map = kwargs.pop('error_map', {404: ResourceNotFoundError, 409: ResourceExistsError}) + api_version = "2019-07-01-preview" + + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + else: + url = next_link + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = 'application/json' + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('PipelineTemplateDefinitionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.DevOps/pipelineTemplateDefinitions'} diff --git a/src/devops/azext_devops/vendored_sdks/devops/py.typed b/src/devops/azext_devops/vendored_sdks/devops/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/devops/report.md b/src/devops/report.md new file mode 100644 index 00000000000..7d0b1a2ceb8 --- /dev/null +++ b/src/devops/report.md @@ -0,0 +1,59 @@ +# Azure CLI Module Creation Report + +### devops pipeline create + +create a devops pipeline. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Name of the resource group within the Azure subscription.|resource_group_name| +|**--pipeline-name**|string|The name of the Azure Pipeline resource in ARM.|pipeline_name| +|**--organization**|object|Reference to the Azure DevOps Organization containing the Pipeline.|organization| +|**--project**|object|Reference to the Azure DevOps Project containing the Pipeline.|project| +|**--bootstrap-configuration-template-id**|string|Unique identifier of the pipeline template.|id_properties_bootstrap_configuration_template_id| +|**--tags**|dictionary|Resource Tags|tags| +|**--location**|string|Resource Location|location| +|**--bootstrap-configuration-template-parameters**|dictionary|Dictionary of input parameters used in the pipeline template.|parameters_properties_bootstrap_configuration_template_parameters| +|**--bootstrap-configuration-repository-repository-type**|choice|Type of code repository.|repository_type| +|**--bootstrap-configuration-repository-id**|string|Unique immutable identifier of the code repository.|id_properties_bootstrap_configuration_repository_id| +|**--bootstrap-configuration-repository-default-branch**|string|Default branch used to configure Continuous Integration (CI) in the pipeline.|default_branch| +|**--bootstrap-configuration-repository-properties**|dictionary|Repository-specific properties.|properties| +|**--bootstrap-configuration-repository-authorization-parameters**|dictionary|Authorization parameters corresponding to the authorization type.|parameters_properties_bootstrap_configuration_repository_authorization_parameters| +### devops pipeline delete + +delete a devops pipeline. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Name of the resource group within the Azure subscription.|resource_group_name| +|**--pipeline-name**|string|The name of the Azure Pipeline resource.|pipeline_name| +### devops pipeline list + +list a devops pipeline. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Name of the resource group within the Azure subscription.|resource_group_name| +### devops pipeline show + +show a devops pipeline. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Name of the resource group within the Azure subscription.|resource_group_name| +|**--pipeline-name**|string|The name of the Azure Pipeline resource in ARM.|pipeline_name| +### devops pipeline update + +update a devops pipeline. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| +|**--resource-group-name**|string|Name of the resource group within the Azure subscription.|resource_group_name| +|**--pipeline-name**|string|The name of the Azure Pipeline resource.|pipeline_name| +|**--tags**|dictionary|Dictionary of key-value pairs to be set as tags on the Azure Pipeline. This will overwrite any existing tags.|tags| +### devops pipeline-template-definition list + +list a devops pipeline-template-definition. + +|Option|Type|Description|Path (SDK)|Path (swagger)| +|------|----|-----------|----------|--------------| \ No newline at end of file diff --git a/src/devops/setup.cfg b/src/devops/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/devops/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/devops/setup.py b/src/devops/setup.py new file mode 100644 index 00000000000..ae8501a9286 --- /dev/null +++ b/src/devops/setup.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages + +# TODO: Confirm this is the right version number you want and it matches your +# HISTORY.rst entry. +VERSION = '0.1.0' + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +# TODO: Add any additional SDK dependencies here +DEPENDENCIES = [] + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='devops', + version=VERSION, + description='Microsoft Azure Command-Line Tools AzureDevOps Extension', + # TODO: Update author and email, if applicable + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + # TODO: consider pointing directly to your source code instead of the generic repo + url='https://github.com/Azure/azure-cli-extensions', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_devops': ['azext_metadata.json']}, +)