From 6e563433ffce8afd2cf1422652f767b6624cc1f7 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Mon, 9 Nov 2020 11:50:47 +0000 Subject: [PATCH] Generated from 0e3888663995ddcf2a83f45727b2342b0226d4c4 --- src/devops/HISTORY.rst | 8 + src/devops/README.md | 39 ++ src/devops/azext_devops/__init__.py | 50 ++ 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 | 24 + src/devops/azext_devops/generated/_help.py | 99 ++++ src/devops/azext_devops/generated/_params.py | 71 +++ .../azext_devops/generated/_validators.py | 9 + src/devops/azext_devops/generated/action.py | 54 ++ src/devops/azext_devops/generated/commands.py | 38 ++ src/devops/azext_devops/generated/custom.py | 73 +++ src/devops/azext_devops/manual/__init__.py | 12 + src/devops/azext_devops/tests/__init__.py | 114 ++++ .../azext_devops/tests/latest/__init__.py | 12 + .../tests/latest/test_devops_scenario.py | 141 +++++ .../azext_devops/vendored_sdks/__init__.py | 12 + .../vendored_sdks/devops/__init__.py | 16 + .../vendored_sdks/devops/_azure_dev_ops.py | 79 +++ .../vendored_sdks/devops/_configuration.py | 70 +++ .../vendored_sdks/devops/aio/__init__.py | 10 + .../devops/aio/_azure_dev_ops.py | 73 +++ .../devops/aio/_configuration.py | 66 +++ .../devops/aio/operations/__init__.py | 17 + .../aio/operations/_operation_operations.py | 104 ++++ .../aio/operations/_pipeline_operations.py | 531 +++++++++++++++++ ...pipeline_template_definition_operations.py | 104 ++++ .../vendored_sdks/devops/models/__init__.py | 55 ++ .../devops/models/_azure_dev_ops_enums.py | 50 ++ .../vendored_sdks/devops/models/_models.py | 430 ++++++++++++++ .../devops/models/_models_py3.py | 479 ++++++++++++++++ .../devops/operations/__init__.py | 17 + .../operations/_operation_operations.py | 109 ++++ .../devops/operations/_pipeline_operations.py | 542 ++++++++++++++++++ ...pipeline_template_definition_operations.py | 109 ++++ .../vendored_sdks/devops/py.typed | 1 + src/devops/report.md | 129 +++++ src/devops/setup.cfg | 1 + src/devops/setup.py | 58 ++ 41 files changed, 3856 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/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/aio/__init__.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/aio/_azure_dev_ops.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/aio/_configuration.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/aio/operations/__init__.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/aio/operations/_operation_operations.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/aio/operations/_pipeline_operations.py create mode 100644 src/devops/azext_devops/vendored_sdks/devops/aio/operations/_pipeline_template_definition_operations.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..1c139576ba0 --- /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..718719c9629 --- /dev/null +++ b/src/devops/README.md @@ -0,0 +1,39 @@ +# Azure CLI devops Extension # +This is the extension for devops + +### How to use ### +Install this extension using the below CLI command +``` +az extension add --name devops +``` + +### Included Features ### +#### devops pipeline-template-definition #### +##### List ##### +``` +az devops pipeline-template-definition list +``` +#### devops pipeline #### +##### Create ##### +``` +az devops pipeline create --location "South India" \ + --bootstrap-configuration-repository-properties bootstrapConfiguration={"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":"myAspNetWebAppPipeline-rg","subscriptionId":"{subscriptionId}","webAppName":"myAspNetWebApp"}}} organization={"name":"myAspNetWebAppPipeline-org"} project={"name":"myAspNetWebAppPipeline-project"} \ + --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg" +``` +##### Show ##### +``` +az devops pipeline show --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg" +``` +##### List ##### +``` +az devops pipeline list --resource-group "myAspNetWebAppPipeline-rg" +``` +##### Update ##### +``` +az devops pipeline update --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg" \ + --tags tagKey="tagvalue" +``` +##### Delete ##### +``` +az devops pipeline delete --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg" +``` \ No newline at end of file diff --git a/src/devops/azext_devops/__init__.py b/src/devops/azext_devops/__init__.py new file mode 100644 index 00000000000..a95e5444bf4 --- /dev/null +++ b/src/devops/azext_devops/__init__.py @@ -0,0 +1,50 @@ +# -------------------------------------------------------------------------- +# 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 +try: + from azext_devops.manual._help import helps # pylint: disable=reimported +except ImportError: + pass + + +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_cl + devops_custom = CliCommandType( + operations_tmpl='azext_devops.custom#{}', + client_factory=cf_devops_cl) + parent = super(AzureDevOpsCommandsLoader, self) + parent.__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..d95d53bf711 --- /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..4f48fa652a5 --- /dev/null +++ b/src/devops/azext_devops/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isExperimental": true, + "azext.minCliCoreVersion": "2.11.0" +} \ 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..dbe9d5f9742 --- /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..c9cfdc73e77 --- /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..fdc9ce88676 --- /dev/null +++ b/src/devops/azext_devops/generated/_client_factory.py @@ -0,0 +1,24 @@ +# -------------------------------------------------------------------------- +# 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_cl(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_cl(cli_ctx).pipeline_template_definition + + +def cf_pipeline(cli_ctx, *_): + return cf_devops_cl(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..77e1e3bf392 --- /dev/null +++ b/src/devops/azext_devops/generated/_help.py @@ -0,0 +1,99 @@ +# -------------------------------------------------------------------------- +# 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 resource group. And 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" + - name: List all Azure pipelines under the specified subscription + text: |- + az devops pipeline list +""" + +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 --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg" +""" + +helps['devops pipeline create'] = """ + type: command + short-summary: "Create 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 \ +bootstrapConfiguration={"template":{"id":"ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp","paramete\ +rs":{"appInsightLocation":"South India","appServicePlan":"S1 Standard","azureAuth":"{\\"scheme\\":\\"ServicePrincipal\\\ +",\\"parameters\\":{\\"tenantid\\":\\"{subscriptionTenantId}\\",\\"objectid\\":\\"{appObjectId}\\",\\"serviceprincipali\ +d\\":\\"{appId}\\",\\"serviceprincipalkey\\":\\"{appSecret}\\"}}","location":"South India","resourceGroup":"myAspNetWeb\ +AppPipeline-rg","subscriptionId":"{subscriptionId}","webAppName":"myAspNetWebApp"}}} organization={"name":"myAspNetWebA\ +ppPipeline-org"} project={"name":"myAspNetWebAppPipeline-project"} --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 --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-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 --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg" +""" + +helps['devops pipeline wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the devops pipeline is met. + examples: + - name: Pause executing next line of CLI script until the devops pipeline is successfully created. + text: |- + az devops pipeline wait --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg" \ +--created +""" diff --git a/src/devops/azext_devops/generated/_params.py b/src/devops/azext_devops/generated/_params.py new file mode 100644 index 00000000000..d0a64ebaf9f --- /dev/null +++ b/src/devops/azext_devops/generated/_params.py @@ -0,0 +1,71 @@ +# -------------------------------------------------------------------------- +# 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 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 ( + AddBootstrapConfigurationTemplateParameters, + AddBootstrapConfigurationRepositoryProperties +) + + +def load_arguments(self, _): + + 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', options_list=['--name', '-n', '--pipeline-name'], type=str, help='The name of the ' + 'Azure Pipeline resource in ARM.', id_part='name') + + with self.argument_context('devops pipeline create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('pipeline_name', options_list=['--name', '-n', '--pipeline-name'], type=str, 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('bootstrap_configuration_template_id', type=str, + 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=VALUE1 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_default_branch', type=str, help='Default branch used to ' + 'configure Continuous Integration (CI) in the pipeline.') + c.argument('bootstrap_configuration_repository_properties', + action=AddBootstrapConfigurationRepositoryProperties, nargs='*', help='Repository-specific ' + 'properties. Expect value: KEY1=VALUE1 KEY2=VALUE2 ...') + c.argument('project_name', type=str, help='Name of the Azure DevOps Project.') + + with self.argument_context('devops pipeline update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('pipeline_name', options_list=['--name', '-n', '--pipeline-name'], type=str, help='The name of the ' + 'Azure Pipeline resource.', id_part='name') + 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', options_list=['--name', '-n', '--pipeline-name'], type=str, help='The name of the ' + 'Azure Pipeline resource.', id_part='name') + + with self.argument_context('devops pipeline wait') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('pipeline_name', options_list=['--name', '-n', '--pipeline-name'], type=str, help='The name of the ' + 'Azure Pipeline resource in ARM.', id_part='name') diff --git a/src/devops/azext_devops/generated/_validators.py b/src/devops/azext_devops/generated/_validators.py new file mode 100644 index 00000000000..b33a44c1ebf --- /dev/null +++ b/src/devops/azext_devops/generated/_validators.py @@ -0,0 +1,9 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- diff --git a/src/devops/azext_devops/generated/action.py b/src/devops/azext_devops/generated/action.py new file mode 100644 index 00000000000..4e38fc1a6ab --- /dev/null +++ b/src/devops/azext_devops/generated/action.py @@ -0,0 +1,54 @@ +# -------------------------------------------------------------------------- +# 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 collections import defaultdict +from knack.util import CLIError + + +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: + v = properties[k] + d[k] = v[0] + 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: + v = properties[k] + d[k] = v[0] + 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..3b4363c47da --- /dev/null +++ b/src/devops/azext_devops/generated/commands.py @@ -0,0 +1,38 @@ +# -------------------------------------------------------------------------- +# 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-statements +# pylint: disable=too-many-locals + +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', confirmation=True) + g.custom_wait_command('wait', 'devops_pipeline_show') diff --git a/src/devops/azext_devops/generated/custom.py b/src/devops/azext_devops/generated/custom.py new file mode 100644 index 00000000000..a4efb989864 --- /dev/null +++ b/src/devops/azext_devops/generated/custom.py @@ -0,0 +1,73 @@ +# -------------------------------------------------------------------------- +# 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 azure.cli.core.util import sdk_no_wait + + +def devops_pipeline_template_definition_list(client): + return client.list() + + +def devops_pipeline_list(client, + resource_group_name=None): + if resource_group_name: + return client.list_by_resource_group(resource_group_name=resource_group_name) + return client.list_by_subscription() + + +def devops_pipeline_show(client, + resource_group_name, + pipeline_name): + return client.get(resource_group_name=resource_group_name, + pipeline_name=pipeline_name) + + +def devops_pipeline_create(client, + resource_group_name, + pipeline_name, + bootstrap_configuration_template_id, + project_name, + tags=None, + location=None, + bootstrap_configuration_template_parameters=None, + bootstrap_configuration_repository_repository_type=None, + bootstrap_configuration_repository_default_branch=None, + bootstrap_configuration_repository_properties=None, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_create_or_update, + resource_group_name=resource_group_name, + pipeline_name=pipeline_name, + tags=tags, + location=location, + id=bootstrap_configuration_template_id, + parameters=bootstrap_configuration_template_parameters, + repository_type=bootstrap_configuration_repository_repository_type, + default_branch=bootstrap_configuration_repository_default_branch, + properties=bootstrap_configuration_repository_properties, + authorization_type="personalAccessToken", + name=project_name) + + +def devops_pipeline_update(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(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..c9cfdc73e77 --- /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..50e0627daff --- /dev/null +++ b/src/devops/azext_devops/tests/__init__.py @@ -0,0 +1,114 @@ +# 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 logging +import os +import sys +import traceback +import datetime as dt + +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError + + +logger = logging.getLogger('azure.cli.testsdk') +logger.addHandler(logging.StreamHandler()) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) +exceptions = [] +test_map = dict() +SUCCESSED = "successed" +FAILED = "failed" + + +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) + func_to_call = import_manual_function(func) + logger.info("Found manual override for %s(...)", func.__name__) + except (ImportError, AttributeError): + pass + return func_to_call + + def wrapper(*args, **kwargs): + func_to_call = get_func_to_call() + logger.info("running %s()...", func.__name__) + try: + test_map[func.__name__] = dict() + test_map[func.__name__]["result"] = SUCCESSED + test_map[func.__name__]["error_message"] = "" + test_map[func.__name__]["error_stack"] = "" + test_map[func.__name__]["error_normalized"] = "" + test_map[func.__name__]["start_dt"] = dt.datetime.utcnow() + ret = func_to_call(*args, **kwargs) + except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, + JMESPathCheckAssertionError) as e: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + test_map[func.__name__]["result"] = FAILED + test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500] + test_map[func.__name__]["error_stack"] = traceback.format_exc().replace( + "\r\n", " ").replace("\n", " ")[:500] + logger.info("--------------------------------------") + logger.info("step exception: %s", e) + logger.error("--------------------------------------") + logger.error("step exception in %s: %s", func.__name__, e) + logger.info(traceback.format_exc()) + exceptions.append((func.__name__, sys.exc_info())) + else: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + return ret + + if inspect.isclass(func): + return get_func_to_call() + return wrapper + + +def calc_coverage(filename): + filename = filename.split(".")[0] + coverage_name = filename + "_coverage.md" + with open(coverage_name, "w") as f: + f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\n") + total = len(test_map) + covered = 0 + for k, v in test_map.items(): + if not k.startswith("step_"): + total -= 1 + continue + if v["result"] == SUCCESSED: + covered += 1 + f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|" + "{end_dt}|\n".format(step_name=k, **v)) + f.write("Coverage: {}/{}\n".format(covered, total)) + print("Create coverage\n", file=sys.stderr) + + +def raise_if(): + if exceptions: + if len(exceptions) <= 1: + raise exceptions[0][1][1] + message = "{}\nFollowed with exceptions in other steps:\n".format(str(exceptions[0][1][1])) + message += "\n".join(["{}: {}".format(h[0], h[1][1]) for h in exceptions[1:]]) + raise exceptions[0][1][0](message).with_traceback(exceptions[0][1][2]) 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..c9cfdc73e77 --- /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/test_devops_scenario.py b/src/devops/azext_devops/tests/latest/test_devops_scenario.py new file mode 100644 index 00000000000..b09fd1dc2dd --- /dev/null +++ b/src/devops/azext_devops/tests/latest/test_devops_scenario.py @@ -0,0 +1,141 @@ +# -------------------------------------------------------------------------- +# 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 azure.cli.testsdk import ScenarioTest +from .. import try_manual, raise_if, calc_coverage +from azure.cli.testsdk import ResourceGroupPreparer + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +# Env setup +@try_manual +def setup(test, rg): + pass + + +# EXAMPLE: /Pipelines/put/Create an Azure pipeline to deploy a sample ASP.Net application to Azure web-app +@try_manual +def step__pipelines_put(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\\"' + ':{{\\"tenantid\\":\\"{{subscriptionTenantId}}\\",\\"objectid\\":\\"{{appObjectId}}\\",\\"serviceprincipal' + 'id\\":\\"{{appId}}\\",\\"serviceprincipalkey\\":\\"{{appSecret}}\\"}}}}","location":"South ' + 'India","resourceGroup":"myAspNetWebAppPipeline-rg","subscriptionId":"{{subscriptionId}}","webAppName":"my' + 'AspNetWebApp"}}}}}} organization={{"name":"myAspNetWebAppPipeline-org"}} project={{"name":"myAspNetWebApp' + 'Pipeline-project"}} ' + '--name "{myPipeline}" ' + '--resource-group "{rg}"', + checks=[ + test.check("location", "South India", case_sensitive=False), + test.check("name", "{myPipeline}", case_sensitive=False), + ]) + + +# 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 ' + '--name "{myPipeline}" ' + '--resource-group "{rg}"', + checks=[ + test.check("location", "South India", case_sensitive=False), + test.check("name", "{myPipeline}", case_sensitive=False), + ]) + + +# EXAMPLE: /Pipelines/get/List all Azure Pipelines under the specified resource group +@try_manual +def step__pipelines_get(test, rg): + test.cmd('az devops pipeline list ' + '--resource-group "{rg}"', + checks=[ + test.check('length(@)', 1), + ]) + + +# EXAMPLE: /Pipelines/get/List all Azure pipelines under the specified subscription +@try_manual +def step__pipelines_get2(test, rg): + test.cmd('az devops pipeline list ' + '-g ""', + checks=[ + test.check('length(@)', 1), + ]) + + +# EXAMPLE: /Pipelines/patch/Get an existing Azure pipeline +@try_manual +def step__pipelines_patch(test, rg): + test.cmd('az devops pipeline update ' + '--name "{myPipeline}" ' + '--resource-group "{rg}" ' + '--tags tagKey="tagvalue"', + checks=[ + test.check("location", "South India", case_sensitive=False), + test.check("name", "{myPipeline}", case_sensitive=False), + test.check("tags.tagKey", "tagvalue", case_sensitive=False), + ]) + + +# EXAMPLE: /Pipelines/delete/Get an existing Azure pipeline +@try_manual +def step__pipelines_delete(test, rg): + test.cmd('az devops pipeline delete -y ' + '--name "{myPipeline}" ' + '--resource-group "{rg}"', + checks=[]) + + +# EXAMPLE: /PipelineTemplateDefinitions/get/Get the list of pipeline template definitions +@try_manual +def step__pipelinetemplatedefinitions_get(test, rg): + test.cmd('az devops pipeline-template-definition list', + checks=[]) + + +# Env cleanup +@try_manual +def cleanup(test, rg): + pass + + +# Testcase +@try_manual +def call_scenario(test, rg): + setup(test, rg) + step__pipelines_put(test, rg) + step__pipelines_get_get_an_existing_azure_pipeline(test, rg) + step__pipelines_get(test, rg) + step__pipelines_get2(test, rg) + step__pipelines_patch(test, rg) + step__pipelines_delete(test, rg) + step__pipelinetemplatedefinitions_get(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({ + 'myPipeline': 'myAspNetWebAppPipeline', + }) + + call_scenario(self, rg) + calc_coverage(__file__) + raise_if() 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..c9cfdc73e77 --- /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..8de90268d08 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/__init__.py @@ -0,0 +1,16 @@ +# 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 +__all__ = ['AzureDevOps'] + +try: + from ._patch import patch_sdk # type: ignore + 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..1d0ee4f59be --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/_azure_dev_ops.py @@ -0,0 +1,79 @@ +# 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 azure.core.credentials import TokenCredential + +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_dev_ops.operations.OperationOperations + :ivar pipeline_template_definition: PipelineTemplateDefinitionOperations operations + :vartype pipeline_template_definition: azure_dev_ops.operations.PipelineTemplateDefinitionOperations + :ivar pipeline: PipelineOperations operations + :vartype pipeline: azure_dev_ops.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 + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + 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..dfc73de98ec --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/_configuration.py @@ -0,0 +1,70 @@ +# 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 azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +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 = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'azuredevops/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) 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..ad8fa47d249 --- /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 import AzureDevOps +__all__ = ['AzureDevOps'] diff --git a/src/devops/azext_devops/vendored_sdks/devops/aio/_azure_dev_ops.py b/src/devops/azext_devops/vendored_sdks/devops/aio/_azure_dev_ops.py new file mode 100644 index 00000000000..6b7c59bc84b --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/aio/_azure_dev_ops.py @@ -0,0 +1,73 @@ +# 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, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +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_dev_ops.aio.operations.OperationOperations + :ivar pipeline_template_definition: PipelineTemplateDefinitionOperations operations + :vartype pipeline_template_definition: azure_dev_ops.aio.operations.PipelineTemplateDefinitionOperations + :ivar pipeline: PipelineOperations operations + :vartype pipeline: azure_dev_ops.aio.operations.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 + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + 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.py b/src/devops/azext_devops/vendored_sdks/devops/aio/_configuration.py new file mode 100644 index 00000000000..90d326bb69c --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/aio/_configuration.py @@ -0,0 +1,66 @@ +# 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 azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +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 = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'azuredevops/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**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/__init__.py b/src/devops/azext_devops/vendored_sdks/devops/aio/operations/__init__.py new file mode 100644 index 00000000000..7492a3c538b --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/aio/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/aio/operations/_operation_operations.py b/src/devops/azext_devops/vendored_sdks/devops/aio/operations/_operation_operations.py new file mode 100644 index 00000000000..19f563c8a96 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/aio/operations/_operation_operations.py @@ -0,0 +1,104 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, 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_dev_ops.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 + ) -> AsyncIterable["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: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure_dev_ops.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + 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'} # type: ignore diff --git a/src/devops/azext_devops/vendored_sdks/devops/aio/operations/_pipeline_operations.py b/src/devops/azext_devops/vendored_sdks/devops/aio/operations/_pipeline_operations.py new file mode 100644 index 00000000000..272ce8f3f21 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/aio/operations/_pipeline_operations.py @@ -0,0 +1,531 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +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_dev_ops.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, + id: str, + name: 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, + default_branch: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + authorization_type: Optional[Union[str, "models.AuthorizationType"]] = None, + **kwargs + ) -> Optional["models.Pipeline"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Pipeline"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + create_operation_parameters = models.Pipeline(tags=tags, location=location, id_bootstrap_configuration_template_id=id, parameters_bootstrap_configuration_template_parameters=parameters, repository_type=repository_type, default_branch=default_branch, properties=properties, authorization_type=authorization_type, name_project_name=name) + api_version = "2019-07-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + 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'] = self._serialize.header("accept", accept, 'str') + + 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}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + pipeline_name: str, + id: str, + name: 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, + default_branch: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + authorization_type: Optional[Union[str, "models.AuthorizationType"]] = None, + **kwargs + ) -> AsyncLROPoller["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 id: Unique identifier of the pipeline template. + :type id: str + :param name: Name of the Azure DevOps Project. + :type name: 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_dev_ops.models.CodeRepositoryType + :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_type: Type of authorization. + :type authorization_type: str or ~azure_dev_ops.models.AuthorizationType + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :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 + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Pipeline or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure_dev_ops.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"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + pipeline_name=pipeline_name, + id=id, + name=name, + tags=tags, + location=location, + parameters=parameters, + repository_type=repository_type, + default_branch=default_branch, + properties=properties, + authorization_type=authorization_type, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Pipeline', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(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}'} # type: ignore + + 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_dev_ops.models.Pipeline + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Pipeline"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + 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'] = self._serialize.header("accept", accept, 'str') + + 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}'} # type: ignore + + 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_dev_ops.models.Pipeline + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Pipeline"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + update_operation_parameters = models.PipelineUpdateParameters(tags=tags) + api_version = "2019-07-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + 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'] = self._serialize.header("accept", accept, 'str') + + 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}'} # type: ignore + + 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + 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'] = self._serialize.header("accept", accept, 'str') + + 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}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["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: An iterator like instance of either PipelineListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure_dev_ops.models.PipelineListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PipelineListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + 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) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + 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'} # type: ignore + + def list_by_subscription( + self, + **kwargs + ) -> AsyncIterable["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: An iterator like instance of either PipelineListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure_dev_ops.models.PipelineListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PipelineListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + 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) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + 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'} # type: ignore diff --git a/src/devops/azext_devops/vendored_sdks/devops/aio/operations/_pipeline_template_definition_operations.py b/src/devops/azext_devops/vendored_sdks/devops/aio/operations/_pipeline_template_definition_operations.py new file mode 100644 index 00000000000..a50ab373aaf --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/aio/operations/_pipeline_template_definition_operations.py @@ -0,0 +1,104 @@ +# 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, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, 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_dev_ops.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 + ) -> AsyncIterable["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: An iterator like instance of either PipelineTemplateDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure_dev_ops.models.PipelineTemplateDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PipelineTemplateDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + 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'} # type: ignore 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..55683825be2 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/models/__init__.py @@ -0,0 +1,55 @@ +# 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 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 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 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 Resource # type: ignore + +from ._azure_dev_ops_enums import ( + AuthorizationType, + CodeRepositoryType, + InputDataType, +) + +__all__ = [ + 'CloudErrorBody', + 'InputDescriptor', + 'InputValue', + 'Operation', + 'OperationListResult', + 'Pipeline', + 'PipelineListResult', + 'PipelineTemplateDefinition', + 'PipelineTemplateDefinitionListResult', + 'PipelineUpdateParameters', + 'Resource', + 'AuthorizationType', + '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..891e4a50127 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/models/_azure_dev_ops_enums.py @@ -0,0 +1,50 @@ +# 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, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class AuthorizationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Type of authorization. + """ + + PERSONAL_ACCESS_TOKEN = "personalAccessToken" + +class CodeRepositoryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Type of code repository. + """ + + GIT_HUB = "gitHub" + VSTS_GIT = "vstsGit" + +class InputDataType(with_metaclass(_CaseInsensitiveEnumMeta, 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..dcd0252b4c8 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/models/_models.py @@ -0,0 +1,430 @@ +# 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_dev_ops.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_dev_ops.models.InputDataType + :param possible_values: List of possible values for the input parameter. + :type possible_values: list[~azure_dev_ops.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_dev_ops.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 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 id_bootstrap_configuration_template_id: Required. Unique identifier of the pipeline + template. + :type id_bootstrap_configuration_template_id: str + :param parameters_bootstrap_configuration_template_parameters: Dictionary of input parameters + used in the pipeline template. + :type parameters_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_dev_ops.models.CodeRepositoryType + :param id_bootstrap_configuration_repository_id: Unique immutable identifier of the code + repository. + :type id_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] + :param authorization_type: Type of authorization. Possible values include: + "personalAccessToken". + :type authorization_type: str or ~azure_dev_ops.models.AuthorizationType + :param parameters_bootstrap_configuration_repository_authorization_parameters: Authorization + parameters corresponding to the authorization type. + :type parameters_bootstrap_configuration_repository_authorization_parameters: dict[str, str] + :ivar id_project_id: Unique immutable identifier of the Azure DevOps Project. + :vartype id_project_id: str + :param name_project_name: Required. Name of the Azure DevOps Project. + :type name_project_name: str + :ivar id_organization_id: Unique immutable identifier for the Azure DevOps Organization. + :vartype id_organization_id: str + :param name_organization_name: Required. Name of the Azure DevOps Organization. + :type name_organization_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'pipeline_id': {'readonly': True}, + 'id_bootstrap_configuration_template_id': {'required': True}, + 'id_project_id': {'readonly': True}, + 'name_project_name': {'required': True}, + 'id_organization_id': {'readonly': True}, + 'name_organization_name': {'required': 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'}, + 'id_bootstrap_configuration_template_id': {'key': 'bootstrapConfiguration.template.id', 'type': 'str'}, + 'parameters_bootstrap_configuration_template_parameters': {'key': 'bootstrapConfiguration.template.parameters', 'type': '{str}'}, + 'repository_type': {'key': 'bootstrapConfiguration.repository.repositoryType', 'type': 'str'}, + 'id_bootstrap_configuration_repository_id': {'key': 'bootstrapConfiguration.repository.id', 'type': 'str'}, + 'default_branch': {'key': 'bootstrapConfiguration.repository.defaultBranch', 'type': 'str'}, + 'properties': {'key': 'bootstrapConfiguration.repository.properties', 'type': '{str}'}, + 'authorization_type': {'key': 'bootstrapConfiguration.repository.authorization.authorizationType', 'type': 'str'}, + 'parameters_bootstrap_configuration_repository_authorization_parameters': {'key': 'bootstrapConfiguration.repository.authorization.parameters', 'type': '{str}'}, + 'id_project_id': {'key': 'project.id', 'type': 'str'}, + 'name_project_name': {'key': 'project.name', 'type': 'str'}, + 'id_organization_id': {'key': 'organization.id', 'type': 'str'}, + 'name_organization_name': {'key': 'organization.name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Pipeline, self).__init__(**kwargs) + self.pipeline_id = None + self.id_bootstrap_configuration_template_id = kwargs['id_bootstrap_configuration_template_id'] + self.parameters_bootstrap_configuration_template_parameters = kwargs.get('parameters_bootstrap_configuration_template_parameters', None) + self.repository_type = kwargs.get('repository_type', None) + self.id_bootstrap_configuration_repository_id = kwargs.get('id_bootstrap_configuration_repository_id', None) + self.default_branch = kwargs.get('default_branch', None) + self.properties = kwargs.get('properties', None) + self.authorization_type = kwargs.get('authorization_type', None) + self.parameters_bootstrap_configuration_repository_authorization_parameters = kwargs.get('parameters_bootstrap_configuration_repository_authorization_parameters', None) + self.id_project_id = None + self.name_project_name = kwargs['name_project_name'] + self.id_organization_id = None + self.name_organization_name = kwargs['name_organization_name'] + + +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_dev_ops.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_dev_ops.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_dev_ops.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) 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..f0c598d675b --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/models/_models_py3.py @@ -0,0 +1,479 @@ +# 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 + +from ._azure_dev_ops_enums import * + + +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_dev_ops.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_dev_ops.models.InputDataType + :param possible_values: List of possible values for the input parameter. + :type possible_values: list[~azure_dev_ops.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_dev_ops.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 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 id_bootstrap_configuration_template_id: Required. Unique identifier of the pipeline + template. + :type id_bootstrap_configuration_template_id: str + :param parameters_bootstrap_configuration_template_parameters: Dictionary of input parameters + used in the pipeline template. + :type parameters_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_dev_ops.models.CodeRepositoryType + :param id_bootstrap_configuration_repository_id: Unique immutable identifier of the code + repository. + :type id_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] + :param authorization_type: Type of authorization. Possible values include: + "personalAccessToken". + :type authorization_type: str or ~azure_dev_ops.models.AuthorizationType + :param parameters_bootstrap_configuration_repository_authorization_parameters: Authorization + parameters corresponding to the authorization type. + :type parameters_bootstrap_configuration_repository_authorization_parameters: dict[str, str] + :ivar id_project_id: Unique immutable identifier of the Azure DevOps Project. + :vartype id_project_id: str + :param name_project_name: Required. Name of the Azure DevOps Project. + :type name_project_name: str + :ivar id_organization_id: Unique immutable identifier for the Azure DevOps Organization. + :vartype id_organization_id: str + :param name_organization_name: Required. Name of the Azure DevOps Organization. + :type name_organization_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'pipeline_id': {'readonly': True}, + 'id_bootstrap_configuration_template_id': {'required': True}, + 'id_project_id': {'readonly': True}, + 'name_project_name': {'required': True}, + 'id_organization_id': {'readonly': True}, + 'name_organization_name': {'required': 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'}, + 'id_bootstrap_configuration_template_id': {'key': 'bootstrapConfiguration.template.id', 'type': 'str'}, + 'parameters_bootstrap_configuration_template_parameters': {'key': 'bootstrapConfiguration.template.parameters', 'type': '{str}'}, + 'repository_type': {'key': 'bootstrapConfiguration.repository.repositoryType', 'type': 'str'}, + 'id_bootstrap_configuration_repository_id': {'key': 'bootstrapConfiguration.repository.id', 'type': 'str'}, + 'default_branch': {'key': 'bootstrapConfiguration.repository.defaultBranch', 'type': 'str'}, + 'properties': {'key': 'bootstrapConfiguration.repository.properties', 'type': '{str}'}, + 'authorization_type': {'key': 'bootstrapConfiguration.repository.authorization.authorizationType', 'type': 'str'}, + 'parameters_bootstrap_configuration_repository_authorization_parameters': {'key': 'bootstrapConfiguration.repository.authorization.parameters', 'type': '{str}'}, + 'id_project_id': {'key': 'project.id', 'type': 'str'}, + 'name_project_name': {'key': 'project.name', 'type': 'str'}, + 'id_organization_id': {'key': 'organization.id', 'type': 'str'}, + 'name_organization_name': {'key': 'organization.name', 'type': 'str'}, + } + + def __init__( + self, + *, + id_bootstrap_configuration_template_id: str, + name_project_name: str, + name_organization_name: str, + tags: Optional[Dict[str, str]] = None, + location: Optional[str] = None, + parameters_bootstrap_configuration_template_parameters: Optional[Dict[str, str]] = None, + repository_type: Optional[Union[str, "CodeRepositoryType"]] = None, + id_bootstrap_configuration_repository_id: Optional[str] = None, + default_branch: Optional[str] = None, + properties: Optional[Dict[str, str]] = None, + authorization_type: Optional[Union[str, "AuthorizationType"]] = None, + parameters_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.id_bootstrap_configuration_template_id = id_bootstrap_configuration_template_id + self.parameters_bootstrap_configuration_template_parameters = parameters_bootstrap_configuration_template_parameters + self.repository_type = repository_type + self.id_bootstrap_configuration_repository_id = id_bootstrap_configuration_repository_id + self.default_branch = default_branch + self.properties = properties + self.authorization_type = authorization_type + self.parameters_bootstrap_configuration_repository_authorization_parameters = parameters_bootstrap_configuration_repository_authorization_parameters + self.id_project_id = None + self.name_project_name = name_project_name + self.id_organization_id = None + self.name_organization_name = name_organization_name + + +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_dev_ops.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_dev_ops.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_dev_ops.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 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..d8b9ae559a4 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/operations/_operation_operations.py @@ -0,0 +1,109 @@ +# 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 ClientAuthenticationError, 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, Iterable, 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_dev_ops.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: (...) -> Iterable["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: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure_dev_ops.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + 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'} # type: ignore 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..cee25546ab3 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/operations/_pipeline_operations.py @@ -0,0 +1,542 @@ +# 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 ClientAuthenticationError, 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, Iterable, 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_dev_ops.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 + id, # type: str + name, # 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"]] + default_branch=None, # type: Optional[str] + properties=None, # type: Optional[Dict[str, str]] + authorization_type=None, # type: Optional[Union[str, "models.AuthorizationType"]] + **kwargs # type: Any + ): + # type: (...) -> Optional["models.Pipeline"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Pipeline"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + create_operation_parameters = models.Pipeline(tags=tags, location=location, id_bootstrap_configuration_template_id=id, parameters_bootstrap_configuration_template_parameters=parameters, repository_type=repository_type, default_branch=default_branch, properties=properties, authorization_type=authorization_type, name_project_name=name) + api_version = "2019-07-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + 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'] = self._serialize.header("accept", accept, 'str') + + 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}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + pipeline_name, # type: str + id, # type: str + name, # 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"]] + default_branch=None, # type: Optional[str] + properties=None, # type: Optional[Dict[str, str]] + authorization_type=None, # type: Optional[Union[str, "models.AuthorizationType"]] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["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 id: Unique identifier of the pipeline template. + :type id: str + :param name: Name of the Azure DevOps Project. + :type name: 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_dev_ops.models.CodeRepositoryType + :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_type: Type of authorization. + :type authorization_type: str or ~azure_dev_ops.models.AuthorizationType + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :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 + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either Pipeline or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure_dev_ops.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"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + pipeline_name=pipeline_name, + id=id, + name=name, + tags=tags, + location=location, + parameters=parameters, + repository_type=repository_type, + default_branch=default_branch, + properties=properties, + authorization_type=authorization_type, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Pipeline', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + 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'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + 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}'} # type: ignore + + 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_dev_ops.models.Pipeline + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Pipeline"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + 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'] = self._serialize.header("accept", accept, 'str') + + 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}'} # type: ignore + + 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_dev_ops.models.Pipeline + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.Pipeline"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + update_operation_parameters = models.PipelineUpdateParameters(tags=tags) + api_version = "2019-07-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + 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'] = self._serialize.header("accept", accept, 'str') + + 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}'} # type: ignore + + 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + 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'] = self._serialize.header("accept", accept, 'str') + + 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}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["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: An iterator like instance of either PipelineListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure_dev_ops.models.PipelineListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PipelineListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + 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) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + 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'} # type: ignore + + def list_by_subscription( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["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: An iterator like instance of either PipelineListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure_dev_ops.models.PipelineListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PipelineListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + 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) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + 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'} # type: ignore 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..2c365428765 --- /dev/null +++ b/src/devops/azext_devops/vendored_sdks/devops/operations/_pipeline_template_definition_operations.py @@ -0,0 +1,109 @@ +# 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 ClientAuthenticationError, 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, Iterable, 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_dev_ops.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: (...) -> Iterable["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: An iterator like instance of either PipelineTemplateDefinitionListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure_dev_ops.models.PipelineTemplateDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PipelineTemplateDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2019-07-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + 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'} # type: ignore 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..8aaa9b86aae --- /dev/null +++ b/src/devops/report.md @@ -0,0 +1,129 @@ +# Azure CLI Module Creation Report + +## EXTENSION +|CLI Extension|Command Groups| +|---------|------------| +|az devops|[groups](#CommandGroups) + +## GROUPS +### Command groups in `az devops` extension +|CLI Command Group|Group Swagger name|Commands| +|---------|------------|--------| +|az devops pipeline-template-definition|PipelineTemplateDefinitions|[commands](#CommandsInPipelineTemplateDefinitions)| +|az devops pipeline|Pipelines|[commands](#CommandsInPipelines)| + +## COMMANDS +### Commands in `az devops pipeline` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az devops pipeline list](#PipelinesListByResourceGroup)|ListByResourceGroup|[Parameters](#ParametersPipelinesListByResourceGroup)|[Example](#ExamplesPipelinesListByResourceGroup)| +|[az devops pipeline list](#PipelinesListBySubscription)|ListBySubscription|[Parameters](#ParametersPipelinesListBySubscription)|[Example](#ExamplesPipelinesListBySubscription)| +|[az devops pipeline show](#PipelinesGet)|Get|[Parameters](#ParametersPipelinesGet)|[Example](#ExamplesPipelinesGet)| +|[az devops pipeline create](#PipelinesCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersPipelinesCreateOrUpdate#Create)|[Example](#ExamplesPipelinesCreateOrUpdate#Create)| +|[az devops pipeline update](#PipelinesUpdate)|Update|[Parameters](#ParametersPipelinesUpdate)|[Example](#ExamplesPipelinesUpdate)| +|[az devops pipeline delete](#PipelinesDelete)|Delete|[Parameters](#ParametersPipelinesDelete)|[Example](#ExamplesPipelinesDelete)| + +### Commands in `az devops pipeline-template-definition` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az devops pipeline-template-definition list](#PipelineTemplateDefinitionsList)|List|[Parameters](#ParametersPipelineTemplateDefinitionsList)|[Example](#ExamplesPipelineTemplateDefinitionsList)| + + +## COMMAND DETAILS + +### group `az devops pipeline` +#### Command `az devops pipeline list` + +##### Example +``` +az devops pipeline list --resource-group "myAspNetWebAppPipeline-rg" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|Name of the resource group within the Azure subscription.|resource_group_name|resourceGroupName| + +#### Command `az devops pipeline list` + +##### Example +``` +az devops pipeline list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az devops pipeline show` + +##### Example +``` +az devops pipeline show --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|Name of the resource group within the Azure subscription.|resource_group_name|resourceGroupName| +|**--pipeline-name**|string|The name of the Azure Pipeline resource in ARM.|pipeline_name|pipelineName| + +#### Command `az devops pipeline create` + +##### Example +``` +az devops pipeline create --location "South India" --bootstrap-configuration-repository-properties \ +bootstrapConfiguration={"template":{"id":"ms.vss-continuous-delivery-pipeline-templates.aspnet-windowswebapp","paramete\ +rs":{"appInsightLocation":"South India","appServicePlan":"S1 Standard","azureAuth":"{\\"scheme\\":\\"ServicePrincipal\\\ +",\\"parameters\\":{\\"tenantid\\":\\"{subscriptionTenantId}\\",\\"objectid\\":\\"{appObjectId}\\",\\"serviceprincipali\ +d\\":\\"{appId}\\",\\"serviceprincipalkey\\":\\"{appSecret}\\"}}","location":"South India","resourceGroup":"myAspNetWeb\ +AppPipeline-rg","subscriptionId":"{subscriptionId}","webAppName":"myAspNetWebApp"}}} organization={"name":"myAspNetWebA\ +ppPipeline-org"} project={"name":"myAspNetWebAppPipeline-project"} --name "myAspNetWebAppPipeline" --resource-group \ +"myAspNetWebAppPipeline-rg" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|Name of the resource group within the Azure subscription.|resource_group_name|resourceGroupName| +|**--pipeline-name**|string|The name of the Azure Pipeline resource in ARM.|pipeline_name|pipelineName| +|**--bootstrap-configuration-template-id**|string|Unique identifier of the pipeline template.|id|id| +|**--project-name**|string|Name of the Azure DevOps Project.|name|name| +|**--tags**|dictionary|Resource Tags|tags|tags| +|**--location**|string|Resource Location|location|location| +|**--bootstrap-configuration-template-parameters**|dictionary|Dictionary of input parameters used in the pipeline template.|parameters|parameters| +|**--bootstrap-configuration-repository-repository-type**|choice|Type of code repository.|repository_type|repositoryType| +|**--bootstrap-configuration-repository-default-branch**|string|Default branch used to configure Continuous Integration (CI) in the pipeline.|default_branch|defaultBranch| +|**--bootstrap-configuration-repository-properties**|dictionary|Repository-specific properties.|properties|properties| + +#### Command `az devops pipeline update` + +##### Example +``` +az devops pipeline update --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg" --tags \ +tagKey="tagvalue" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|Name of the resource group within the Azure subscription.|resource_group_name|resourceGroupName| +|**--pipeline-name**|string|The name of the Azure Pipeline resource.|pipeline_name|pipelineName| +|**--tags**|dictionary|Dictionary of key-value pairs to be set as tags on the Azure Pipeline. This will overwrite any existing tags.|tags|tags| + +#### Command `az devops pipeline delete` + +##### Example +``` +az devops pipeline delete --name "myAspNetWebAppPipeline" --resource-group "myAspNetWebAppPipeline-rg" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|Name of the resource group within the Azure subscription.|resource_group_name|resourceGroupName| +|**--pipeline-name**|string|The name of the Azure Pipeline resource.|pipeline_name|pipelineName| + +### group `az devops pipeline-template-definition` +#### Command `az devops pipeline-template-definition list` + +##### Example +``` +az devops pipeline-template-definition list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| \ 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..4e79f92b974 --- /dev/null +++ b/src/devops/setup.py @@ -0,0 +1,58 @@ +#!/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 + +# HISTORY.rst entry. +VERSION = '0.1.0' +try: + from azext_devops.manual.version import VERSION +except ImportError: + pass + +# 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', +] + +DEPENDENCIES = [] + +try: + from azext_devops.manual.dependency import DEPENDENCIES +except ImportError: + pass + +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', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/master/src/devops', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_devops': ['azext_metadata.json']}, +)