From c035c1403eef7f5c6488b0094ffdb0fb60cfb3f6 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Tue, 1 Sep 2020 08:34:01 -0700 Subject: [PATCH 01/41] adding tags to build pipeline --- azuredevops/internal/model/tags.go | 12 ++++++++++++ .../service/build/resource_build_definition.go | 6 ++++++ .../service/build/resource_build_definition_test.go | 1 + 3 files changed, 19 insertions(+) create mode 100644 azuredevops/internal/model/tags.go diff --git a/azuredevops/internal/model/tags.go b/azuredevops/internal/model/tags.go new file mode 100644 index 000000000..2263acb4c --- /dev/null +++ b/azuredevops/internal/model/tags.go @@ -0,0 +1,12 @@ +package model + +import "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + +// TagsSchema list of tags +var TagsSchema = &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, +} diff --git a/azuredevops/internal/service/build/resource_build_definition.go b/azuredevops/internal/service/build/resource_build_definition.go index 0d148cad8..846ebc94d 100644 --- a/azuredevops/internal/service/build/resource_build_definition.go +++ b/azuredevops/internal/service/build/resource_build_definition.go @@ -294,6 +294,7 @@ func ResourceBuildDefinition() *schema.Resource { }, }, }, + "tags": model.TagsSchema, }, } } @@ -330,6 +331,8 @@ func flattenBuildDefinition(d *schema.ResourceData, buildDefinition *build.Build d.Set("agent_pool_name", *buildDefinition.Queue.Pool.Name) } + d.Set("path", *buildDefinition.Path) + d.Set("variable_groups", flattenVariableGroups(buildDefinition)) d.Set(bdVariable, flattenBuildVariables(d, buildDefinition)) @@ -893,6 +896,8 @@ func expandBuildDefinition(d *schema.ResourceData) (*build.BuildDefinition, stri return nil, "", fmt.Errorf("Error expanding varibles: %+v", err) } + tags := tfhelper.ExpandStringList(d.Get("tags").([]interface{})) + buildDefinition := build.BuildDefinition{ Id: buildDefinitionReference, Name: converter.String(d.Get("name").(string)), @@ -919,6 +924,7 @@ func expandBuildDefinition(d *schema.ResourceData) (*build.BuildDefinition, stri VariableGroups: expandVariableGroups(d), Variables: variables, Triggers: &buildTriggers, + Tags: &tags, } if agentPoolName, ok := d.GetOk("agent_pool_name"); ok { diff --git a/azuredevops/internal/service/build/resource_build_definition_test.go b/azuredevops/internal/service/build/resource_build_definition_test.go index c3e535641..7dfbffab8 100644 --- a/azuredevops/internal/service/build/resource_build_definition_test.go +++ b/azuredevops/internal/service/build/resource_build_definition_test.go @@ -121,6 +121,7 @@ var testBuildDefinition = build.BuildDefinition{ Quality: &build.DefinitionQualityValues.Definition, Triggers: &[]interface{}{}, VariableGroups: &[]build.VariableGroup{}, + Tags: &[]string{}, } // This definition matches the overall structure of what a configured Bitbucket git repository would From 9676a775840d6a56963c5ae0a0e13e886c8a9210 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Tue, 1 Sep 2020 08:35:34 -0700 Subject: [PATCH 02/41] adding in release pipelines --- azuredevops/internal/model/tags.go | 12 + .../internal/service/distributedtask/task.go | 378 +++ .../release/resource_release_definition.go | 2951 +++++++++++++++++ .../resource_release_definition_test.go | 392 +++ azuredevops/provider.go | 2 + azuredevops/provider_test.go | 1 + 6 files changed, 3736 insertions(+) create mode 100644 azuredevops/internal/model/tags.go create mode 100644 azuredevops/internal/service/distributedtask/task.go create mode 100644 azuredevops/internal/service/release/resource_release_definition.go create mode 100644 azuredevops/internal/service/release/resource_release_definition_test.go diff --git a/azuredevops/internal/model/tags.go b/azuredevops/internal/model/tags.go new file mode 100644 index 000000000..2263acb4c --- /dev/null +++ b/azuredevops/internal/model/tags.go @@ -0,0 +1,12 @@ +package model + +import "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + +// TagsSchema list of tags +var TagsSchema = &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, +} diff --git a/azuredevops/internal/service/distributedtask/task.go b/azuredevops/internal/service/distributedtask/task.go new file mode 100644 index 000000000..bbd3d8878 --- /dev/null +++ b/azuredevops/internal/service/distributedtask/task.go @@ -0,0 +1,378 @@ +package distributedtask + +import "github.com/google/uuid" + +// TaskNameToUUID mapping of task name to task uuid +var TaskNameToUUID = map[string]uuid.UUID{} + +// TaskUUIDToName mapping of task uuid to task name +var TaskUUIDToName = map[uuid.UUID]string{} + +func init() { + task0Uuid, _ := uuid.Parse("e213ff0f-5d5c-4791-802d-52ea3e7be1f1") + TaskNameToUUID["PowerShell"] = task0Uuid + task1Uuid, _ := uuid.Parse("72a1931b-effb-4d2e-8fd8-f8472a07cb62") + TaskNameToUUID["AzurePowerShell"] = task1Uuid + task2Uuid, _ := uuid.Parse("6fec3938-df52-4c01-9f5a-8ed5f66c377e") + TaskNameToUUID["MysqlDeploymentOnMachineGroup"] = task2Uuid + task3Uuid, _ := uuid.Parse("5e3feff0-c5ae-11e8-a7d0-4bd3b8229800") + TaskNameToUUID["PipAuthenticate"] = task3Uuid + task4Uuid, _ := uuid.Parse("ac4ee482-65da-4485-a532-7b085873e532") + TaskNameToUUID["Maven"] = task4Uuid + task5Uuid, _ := uuid.Parse("5541a522-603c-47ad-91fc-a4b1d163081b") + TaskNameToUUID["DotNetCoreCLI"] = task5Uuid + task6Uuid, _ := uuid.Parse("ff50fc97-da8c-4683-b014-34c15315ee5f") + TaskNameToUUID["XamarinComponentRestore"] = task6Uuid + task7Uuid, _ := uuid.Parse("497d490f-eea7-4f2b-ab94-48d9c1acdcb1") + TaskNameToUUID["AzureRmWebAppDeployment"] = task7Uuid + task8Uuid, _ := uuid.Parse("3b5693d4-5777-4fee-862a-bd2b7a374c68") + TaskNameToUUID["PowerShellOnTargetMachines"] = task8Uuid + task9Uuid, _ := uuid.Parse("2a7ebc54-c13e-490e-81a5-d7561ab7cd97") + TaskNameToUUID["PublishCodeCoverageResults"] = task9Uuid + task10Uuid, _ := uuid.Parse("d353d6a2-e361-4a8f-8d8c-123bebb71028") + TaskNameToUUID["RunVisualStudioTestsusingTestAgent"] = task10Uuid + task11Uuid, _ := uuid.Parse("bcb64569-d51a-4af0-9c01-ea5d05b3b622") + TaskNameToUUID["ManualIntervention"] = task11Uuid + task12Uuid, _ := uuid.Parse("0f9f66ca-250e-40fd-9678-309bcd439d5e") + TaskNameToUUID["InstallAppleProvisioningProfile"] = task12Uuid + task13Uuid, _ := uuid.Parse("730d8de1-7a4f-424c-9542-fe7cc02604eb") + TaskNameToUUID["SonarQubePostTest"] = task13Uuid + task14Uuid, _ := uuid.Parse("2d8a1d60-8ccd-11e7-a792-11ac56e9f553") + TaskNameToUUID["PyPIPublisher"] = task14Uuid + task15Uuid, _ := uuid.Parse("c7b7ccf9-d6e0-472b-97bb-06b6e43504f3") + TaskNameToUUID["ChefKnife"] = task15Uuid + task16Uuid, _ := uuid.Parse("334727f4-9495-4f9d-a391-fc621d671474") + TaskNameToUUID["GoTool"] = task16Uuid + task17Uuid, _ := uuid.Parse("f54d001c-999f-408a-9867-0400c1838c5e") + TaskNameToUUID["XcodePackageiOS"] = task17Uuid + task18Uuid, _ := uuid.Parse("34b37fdd-bbf7-4ef1-b37c-9652ca7bb355") + TaskNameToUUID["Go"] = task18Uuid + task19Uuid, _ := uuid.Parse("01fa79eb-4c54-41b5-a16f-5cd8d60db88d") + TaskNameToUUID["PublishPipelineMetadata"] = task19Uuid + task20Uuid, _ := uuid.Parse("e28912f1-0114-4464-802a-a3a35437fd16") + TaskNameToUUID["Docker"] = task20Uuid + task21Uuid, _ := uuid.Parse("c24b86d4-4256-4925-9a29-246f81aa64a7") + TaskNameToUUID["JenkinsQueueJob"] = task21Uuid + task22Uuid, _ := uuid.Parse("6f8c69a5-b023-428e-a125-fccf4efcb929") + TaskNameToUUID["FtpUpload"] = task22Uuid + task23Uuid, _ := uuid.Parse("731004d4-1d66-4f70-8c05-638018b22210") + TaskNameToUUID["WindowsMachineFileCopy"] = task23Uuid + task24Uuid, _ := uuid.Parse("df857559-8715-46eb-a74e-ac98b9178aa0") + TaskNameToUUID["AndroidBuild"] = task24Uuid + task25Uuid, _ := uuid.Parse("e4d58330-c771-11e8-8f8f-81fbb42e2824") + TaskNameToUUID["TwineAuthenticate"] = task25Uuid + task26Uuid, _ := uuid.Parse("1b467810-6725-4b6d-accd-886174c09bba") + TaskNameToUUID["IISWebAppDeploymentOnMachineGroup"] = task26Uuid + task27Uuid, _ := uuid.Parse("6392f95f-7e76-4a18-b3c7-7f078d2f7700") + TaskNameToUUID["PythonScript"] = task27Uuid + task28Uuid, _ := uuid.Parse("068d5909-43e6-48c5-9e01-7c8a94816220") + TaskNameToUUID["HelmInstaller"] = task28Uuid + task29Uuid, _ := uuid.Parse("6237827d-6244-4d52-b93e-47d8610fbd8a") + TaskNameToUUID["XamarinLicense"] = task29Uuid + task30Uuid, _ := uuid.Parse("f5fd8599-ccfa-4d6e-b965-4d14bed7097b") + TaskNameToUUID["NuGetAuthenticate"] = task30Uuid + task31Uuid, _ := uuid.Parse("9fac244b-8d7c-4d8e-a003-2097daa3270f") + TaskNameToUUID["DownloadGitHubNugetPackage"] = task31Uuid + task32Uuid, _ := uuid.Parse("d4b964f9-ea90-41bb-9526-29589628ad90") + TaskNameToUUID["MavenAuthenticate"] = task32Uuid + task33Uuid, _ := uuid.Parse("deeafed4-0b18-4f58-968d-86655b4d2ce9") + TaskNameToUUID["ReviewApp"] = task33Uuid + task34Uuid, _ := uuid.Parse("c0e0b74f-0931-47c7-ac27-7c5a19456a36") + TaskNameToUUID["JavaToolInstaller"] = task34Uuid + task35Uuid, _ := uuid.Parse("b719db6c-40a2-4f43-9aff-827825baecae") + TaskNameToUUID["Chef"] = task35Uuid + task36Uuid, _ := uuid.Parse("501dd25d-1785-43e4-b4e5-a5c78ccc0573") + TaskNameToUUID["AzureFunctionApp"] = task36Uuid + task37Uuid, _ := uuid.Parse("ad884ca2-732e-4b85-b2d3-ed71bcbd2788") + TaskNameToUUID["npmAuthenticate"] = task37Uuid + task38Uuid, _ := uuid.Parse("c6c4c611-aa2e-4a33-b606-5eaba2196824") + TaskNameToUUID["MSBuild"] = task38Uuid + task39Uuid, _ := uuid.Parse("845fd4f4-642d-4694-8514-047948a5a556") + TaskNameToUUID["PackerBuild"] = task39Uuid + task40Uuid, _ := uuid.Parse("333b11bd-d341-40d9-afcf-b32d5ce6f24b") + TaskNameToUUID["NuGetPackager"] = task40Uuid + task41Uuid, _ := uuid.Parse("97ef6e59-b8cc-48aa-9937-1a01e35e7584") + TaskNameToUUID["ServiceFabricUpdateAppVersions"] = task41Uuid + task42Uuid, _ := uuid.Parse("11ea7cf0-8a3e-4b5a-98a2-8756cc3094b0") + TaskNameToUUID["DuffleInstaller"] = task42Uuid + task43Uuid, _ := uuid.Parse("99a72e7f-25e4-4576-bf38-22a42b995ed8") + TaskNameToUUID["AzureMonitor"] = task43Uuid + task44Uuid, _ := uuid.Parse("e94f1750-a6a8-11e6-be69-bdf37a7b15d8") + TaskNameToUUID["AzureNLBManagement"] = task44Uuid + task45Uuid, _ := uuid.Parse("f20661eb-e0f7-4afd-9a86-9fe9d1a93382") + TaskNameToUUID["ApacheJMeterLoadTest"] = task45Uuid + task46Uuid, _ := uuid.Parse("6975e2d1-96d3-4afc-8a41-498b5d34ea19") + TaskNameToUUID["DockerCompose"] = task46Uuid + task47Uuid, _ := uuid.Parse("1d876d40-9aa7-11e7-905d-f541cc882994") + TaskNameToUUID["AzureMonitorAlerts"] = task47Uuid + task48Uuid, _ := uuid.Parse("049918cb-1488-48eb-85e8-c318eccaaa74") + TaskNameToUUID["XamarinTestCloud"] = task48Uuid + task49Uuid, _ := uuid.Parse("c6650aa0-185b-11e6-a47d-df93e7a34c64") + TaskNameToUUID["ServiceFabricDeploy"] = task49Uuid + task50Uuid, _ := uuid.Parse("1e78dc1b-9132-4b18-9c75-0e7ecc634b74") + TaskNameToUUID["Xcode"] = task50Uuid + task51Uuid, _ := uuid.Parse("333b11bd-d341-40d9-afcf-b32d5ce6f25b") + TaskNameToUUID["NuGetPublisher"] = task51Uuid + task52Uuid, _ := uuid.Parse("f1e4b0e6-017e-4819-8a48-ef19ae96e289") + TaskNameToUUID["queryWorkItems"] = task52Uuid + task53Uuid, _ := uuid.Parse("15858991-8bac-4542-99e7-577fef9b5be6") + TaskNameToUUID["AzureWebAppContainer"] = task53Uuid + task54Uuid, _ := uuid.Parse("4b506f7f-720f-47bb-bf21-029bac6a690d") + TaskNameToUUID["SqlDacpacDeploymentOnMachineGroup"] = task54Uuid + task55Uuid, _ := uuid.Parse("d53ccab4-555e-4494-9d06-11db043fb4a9") + TaskNameToUUID["Cache"] = task55Uuid + task56Uuid, _ := uuid.Parse("7d831c3c-3c68-459a-a5c9-bde6e659596c") + TaskNameToUUID["CMake"] = task56Uuid + task57Uuid, _ := uuid.Parse("ad5cd22a-be4e-48bb-adce-181a32432da5") + TaskNameToUUID["AppCenterTest"] = task57Uuid + task58Uuid, _ := uuid.Parse("2a6ca863-f2ce-4f4d-8bcb-15e64608ec4b") + TaskNameToUUID["DownloadSecureFile"] = task58Uuid + task59Uuid, _ := uuid.Parse("630c472c-cde7-4cd8-ba13-e00ca5ff180b") + TaskNameToUUID["UseRubyVersion"] = task59Uuid + task60Uuid, _ := uuid.Parse("521d1e15-f5fb-4b73-a93b-b2fe88a9a286") + TaskNameToUUID["Grunt"] = task60Uuid + task61Uuid, _ := uuid.Parse("ce85a08b-a538-4d2b-8589-1d37a9ab970f") + TaskNameToUUID["SqlAzureDacpacDeployment"] = task61Uuid + task62Uuid, _ := uuid.Parse("39bc2c9b-55b7-4835-89cd-6cc699ef7220") + TaskNameToUUID["ContainerStructureTest"] = task62Uuid + task63Uuid, _ := uuid.Parse("89a3a82d-4b3e-4a09-8d40-a793849dc94f") + TaskNameToUUID["IISWebAppDeployment"] = task63Uuid + task64Uuid, _ := uuid.Parse("9e9db38a-b40b-4c13-b7f0-31031c894c22") + TaskNameToUUID["CloudLoadTest"] = task64Uuid + task65Uuid, _ := uuid.Parse("8413c881-4959-43d5-8840-b4ea0ffc5cfd") + TaskNameToUUID["KubectlInstaller"] = task65Uuid + task66Uuid, _ := uuid.Parse("d9bafed4-0b18-4f58-968d-86655b4d2ce9") + TaskNameToUUID["CmdLine"] = task66Uuid + task67Uuid, _ := uuid.Parse("2661b7e5-00f9-4de1-ba41-04e68d70b528") + TaskNameToUUID["NuGet"] = task67Uuid + task68Uuid, _ := uuid.Parse("8413c881-4959-43d5-8840-b4ea0ffc5cfe") + TaskNameToUUID["ContainerBuild"] = task68Uuid + task69Uuid, _ := uuid.Parse("333b11bd-d341-40d9-afcf-b32d5ce6f23b") + TaskNameToUUID["NuGetInstaller"] = task69Uuid + task70Uuid, _ := uuid.Parse("28782b92-5e8e-4458-9751-a71cd1492bae") + TaskNameToUUID["Delay"] = task70Uuid + task71Uuid, _ := uuid.Parse("0f077e3a-af59-496d-81bc-ad971b7464e0") + TaskNameToUUID["XamariniOS"] = task71Uuid + task72Uuid, _ := uuid.Parse("0b0f01ed-7dde-43ff-9cbb-e48954daf9b1") + TaskNameToUUID["PublishTestResults"] = task72Uuid + task73Uuid, _ := uuid.Parse("eb72cb01-a7e5-427b-a8a1-1b31ccac8a43") + TaskNameToUUID["AzureFileCopy"] = task73Uuid + task74Uuid, _ := uuid.Parse("0675668a-7bba-4ccb-901d-5ad6554ca653") + TaskNameToUUID["PublishSymbols"] = task74Uuid + task75Uuid, _ := uuid.Parse("67cec91b-0351-4c2f-8465-d74b3d2a2d96") + TaskNameToUUID["CopyFilesOverSSH"] = task75Uuid + task76Uuid, _ := uuid.Parse("8d8eebd8-2b94-4c97-85af-839254cc6da4") + TaskNameToUUID["Gradle"] = task76Uuid + task77Uuid, _ := uuid.Parse("b832bec5-8c27-4fef-9fb8-6bec8524ad8a") + TaskNameToUUID["AppCenterDistribute"] = task77Uuid + task78Uuid, _ := uuid.Parse("2c65196a-54fd-4a02-9be8-d9d1837b7c5d") + TaskNameToUUID["NuGetToolInstaller"] = task78Uuid + task79Uuid, _ := uuid.Parse("86c37a92-59a7-444b-93c7-220fcf91e29c") + TaskNameToUUID["JenkinsDownloadArtifacts"] = task79Uuid + task80Uuid, _ := uuid.Parse("13c22ce0-3b93-43f9-aeb7-71fbce7bf5b2") + TaskNameToUUID["AzureFunctionAppContainer"] = task80Uuid + task81Uuid, _ := uuid.Parse("7c6a6b71-4355-4afc-a274-480eab5678e9") + TaskNameToUUID["DecryptFile"] = task81Uuid + task82Uuid, _ := uuid.Parse("afa7d54d-537b-4dc8-b60a-e0eeea2c9a87") + TaskNameToUUID["HelmDeploy"] = task82Uuid + task83Uuid, _ := uuid.Parse("d2eff759-736d-4b7b-8554-7ba0960d49d6") + TaskNameToUUID["InstallAppleCertificate"] = task83Uuid + task84Uuid, _ := uuid.Parse("537fdb7a-a601-4537-aa70-92645a2b5ce4") + TaskNameToUUID["AzureFunction"] = task84Uuid + task85Uuid, _ := uuid.Parse("263abc27-4582-4174-8789-af599697778e") + TaskNameToUUID["DownloadGitHubRelease"] = task85Uuid + task86Uuid, _ := uuid.Parse("91443475-df55-4874-944b-39253b558790") + TaskNameToUUID["SSH"] = task86Uuid + task87Uuid, _ := uuid.Parse("ecdc45f6-832d-4ad9-b52b-ee49e94659be") + TaskNameToUUID["PublishPipelineArtifact"] = task87Uuid + task88Uuid, _ := uuid.Parse("eae5b2cc-ac5e-4cba-b022-a06621f9c01f") + TaskNameToUUID["SonarQubePreBuild"] = task88Uuid + task89Uuid, _ := uuid.Parse("e3cf3806-ad30-4ec4-8f1e-8ecd98771aa0") + TaskNameToUUID["DownloadFileshareArtifacts"] = task89Uuid + task90Uuid, _ := uuid.Parse("cbc316a2-586f-4def-be79-488a1f503564") + TaskNameToUUID["Kubernetes"] = task90Uuid + task91Uuid, _ := uuid.Parse("80f3f6a0-82a6-4a22-ba7a-e5b8c541b9b8") + TaskNameToUUID["AzureIoTEdge"] = task91Uuid + task92Uuid, _ := uuid.Parse("19c02b15-d377-40e0-9efa-3168506e0933") + TaskNameToUUID["ServiceFabricComposeDeploy"] = task92Uuid + task93Uuid, _ := uuid.Parse("80f3f6a0-82a6-4a22-ba7a-e5b8c541b9b9") + TaskNameToUUID["AndroidSigning"] = task93Uuid + task94Uuid, _ := uuid.Parse("61f2a582-95ae-4948-b34d-a1b3c4f6a737") + TaskNameToUUID["DownloadPipelineArtifact"] = task94Uuid + task95Uuid, _ := uuid.Parse("33c63b11-352b-45a2-ba1b-54cb568a29ca") + TaskNameToUUID["UsePythonVersion"] = task95Uuid + task96Uuid, _ := uuid.Parse("816979f7-c273-4347-9a55-845b721d82cb") + TaskNameToUUID["ServiceFabricPowerShell"] = task96Uuid + task97Uuid, _ := uuid.Parse("ef087383-ee5e-42c7-9a53-ab56c98420f9") + TaskNameToUUID["VSTest"] = task97Uuid + task98Uuid, _ := uuid.Parse("3a6a2d63-f2b2-4e93-bcf9-0cbe22f5dc26") + TaskNameToUUID["Ant"] = task98Uuid + task99Uuid, _ := uuid.Parse("52a38a6a-1517-41d7-96cc-73ee0c60d2b6") + TaskNameToUUID["DeployVisualStudioTestAgent"] = task99Uuid + task100Uuid, _ := uuid.Parse("03dd16c3-43e0-4667-ba84-40515d27a410") + TaskNameToUUID["CondaEnvironment"] = task100Uuid + task101Uuid, _ := uuid.Parse("bfc8bf76-e7ac-4a8c-9a55-a944a9f632fd") + TaskNameToUUID["BatchScript"] = task101Uuid + task102Uuid, _ := uuid.Parse("97411e3d-0241-4b1f-9607-2d2c04b4df51") + TaskNameToUUID["DownloadGithubNpmPackage"] = task102Uuid + task103Uuid, _ := uuid.Parse("71a9a2d3-a98a-4caa-96ab-affca411ecda") + TaskNameToUUID["VSBuild"] = task103Uuid + task104Uuid, _ := uuid.Parse("1e244d32-2dd4-4165-96fb-b7441ca9331e") + TaskNameToUUID["AzureKeyVault"] = task104Uuid + task105Uuid, _ := uuid.Parse("b0ce7256-7898-45d3-9cb5-176b752bfea6") + TaskNameToUUID["DotNetCoreInstaller"] = task105Uuid + task106Uuid, _ := uuid.Parse("f045e430-8704-11e6-968f-e717e6411619") + TaskNameToUUID["AzureAppServiceManage"] = task106Uuid + task107Uuid, _ := uuid.Parse("a22a6eb4-fe21-442e-abce-5b2b09cfece3") + TaskNameToUUID["FuncToolsInstaller"] = task107Uuid + task108Uuid, _ := uuid.Parse("8ce97e91-56cc-4743-bfab-9a9315be5f27") + TaskNameToUUID["FileTransform"] = task108Uuid + task109Uuid, _ := uuid.Parse("5e1e3830-fbfb-11e5-aab1-090c92bc4988") + TaskNameToUUID["ExtractFiles"] = task109Uuid + task110Uuid, _ := uuid.Parse("27edd013-36fd-43aa-96a3-7d73e1e35285") + TaskNameToUUID["XamarinAndroid"] = task110Uuid + task111Uuid, _ := uuid.Parse("1d341bb0-2106-458c-8422-d00bcea6512a") + TaskNameToUUID["CopyPublishBuildArtifacts"] = task111Uuid + task112Uuid, _ := uuid.Parse("8d6e8f7e-267d-442d-8c92-1f586864c62f") + TaskNameToUUID["DownloadPackage"] = task112Uuid + task113Uuid, _ := uuid.Parse("94a74903-f93f-4075-884f-dc11f34058b4") + TaskNameToUUID["AzureResourceManagerTemplateDeployment"] = task113Uuid + task114Uuid, _ := uuid.Parse("9c3e8943-130d-4c78-ac63-8af81df62dfb") + TaskNameToUUID["InvokeRESTAPI"] = task114Uuid + task115Uuid, _ := uuid.Parse("d8b84976-e99a-4b86-b885-4849694435b0") + TaskNameToUUID["ArchiveFiles"] = task115Uuid + task116Uuid, _ := uuid.Parse("deea6198-adf8-4b16-9939-7addf85708b2") + TaskNameToUUID["GitHubComment"] = task116Uuid + task117Uuid, _ := uuid.Parse("5bfb729a-a7c8-4a78-a7c3-8d717bb7c13c") + TaskNameToUUID["CopyFiles"] = task117Uuid + task118Uuid, _ := uuid.Parse("bd1bed02-f04e-11e7-8c3f-9a214cf093ae") + TaskNameToUUID["AzureMysqlDeployment"] = task118Uuid + task119Uuid, _ := uuid.Parse("fe47e961-9fa8-4106-8639-368c022d43ad") + TaskNameToUUID["Npm"] = task119Uuid + task120Uuid, _ := uuid.Parse("31c75bbb-bcdf-4706-8d7c-4da6a1959bc2") + TaskNameToUUID["NodeTool"] = task120Uuid + task121Uuid, _ := uuid.Parse("70a3a82d-4a3c-4a09-8d30-a793739dc94f") + TaskNameToUUID["SqlServerDacpacDeployment"] = task121Uuid + task122Uuid, _ := uuid.Parse("2c65196a-54fd-4a02-9be8-d9d1837b7111") + TaskNameToUUID["VisualStudioTestPlatformInstaller"] = task122Uuid + task123Uuid, _ := uuid.Parse("ba761f24-cbd6-48cb-92f3-fc13396405b1") + TaskNameToUUID["PublishToAzureServiceBus"] = task123Uuid + task124Uuid, _ := uuid.Parse("dee316a2-586f-4def-be79-488a1f503dfe") + TaskNameToUUID["KubernetesManifest"] = task124Uuid + task125Uuid, _ := uuid.Parse("a433f589-fce1-4460-9ee6-44a624aeb1fb") + TaskNameToUUID["DownloadBuildArtifacts"] = task125Uuid + task126Uuid, _ := uuid.Parse("bfc05e0d-839c-42cd-89c7-0f9fbfcab965") + TaskNameToUUID["CocoaPods"] = task126Uuid + task127Uuid, _ := uuid.Parse("18bde28a-8172-45cb-b204-5cef1393dbb1") + TaskNameToUUID["AzureWebApp"] = task127Uuid + task128Uuid, _ := uuid.Parse("46e4be58-730b-4389-8a2f-ea10b3e5e815") + TaskNameToUUID["AzureCLI"] = task128Uuid + task129Uuid, _ := uuid.Parse("7b5a6198-adf8-4b16-9939-7addf85708b2") + TaskNameToUUID["GitHubRelease"] = task129Uuid + task130Uuid, _ := uuid.Parse("ad8974d8-de11-11e4-b2fe-7fb898a745f3") + TaskNameToUUID["cURLUploader"] = task130Uuid + task131Uuid, _ := uuid.Parse("3eeea460-bffa-11e9-9cb5-2a2ae2dbcce4") + TaskNameToUUID["AzureAppServiceSettings"] = task131Uuid + task132Uuid, _ := uuid.Parse("e0b79640-8625-11e8-91be-db2878ff888a") + TaskNameToUUID["UniversalPackages"] = task132Uuid + task133Uuid, _ := uuid.Parse("8ba74703-e94f-4a35-814e-fc21f44578a2") + TaskNameToUUID["AzurePolicyCheckGate"] = task133Uuid + task134Uuid, _ := uuid.Parse("fd1aa5b9-400c-4f4b-9c0b-069ba74e53c6") + TaskNameToUUID["AzureFunctionOnKubernetes"] = task134Uuid + task135Uuid, _ := uuid.Parse("6c731c3c-3c68-459a-a5c9-bde6e6595b5b") + TaskNameToUUID["ShellScript"] = task135Uuid + task136Uuid, _ := uuid.Parse("2ff763a7-ce83-4e1f-bc89-0ae63477cebe") + TaskNameToUUID["PublishBuildArtifacts"] = task136Uuid + task137Uuid, _ := uuid.Parse("5c9af2eb-5fc5-42dc-9b91-dc234a8c4400") + TaskNameToUUID["InstallSSHKey"] = task137Uuid + task138Uuid, _ := uuid.Parse("4dda660c-b643-4598-a4a2-61080d0002d9") + TaskNameToUUID["AzureVmssDeployment"] = task138Uuid + task139Uuid, _ := uuid.Parse("dcbef2c9-e4f4-4929-82b2-ea7fc9166109") + TaskNameToUUID["AzureWebPowerShellDeployment"] = task139Uuid + task140Uuid, _ := uuid.Parse("2ca8fe15-42ea-4b26-80f1-e0738ec17e89") + TaskNameToUUID["AzureCloudPowerShellDeployment"] = task140Uuid + task141Uuid, _ := uuid.Parse("b7e8b412-0437-4065-9371-edc5881de25b") + TaskNameToUUID["DeleteFiles"] = task141Uuid + task142Uuid, _ := uuid.Parse("b82cfbe4-34f9-40f5-889e-c8842ca9dd9d") + TaskNameToUUID["gulp"] = task142Uuid + task143Uuid, _ := uuid.Parse("9648625c-1523-4eb5-b015-dfe7c685840c") + TaskNameToUUID["QuickPerfTest"] = task143Uuid + task144Uuid, _ := uuid.Parse("1b2aec60-dc49-11e6-9b76-63056e018cac") + TaskNameToUUID["IISWebAppManagementOnMachineGroup"] = task144Uuid + task145Uuid, _ := uuid.Parse("8e038650-f7bf-11e8-8a6c-8fff434b4eff") + TaskNameToUUID["DockerInstaller"] = task145Uuid + task146Uuid, _ := uuid.Parse("30f6a876-1d27-450c-b2bb-9f390a592082") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.S3Download.S3Download"] = task146Uuid + task147Uuid, _ := uuid.Parse("081ccf10-2f14-48dd-9bd0-892b8975d24f") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.AWSCLI.AWSCLI"] = task147Uuid + task148Uuid, _ := uuid.Parse("57ef2af4-cd99-4298-bf77-2feb5dc51863") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.SystemsManagerGetParameter.SystemsManagerGetParameter"] = task148Uuid + task149Uuid, _ := uuid.Parse("3a219265-181c-4ed2-9a51-75a7f308f0d5") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.S3Upload.S3Upload"] = task149Uuid + task150Uuid, _ := uuid.Parse("a8515ec8-7254-4ffd-912c-86772e2b5962") + TaskNameToUUID["qetza.replacetokens.replacetokens-task.replacetokens"] = task150Uuid + task151Uuid, _ := uuid.Parse("2ff35748-7800-409d-9511-a0a37ff0d348") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.CodeDeployDeployApplication.CodeDeployDeployApplication"] = task151Uuid + task152Uuid, _ := uuid.Parse("1399d161-270d-4ee9-b913-78b177165406") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.BeanstalkDeployApplication.BeanstalkDeployApplication"] = task152Uuid + task153Uuid, _ := uuid.Parse("467d1870-1a00-4755-b00d-9642129fe759") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.ECRPushImage.ECRPushImage"] = task153Uuid + task154Uuid, _ := uuid.Parse("6d01813a-9589-4b15-8491-8164aeb38055") + TaskNameToUUID["SonarSource.sonarqube.6D01813A-9589-4B15-8491-8164AEB38055.SonarQubeScannerMsBuildEnd"] = task154Uuid + task155Uuid, _ := uuid.Parse("f15dc48c-4351-4c96-927c-729360a3164b") + TaskNameToUUID["bleddynrichards.Assembly-Info-Task.Assembly-Info-NetCore.Assembly-Info-NetCore"] = task155Uuid + task156Uuid, _ := uuid.Parse("c67b072a-0853-4578-95c1-acbc26e8897a") + TaskNameToUUID["BigAvocado.Terragrunt.installTerragrunt.installTerragrunt"] = task156Uuid + task157Uuid, _ := uuid.Parse("11645770-d18e-11e8-8f5b-1b8b62612b3b") + TaskNameToUUID["charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-installer.TerraformInstaller"] = task157Uuid + task158Uuid, _ := uuid.Parse("2ec1147b-5c33-41df-94b5-676758d87c1b") + TaskNameToUUID["geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller"] = task158Uuid + task159Uuid, _ := uuid.Parse("0c632a66-60d4-498a-88c8-1c69cc057ef1") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.LambdaNETCoreDeploy.LambdaNETCoreDeploy"] = task159Uuid + task160Uuid, _ := uuid.Parse("bc6233ad-6a33-41c0-b2af-9d71898008d0") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.SystemsManagerRunCommand.SystemsManagerRunCommand"] = task160Uuid + task161Uuid, _ := uuid.Parse("c9e49f96-6c7d-4420-97f1-5e0dfd816354") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.LambdaInvokeFunction.LambdaInvokeFunction"] = task161Uuid + task162Uuid, _ := uuid.Parse("291ed61f-1ee4-45d3-b1b0-bf822d9095ef") + TaskNameToUUID["SonarSource.sonarqube.291ed61f-1ee4-45d3-b1b0-bf822d9095ef.SonarQubePublish"] = task162Uuid + task163Uuid, _ := uuid.Parse("15b84ca1-b62f-4a2a-a403-89b77a063157") + TaskNameToUUID["SonarSource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubeScannerMsBuildBegin"] = task163Uuid + task164Uuid, _ := uuid.Parse("0888c9a9-d1b2-4567-aae2-beadcb2059b3") + TaskNameToUUID["geeklearningio.gl-vsts-tasks-yarn.yarn-task.Yarn"] = task164Uuid + task165Uuid, _ := uuid.Parse("089bda61-367d-4d7c-a06b-88f7e2f20f22") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.CloudFormationDeleteStack.CloudFormationDeleteStack"] = task165Uuid + task166Uuid, _ := uuid.Parse("ec87c253-756f-4a7a-be91-4f1c60f9d8fe") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.LambdaDeployFunction.LambdaDeployFunction"] = task166Uuid + task167Uuid, _ := uuid.Parse("ff19b049-2efa-4d42-ae91-630fee8c5e1f") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.ECRPullImage.ECRPullImage"] = task167Uuid + task168Uuid, _ := uuid.Parse("67d18db7-e637-48f8-80b3-91f440db4931") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.SendMessage.SendMessage"] = task168Uuid + task169Uuid, _ := uuid.Parse("d531ff03-d75a-41e5-92e8-7b4680e02eb4") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.BeanstalkCreateApplicationVersion.BeanstalkCreateApplicationVersion"] = task169Uuid + task170Uuid, _ := uuid.Parse("b6d19a53-dc5f-4b71-a49c-63e87f49e9ab") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.SecretsManagerGetSecret.SecretsManagerGetSecret"] = task170Uuid + task171Uuid, _ := uuid.Parse("721c3f90-d938-11e8-9d92-09d7594721b5") + TaskNameToUUID["charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-cli.TerraformCLI"] = task171Uuid + task172Uuid, _ := uuid.Parse("3d6cb0c8-d1f9-465f-957a-a02c776646a0") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.SecretsManagerCreateOrUpdateSecret.SecretsManagerCreateOrUpdateSecret"] = task172Uuid + task173Uuid, _ := uuid.Parse("7ef7cdfa-aa45-42c5-93c8-d7603643dd99") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.CloudFormationCreateOrUpdateStack.CloudFormationCreateOrUpdateStack"] = task173Uuid + task174Uuid, _ := uuid.Parse("019b0650-1f0e-4376-ad37-1498abef311e") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.CloudFormationExecuteChangeSet.CloudFormationExecuteChangeSet"] = task174Uuid + task175Uuid, _ := uuid.Parse("13f9d337-5ae6-4f96-9bc2-fe2b18a6319b") + TaskNameToUUID["Farrellsoft.publish-html-task.publish-html-task.publishHtml"] = task175Uuid + task176Uuid, _ := uuid.Parse("3aea39d2-803c-43c7-b8d6-8e71b670f816") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.AWSShellScript.AWSShellScript"] = task176Uuid + task177Uuid, _ := uuid.Parse("3edc451e-360c-40e5-a221-a42d5c987ab8") + TaskNameToUUID["bleddynrichards.Assembly-Info-Task.Assembly-Info-Task.Assembly-Info-NetFramework"] = task177Uuid + task178Uuid, _ := uuid.Parse("9f57024b-31f9-4e58-9e39-a47ccc098f03") + TaskNameToUUID["SonarSource.sonarqube.9F57024B-31F9-4E58-9E39-A47CCC098F03.SonarQubeScannerCli"] = task178Uuid + task179Uuid, _ := uuid.Parse("37dda93c-8427-4372-9b7b-9b6e10f3f744") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.AWSPowerShellModuleScript.AWSPowerShellModuleScript"] = task179Uuid + task180Uuid, _ := uuid.Parse("3c47544d-0c9b-49e1-89a4-3c94d0586c89") + TaskNameToUUID["AmazonWebServices.aws-vsts-tools.SystemsManagerSetParameter.SystemsManagerSetParameter"] = task180Uuid + + for k, v := range TaskNameToUUID { + TaskUUIDToName[v] = k + } +} diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go new file mode 100644 index 000000000..ae4fbc436 --- /dev/null +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -0,0 +1,2951 @@ +package release + +import ( + "encoding/json" + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/release" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/client" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/model" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/service/distributedtask" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/utils/converter" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/utils/validate" + "log" + "regexp" + "sort" + "strconv" + "strings" + "time" +) + +func Log(i interface{}) { + d, _ := json.MarshalIndent(i, "", " ") + log.Println(string(d)) +} + +/* +NOTE : https://www.terraform.io/docs/extend/writing-custom-providers.html +Due to the limitation of tf-11115 it is not possible to nest maps. So the workaround is to let only the innermost data structure be of the type TypeMap: in this case driver_options. The outer data structures are of TypeList which can only have one item. + +TODO : Based on the info above any of the Min: 1, Max: 1, items will MOST LIKELY become TypeList instead of TypeSet. +TODO : Otherwise a custom schema.Schema.Set function will need to be created to identify them in the set. +This fixes the behaviour of apply. Otherwise sometimes apply marking data as changed because of nexted children. +*/ + +func ResourceReleaseDefinition() *schema.Resource { + + id := &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + } + + rank := &schema.Schema{ + Type: schema.TypeInt, + Computed: true, + } + + timeoutInMinutes := &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Default: 0, + } + + maxExecutionInMinutes := &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Default: 1, + ValidateFunc: validation.IntAtLeast(1), + } + + variableGroups := &schema.Schema{ + Type: schema.TypeList, + Elem: &schema.Schema{ + Type: schema.TypeInt, + ValidateFunc: validation.IntAtLeast(1), + }, + Optional: true, + } + + configurationVariableValue := map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "value": { + Type: schema.TypeString, + Required: true, + }, + "allow_override": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "is_secret": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + } + + configurationVariables := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: configurationVariableValue, + }, + } + + // TODO : import these from YAML + //taskInputValidation := map[string]*schema.Schema{ + // "expression": { + // Type: schema.TypeString, + // Required: true, + // }, + // "message": { + // Type: schema.TypeString, + // Optional: true, + // }, + //} + + demand := map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "value": { + Type: schema.TypeString, + Optional: true, + }, + } + + demands := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: demand, + }, + } + + artifactItems := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + } + + buildArtifactDownloads := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "artifact_alias": { + Type: schema.TypeString, + Required: true, + }, + "include": artifactItems, + }, + }, + } + + overrideInputs := &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + } + + task := map[string]*schema.Schema{ + // NOTE : Due to limitations of ConflictsWith & ExactlyOneOf when using nested structures. https://github.com/hashicorp/terraform-plugin-sdk/issues/71 + // Task will be the only field supplied. + "task": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: func(i interface{}, k string) ([]string, []error) { + v, ok := i.(string) + if !ok { + return nil, []error{fmt.Errorf("expected type of %q to be string", k)} + } + var validID = regexp.MustCompile(`^.*?@\d+`) + if match := validID.MatchString(v); !match { + return nil, []error{fmt.Errorf("invalid task format is name@version")} + } + task := strings.Split(v, "@") + taskName := task[0] + if _, ok := distributedtask.TaskNameToUUID[taskName]; !ok { + return nil, []error{fmt.Errorf("unkown task %q", taskName)} + } + return nil, nil + }, + // ConflictsWith: []string{"task_id", "version"}, + }, + "always_run": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "condition": { + Type: schema.TypeString, + Optional: true, + Default: "succeeded()", + }, + "continue_on_error": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "enabled": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + "environment": { + Type: schema.TypeMap, + Optional: true, + }, + "display_name": { + Type: schema.TypeString, + Optional: true, + }, + "override_inputs": overrideInputs, + "timeout_in_minutes": timeoutInMinutes, + "inputs": { + Type: schema.TypeMap, + Optional: true, + }, + // NOTE : Due to limitations of ConflictsWith & ExactlyOneOf when using nested structures. https://github.com/hashicorp/terraform-plugin-sdk/issues/71 + // It is not possible to have task OR task_id/version + // If ConflictsWith & ExactlyOneOf support * then this could be done. + //"task_id": { + // Type: schema.TypeString, + // Required: true, + // ExactlyOneOf: []string{"task_id", "task"}, + //}, + //"version": { + // Type: schema.TypeString, + // Required: true, + // ExactlyOneOf: []string{"version", "task"}, + //}, + } + + tasks := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: task, + }, + } + + releaseDefinitionDeployStep := &schema.Schema{ + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": id, + "task": tasks, + }, + }, + } + + approvalOptions := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "auto_triggered_and_previous_environment_approved_can_be_skipped": { + Type: schema.TypeBool, + Optional: true, + }, + "enforce_identity_revalidation": { + Type: schema.TypeBool, + Optional: true, + }, + "execution_order": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(release.ApprovalExecutionOrderValues.AfterGatesAlways), + string(release.ApprovalExecutionOrderValues.AfterSuccessfulGates), + string(release.ApprovalExecutionOrderValues.BeforeGates), + }, false), + }, + "release_creator_can_be_approver": { + Type: schema.TypeBool, + Optional: true, + }, + "required_approver_count": { + Type: schema.TypeInt, + Optional: true, + }, + "timeout_in_minutes": timeoutInMinutes, + }, + }, + } + + releaseDefinitionGatesOptions := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "is_enabled": { + Type: schema.TypeBool, + Optional: true, + }, + "minimum_success_duration": { + Type: schema.TypeInt, + Optional: true, + }, + "sampling_interval": { + Type: schema.TypeInt, + Optional: true, + }, + "stabilization_time": { + Type: schema.TypeInt, + Optional: true, + }, + "timeout": { + Type: schema.TypeInt, + Optional: true, + }, + }, + }, + } + + releaseDefinitionGate := map[string]*schema.Schema{ + "task": tasks, + } + + releaseDefinitionGates := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: releaseDefinitionGate, + }, + } + + releaseDefinitionGatesStep := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": id, + "gate": releaseDefinitionGates, + "gates_options": releaseDefinitionGatesOptions, + }, + }, + } + + skipArtifactsDownload := &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + } + + environmentOptions := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "auto_link_work_items": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "badge_enabled": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "publish_deployment_status": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + "pull_request_deployment_enabled": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + }, + }, + } + + environmentExecutionPolicy := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "concurrency_count": { + Type: schema.TypeInt, + Optional: true, + Default: 1, + }, + "queue_depth_count": { + Type: schema.TypeInt, + Optional: true, + Default: 0, + }, + }, + }, + } + + schedule := map[string]*schema.Schema{ + "days_to_release": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(release.ScheduleDaysValues.All), + string(release.ScheduleDaysValues.Friday), + string(release.ScheduleDaysValues.Monday), + string(release.ScheduleDaysValues.None), + string(release.ScheduleDaysValues.Saturday), + string(release.ScheduleDaysValues.Sunday), + string(release.ScheduleDaysValues.Thursday), + string(release.ScheduleDaysValues.Tuesday), + string(release.ScheduleDaysValues.Wednesday), + }, false), + }, + "job_id": { + Type: schema.TypeString, + Required: true, + }, + "schedule_only_with_changes": { + Type: schema.TypeBool, + Required: true, + }, + "start_hours": { + Type: schema.TypeInt, + Required: true, + }, + "start_minutes": { + Type: schema.TypeInt, + Required: true, + }, + "time_zone_id": { + Type: schema.TypeString, + Required: true, + }, + } + + schedules := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: schedule, + }, + } + + releaseDefinitionProperties := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "definition_creation_source": { + Type: schema.TypeString, + Optional: true, + Default: "ReleaseNew", + }, + "integrate_jira_work_items": { + Type: schema.TypeBool, + Optional: true, + Default: false, + AtLeastOneOf: []string{"properties.0.jira_service_endpoint_id"}, + }, + "integrate_boards_work_items": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "jira_service_endpoint_id": { + Type: schema.TypeString, + Optional: true, + AtLeastOneOf: []string{"properties.0.integrate_jira_work_items"}, + }, + }, + }, + } + + environmentType := &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + string(DeploymentTypeValues.Production), + string(DeploymentTypeValues.Staging), + string(DeploymentTypeValues.Testing), + string(DeploymentTypeValues.Development), + string(DeploymentTypeValues.Unmapped), + }, false), + } + + releaseDefinitionEnvironmentProperties := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "boards_environment_type": environmentType, + "link_boards_work_items": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "jira_environment_type": environmentType, + "link_jira_work_items": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + }, + }, + } + + releaseTrigger := map[string]*schema.Schema{ + "trigger_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(release.EnvironmentTriggerTypeValues.Undefined), + string(release.EnvironmentTriggerTypeValues.DeploymentGroupRedeploy), + string(release.EnvironmentTriggerTypeValues.RollbackRedeploy), + }, false), + }, + } + + releaseTriggers := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: releaseTrigger, + }, + } + + environmentTrigger := map[string]*schema.Schema{ + "definition_environment_id": { + Type: schema.TypeInt, + Optional: true, + }, + "release_definition_id": { + Type: schema.TypeInt, + Optional: true, + }, + "trigger_content": { + Type: schema.TypeString, + Optional: true, + }, + "trigger_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(release.EnvironmentTriggerTypeValues.Undefined), + string(release.EnvironmentTriggerTypeValues.DeploymentGroupRedeploy), + string(release.EnvironmentTriggerTypeValues.RollbackRedeploy), + }, false), + }, + } + + environmentTriggers := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: environmentTrigger, + }, + } + + buildArtifact := map[string]*schema.Schema{ + "project_id": { + Type: schema.TypeString, + Required: true, + }, + "build_pipeline_id": { + Type: schema.TypeString, + Required: true, + }, + "latest": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "branch": { + Type: schema.TypeString, + Optional: true, + }, + "tags": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + ExactlyOneOf: []string{"build_artifact.0.latest", "build_artifact.0.specify"}, + }, + "specify": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "version": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + ExactlyOneOf: []string{"build_artifact.0.latest", "build_artifact.0.specify"}, + }, + "alias": { + Type: schema.TypeString, + Optional: true, + }, + "is_primary": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "is_retained": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + } + buildArtifacts := &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: buildArtifact, + }, + } + + approval := &schema.Schema{ + Type: schema.TypeList, + Required: true, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": id, + "rank": rank, + "approver_id": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.IsUUID, + }, + }, + }, + } + + releaseDefinitionApproval := &schema.Schema{ + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "approval": approval, + }, + }, + // TODO : How to solve "ignore" if empty and new is isAutomated? + // NOTE : Currently the compare between Set is not showing partial update but is complete remove and add. + } + + retentionPolicy := &schema.Schema{ + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "days_to_keep": { + Type: schema.TypeInt, + Optional: true, + Default: 30, + }, + "releases_to_keep": { + Type: schema.TypeInt, + Optional: true, + Default: 3, + }, + "retain_build": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + }, + }, + } + + allowScriptsToAccessOauthToken := &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + } + + stages := &schema.Schema{ + Type: schema.TypeList, + Required: true, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": id, + "rank": rank, + "name": { + Type: schema.TypeString, + Required: true, + }, + "owner_id": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.IsUUID, + }, + "variable": configurationVariables, + "variable_groups": variableGroups, + "pre_deploy_approval": releaseDefinitionApproval, + "post_deploy_approval": releaseDefinitionApproval, + // NOTE : the ui only allows setting these to the same value for Post and Pre + "approval_options": approvalOptions, + + "deploy_step": releaseDefinitionDeployStep, + + "job": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "agent": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "override_inputs": overrideInputs, + "demand": demands, + "rank": rank, + "agent_pool_hosted_azure_pipelines": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "agent_pool_id": { + Type: schema.TypeInt, + Required: true, + }, + "agent_specification": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + "macOS-10.13", + "macOS-10.14", + "ubuntu-16.04", + "ubuntu-18.04", + "vs2015-win2012r2", + "vs2017-win2016", + "win1803", + "windows-2019", + }, false), + }, + }, + }, + }, + "build_artifact_download": buildArtifactDownloads, + "agent_pool_private": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "agent_pool_id": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + "timeout_in_minutes": timeoutInMinutes, + "max_execution_time_in_minutes": maxExecutionInMinutes, + "condition": { + Type: schema.TypeString, + Optional: true, + Default: "succeeded()", + }, + "multi_configuration": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "multipliers": { + Type: schema.TypeString, + Required: true, + Description: "A list of comma separated configuration variables to use. These are defined on the Variables tab. For example, OperatingSystem, Browser will run the tasks for both variables.", + }, + "number_of_agents": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, + "continue_on_error": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + }, + }, + }, + "multi_agent": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "max_number_of_agents": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, + "continue_on_error": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + }, + }, + }, + "skip_artifacts_download": skipArtifactsDownload, + "allow_scripts_to_access_oauth_token": allowScriptsToAccessOauthToken, + "task": tasks, + }, + }, + }, + "deployment_group": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "override_inputs": overrideInputs, + "demand": demands, + "rank": rank, + "deployment_group_id": { + Type: schema.TypeInt, + Required: true, + }, + "tags": model.TagsSchema, + "multiple": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "max_targets_in_parallel": { + Type: schema.TypeInt, + Required: true, + }, + }, + }, + }, + "allow_scripts_to_access_oauth_token": allowScriptsToAccessOauthToken, + "timeout_in_minutes": timeoutInMinutes, + "max_execution_time_in_minutes": maxExecutionInMinutes, + "condition": { + Type: schema.TypeString, + Required: true, + }, + "task": tasks, + "skip_artifacts_download": skipArtifactsDownload, + }, + }, + }, + "agentless": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "override_inputs": overrideInputs, + "rank": rank, + "timeout_in_minutes": timeoutInMinutes, + "max_execution_time_in_minutes": maxExecutionInMinutes, + "condition": { + Type: schema.TypeString, + Optional: true, + Default: "succeeded()", + }, + "multi_configuration": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "multipliers": { + Type: schema.TypeString, + Required: true, + Description: "A list of comma separated configuration variables to use. These are defined on the Variables tab. For example, OperatingSystem, Browser will run the tasks for both variables.", + }, + "continue_on_error": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + }, + }, + }, + "task": tasks, + }, + }, + }, + }, + }, + }, + "retention_policy": retentionPolicy, + + // TODO : This is missing from the docs + // "runOptions": runOptions, + "environment_options": environmentOptions, + "demand": { + Type: schema.TypeList, + Optional: true, + Deprecated: "Use DeploymentInput.Demands instead", + Elem: &schema.Resource{ + Schema: demand, + }, + }, + "after_stage": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "stage_name": { + Type: schema.TypeString, + Required: true, + }, + "trigger_even_when_stages_partially_succeed": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + }, + }, + // TODO : deeply nested validation + // ConflictsWith: []string{"after_release"}, + }, + + "after_release": { + Type: schema.TypeList, + MinItems: 1, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "event_name": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + // TODO : deeply nested validation + // ConflictsWith: []string{"after_stage"}, + }, + + "artifact_filter": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "artifact_alias": { + Type: schema.TypeString, + Required: true, + }, + "include": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "branch_name": { + Type: schema.TypeString, + Required: true, + }, + "tags": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, + }, + }, + }, + }, + }, + "exclude": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "branch_name": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + }, + }, + }, + "execution_policy": environmentExecutionPolicy, + "schedules": schedules, + "properties": releaseDefinitionEnvironmentProperties, + "pre_deploy_gate": releaseDefinitionGatesStep, + "post_deploy_gate": releaseDefinitionGatesStep, + "environment_triggers": environmentTriggers, + "badge_url": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + } + + return &schema.Resource{ + Create: resourceReleaseDefinitionCreate, + Read: resourceReleaseDefinitionRead, + Update: resourceReleaseDefinitionUpdate, + Delete: resourceReleaseDefinitionDelete, + Importer: &schema.ResourceImporter{ + State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + projectID, buildDefinitionID, err := tfhelper.ParseImportedID(d.Id()) + if err != nil { + return nil, fmt.Errorf("error parsing the build definition ID from the Terraform resource data: %v", err) + } + d.Set("project_id", projectID) + d.SetId(fmt.Sprintf("%d", buildDefinitionID)) + + return []*schema.ResourceData{d}, nil + }, + }, + Schema: map[string]*schema.Schema{ + "project_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "revision": { + Type: schema.TypeInt, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Optional: true, + Default: "", + }, + "path": { + Type: schema.TypeString, + Optional: true, + Default: "\\", + ValidateFunc: validate.Path, + }, + "variable_groups": variableGroups, + "source": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + Default: "", + }, + "variable": configurationVariables, + "release_name_format": { + Type: schema.TypeString, + Optional: true, + Default: "Release-$(rev:r)", + }, + "url": { + Type: schema.TypeString, + Computed: true, + }, + "is_deleted": { + Type: schema.TypeBool, + Computed: true, + }, + "tags": model.TagsSchema, + "properties": releaseDefinitionProperties, + "comment": { + Type: schema.TypeString, + Optional: true, + Default: "", + DiffSuppressFunc: func(_, _, _ string, _ *schema.ResourceData) bool { return true }, + }, + "created_on": { + Type: schema.TypeString, + Computed: true, + }, + "modified_on": { + Type: schema.TypeString, + Computed: true, + }, + "stage": stages, + "build_artifact": buildArtifacts, + "triggers": releaseTriggers, + }, + } +} + +func flattenReleaseDefinition(d *schema.ResourceData, releaseDefinition *release.ReleaseDefinition, projectID string) { + d.SetId(strconv.Itoa(*releaseDefinition.Id)) + d.Set("project_id", projectID) + d.Set("name", *releaseDefinition.Name) + d.Set("path", *releaseDefinition.Path) + d.Set("variable_groups", *releaseDefinition.VariableGroups) + d.Set("source", *releaseDefinition.Source) + d.Set("description", converter.ToString(releaseDefinition.Description, "")) + d.Set("variable", flattenReleaseDefinitionVariables(releaseDefinition.Variables)) + d.Set("release_name_format", *releaseDefinition.ReleaseNameFormat) + d.Set("url", *releaseDefinition.Url) + d.Set("is_deleted", *releaseDefinition.IsDeleted) + d.Set("tags", *releaseDefinition.Tags) + d.Set("properties", flattenReleaseDefinitionProperties(releaseDefinition.Properties)) + if releaseDefinition.Comment != nil { + d.Set("comment", *releaseDefinition.Comment) + } + d.Set("created_on", releaseDefinition.CreatedOn.Time.Format(time.RFC3339)) + d.Set("modified_on", releaseDefinition.ModifiedOn.Time.Format(time.RFC3339)) + d.Set("stage", flattenReleaseDefinitionEnvironmentList(releaseDefinition.Environments)) + d.Set("build_artifact", flattenReleaseDefinitionArtifactsList(releaseDefinition.Artifacts, release.AgentArtifactTypeValues.Build)) + d.Set("triggers", flattenReleaseDefinitionTriggersList(releaseDefinition.Triggers)) + + revision := 0 + if releaseDefinition.Revision != nil { + revision = *releaseDefinition.Revision + } + d.Set("revision", revision) +} + +func resourceReleaseDefinitionCreate(d *schema.ResourceData, m interface{}) error { + clients := m.(*client.AggregatedClient) + releaseDefinition, projectID, err := expandReleaseDefinition(d) + if err != nil { + return fmt.Errorf("error creating resource Release Definition: %+v", err) + } + + createdReleaseDefinition, err := createReleaseDefinition(clients, releaseDefinition, projectID) + if err != nil { + return fmt.Errorf("error creating resource Release Definition: %+v", err) + } + + flattenReleaseDefinition(d, createdReleaseDefinition, projectID) + return nil +} + +func resourceReleaseDefinitionRead(d *schema.ResourceData, m interface{}) error { + clients := m.(*client.AggregatedClient) + projectID, releaseDefinitionID, err := tfhelper.ParseProjectIDAndResourceID(d) + + if err != nil { + return err + } + + releaseDefinition, err := clients.ReleaseClient.GetReleaseDefinition(clients.Ctx, release.GetReleaseDefinitionArgs{ + Project: &projectID, + DefinitionId: &releaseDefinitionID, + }) + + if err != nil { + return err + } + + flattenReleaseDefinition(d, releaseDefinition, projectID) + return nil +} + +func resourceReleaseDefinitionDelete(d *schema.ResourceData, m interface{}) error { + if d.Id() == "" { + return nil + } + + clients := m.(*client.AggregatedClient) + projectID, releaseDefinitionID, err := tfhelper.ParseProjectIDAndResourceID(d) + if err != nil { + return err + } + + err = clients.ReleaseClient.DeleteReleaseDefinition(m.(*client.AggregatedClient).Ctx, release.DeleteReleaseDefinitionArgs{ + Project: &projectID, + DefinitionId: &releaseDefinitionID, + }) + + return err +} + +func resourceReleaseDefinitionUpdate(d *schema.ResourceData, m interface{}) error { + clients := m.(*client.AggregatedClient) + releaseDefinition, projectID, err := expandReleaseDefinition(d) + if err != nil { + return err + } + + updatedReleaseDefinition, err := clients.ReleaseClient.UpdateReleaseDefinition(m.(*client.AggregatedClient).Ctx, release.UpdateReleaseDefinitionArgs{ + ReleaseDefinition: releaseDefinition, + Project: &projectID, + }) + + if err != nil { + return err + } + + flattenReleaseDefinition(d, updatedReleaseDefinition, projectID) + return nil +} + +func createReleaseDefinition(clients *client.AggregatedClient, releaseDefinition *release.ReleaseDefinition, project string) (*release.ReleaseDefinition, error) { + createdBuild, err := clients.ReleaseClient.CreateReleaseDefinition(clients.Ctx, release.CreateReleaseDefinitionArgs{ + ReleaseDefinition: releaseDefinition, + Project: &project, + }) + + return createdBuild, err +} + +func expandReleaseDefinition(d *schema.ResourceData) (*release.ReleaseDefinition, string, error) { + projectID := d.Get("project_id").(string) + + // Look for the ID. This may not exist if we are within the context of a "create" operation, + // so it is OK if it is missing. + releaseDefinitionID, err := strconv.Atoi(d.Id()) + var releaseDefinitionReference *int = nil + if err == nil { + releaseDefinitionReference = &releaseDefinitionID + } + + createdOn, _ := time.Parse(time.RFC3339, d.Get("created_on").(string)) + modifiedOn, _ := time.Parse(time.RFC3339, d.Get("modified_on").(string)) + source := expandReleaseDefinitionSource(d.Get("source").(string)) + variableGroups := expandIntList(d.Get("variable_groups").([]interface{})) + environments := expandReleaseDefinitionEnvironmentList(d.Get("stage").([]interface{})) + variables := expandReleaseConfigurationVariableValueList(d.Get("variable").([]interface{})) + properties := expandReleaseDefinitionPropertiesListFirstOrNil(d.Get("properties").([]interface{})) + triggers := expandReleaseDefinitionTriggersList(d.Get("triggers").([]interface{})) + buildArtifacts := expandReleaseArtifactList(d.Get("build_artifact").([]interface{}), release.AgentArtifactTypeValues.Build) + + artifacts := buildArtifacts + + tags := tfhelper.ExpandStringList(d.Get("tags").([]interface{})) + + releaseDefinition := release.ReleaseDefinition{ + Id: releaseDefinitionReference, + Name: converter.String(d.Get("name").(string)), + Path: converter.String(d.Get("path").(string)), + Revision: converter.Int(d.Get("revision").(int)), + Description: converter.String(d.Get("description").(string)), + Environments: &environments, + Variables: &variables, + ReleaseNameFormat: converter.String(d.Get("release_name_format").(string)), + VariableGroups: &variableGroups, + Properties: properties, + Artifacts: &artifacts, + Url: converter.String(d.Get("url").(string)), + Comment: converter.String(d.Get("comment").(string)), + Tags: &tags, + CreatedOn: &azuredevops.Time{Time: createdOn}, + ModifiedOn: &azuredevops.Time{Time: modifiedOn}, + IsDeleted: converter.Bool(d.Get("is_deleted").(bool)), + Source: &source, + Triggers: &triggers, + } + + return &releaseDefinition, projectID, nil +} + +// AgentDeploymentInput phase type which contains tasks executed on agent +type AgentDeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Artifacts that downloaded during job execution. + ArtifactsDownloadInput *release.ArtifactsDownloadInput `json:"artifactsDownloadInput,omitempty"` + // List demands that needs to meet to execute the job. + Demands *[]interface{} `json:"demands,omitempty"` + // Indicates whether to include access token in deployment job or not. + EnableAccessToken *bool `json:"enableAccessToken,omitempty"` + // Id of the pool on which job get executed. + QueueID *int `json:"queueId,omitempty"` + // Indicates whether artifacts downloaded while job execution or not. + SkipArtifactsDownload *bool `json:"skipArtifactsDownload,omitempty"` + // Specification for an agent on which a job gets executed. + AgentSpecification *release.AgentSpecification `json:"agentSpecification,omitempty"` + // Gets or sets the image ID. + ImageID *int `json:"imageId,omitempty"` + // Gets or sets the parallel execution input. + ParallelExecution interface{} `json:"parallelExecution,omitempty"` +} + +// ServerDeploymentInput phase type which contains tasks executed by server +type ServerDeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Gets or sets the parallel execution input. + ParallelExecution interface{} `json:"parallelExecution,omitempty"` +} + +// ReleaseDeployPhase the deploy phase +type ReleaseDeployPhase struct { + // Dynamic based on PhaseType + DeploymentInput interface{} `json:"deploymentInput,omitempty"` + // WorkflowTasks + WorkflowTasks *[]release.WorkflowTask `json:"workflowTasks,omitempty"` + // Gets or sets the reference name of the task. + RefName *string `json:"refName,omitempty"` + // Name of the phase. + Name *string `json:"name,omitempty"` + // Type of the phase. + PhaseType *release.DeployPhaseTypes `json:"phaseType,omitempty"` + // Rank of the phase. + Rank *int `json:"rank,omitempty"` + + // TODO : Figure out if this is used for Deployment Job Group or all 3 Job Types. + // Deployment jobs of the phase. + //DeploymentJobs *[]release.DeploymentJob `json:"deploymentJobs,omitempty"` + + // TODO : Add manual_intervention {} (block) under agentless_job { } (block) + // List of manual intervention tasks execution information in phase. + ManualInterventions *[]release.ManualIntervention `json:"manualInterventions,omitempty"` + + // TODO : Remove below properties after a little R&D + + // TODO : Going to remove Id. As it is Deprecated. + // Deprecated: + //Id *int `json:"id,omitempty"` + + // TODO : Consider removing ID. As I do not believe you can change the value via the API. + // TODO : If you can change via API then allow updating. Also explore if this cause a ForceNew/ForceReplace + // ID of the phase. + //PhaseId *string `json:"phaseId,omitempty"` + + // TODO : Consider removing RunPlanId. It is stateful data about the current state of the pipeline. + // TODO : This does not seem like something one would want with terraform. + // Run Plan ID of the phase. + //RunPlanId *uuid.UUID `json:"runPlanId,omitempty"` + + // TODO : Consider removing StartedOn. It is stateful data about the current state of the pipeline. + // TODO : This does not seem like something one would want with terraform. + // Phase start time. + //StartedOn *azuredevops.Time `json:"startedOn,omitempty"` + + // TODO : Consider removing Status. It is stateful data about the current state of the pipeline. + // TODO : This does not seem like something one would want with terraform. + // Status of the phase. + //Status *release.DeployPhaseStatus `json:"status,omitempty"` + + // TODO : Consider removing ErrorLog. It is stateful data about the current state of the pipeline. + // TODO : This does not seem like something one would want with terraform. + // Phase execution error logs. + //ErrorLog *string `json:"errorLog,omitempty"` +} + +// ArtifactDownloadModeType download type +type ArtifactDownloadModeType string +type artifactDownloadModeTypeValuesType struct { + Skip ArtifactDownloadModeType + Selective ArtifactDownloadModeType + All ArtifactDownloadModeType +} + +// ArtifactDownloadModeTypeValues enum of download type +var ArtifactDownloadModeTypeValues = artifactDownloadModeTypeValuesType{ + Skip: "Skip", + Selective: "Selective", + All: "All", +} + +// DeploymentHealthOptionType health check type +type DeploymentHealthOptionType string +type deploymentHealthOptionValuesType struct { + OneTargetAtATime DeploymentHealthOptionType + Custom DeploymentHealthOptionType +} + +// DeploymentHealthOptionTypeValues enum of health check type +var DeploymentHealthOptionTypeValues = deploymentHealthOptionValuesType{ + OneTargetAtATime: "OneTargetAtATime", + Custom: "Custom", +} + +// ReleaseDefinitionDemand demand +type ReleaseDefinitionDemand struct { + // Name of the demand. + Name *string `json:"name,omitempty"` + // The value of the demand. + Value *string `json:"value,omitempty"` +} + +// MachineGroupDeploymentMultiple phase type which contains tasks executed on deployment group machines. +type MachineGroupDeploymentMultiple struct { +} + +// ReleaseHostedAzurePipelines hosted agent details +type ReleaseHostedAzurePipelines struct { + AgentSpecification *release.AgentSpecification + QueueID *int +} + +// DefaultVersionType health check type +type DefaultVersionType string +type defaultVersionValuesType struct { + Latest DefaultVersionType + LatestWithBranchAndTags DefaultVersionType + LatestWithBuildDefinitionBranchAndTags DefaultVersionType + SpecificVersion DefaultVersionType + SelectDuringReleaseCreation DefaultVersionType +} + +// DefaultVersionTypeValues enum of health check type +var DefaultVersionTypeValues = defaultVersionValuesType{ + Latest: "latestType", // "Latest" + LatestWithBranchAndTags: "latestWithBranchAndTagsType", // "Latest from a specific branch with tags" + LatestWithBuildDefinitionBranchAndTags: "latestWithBuildDefinitionBranchAndTagsType", // "Latest from the build pipeline default branch with tags" + SpecificVersion: "specificVersionType", // "Specific version" + SelectDuringReleaseCreation: "selectDuringReleaseCreationType", // "Specify at the time of release creation" +} + +// DeploymentType deployment type +type DeploymentType string +type deploymentTypeValuesType struct { + Production DeploymentType + Staging DeploymentType + Testing DeploymentType + Development DeploymentType + Unmapped DeploymentType +} + +// DeploymentTypeValues enum of download type +var DeploymentTypeValues = deploymentTypeValuesType{ + Production: "production", + Staging: "staging", + Testing: "testing", + Development: "development", + Unmapped: "unmapped", +} + +func expandStringMapString(d map[string]interface{}) map[string]string { + vs := make(map[string]string) + for k, v := range d { + if s, ok := v.(string); ok { + vs[k] = s + } else if s, ok := v.(int); ok { + vs[k] = string(s) + } else if b, ok := v.(bool); ok { + vs[k] = strconv.FormatBool(b) + } else if f, ok := v.(float64); ok { + vs[k] = strconv.FormatFloat(f, 'E', -1, 64) + } + } + return vs +} + +func expandIntList(d []interface{}) []int { + vs := make([]int, 0, len(d)) + for _, v := range d { + val, ok := v.(string) + if ok && val != "" { + vs = append(vs, v.(int)) + } + } + return vs +} + +func expandReleaseDefinitionSource(d string) release.ReleaseDefinitionSource { + switch d { + case string(release.ReleaseDefinitionSourceValues.RestApi): + return release.ReleaseDefinitionSourceValues.RestApi + case string(release.ReleaseDefinitionSourceValues.Ibiza): + return release.ReleaseDefinitionSourceValues.Ibiza + case string(release.ReleaseDefinitionSourceValues.PortalExtensionApi): + return release.ReleaseDefinitionSourceValues.PortalExtensionApi + case string(release.ReleaseDefinitionSourceValues.UserInterface): + return release.ReleaseDefinitionSourceValues.UserInterface + } + return release.ReleaseDefinitionSourceValues.Undefined +} + +func expandReleaseStringProperty(d string) interface{} { + return map[string]interface{}{ + "$type": "System.String", + "$value": d, + } +} + +func expandReleaseEnvironmentProperties(d map[string]interface{}) map[string]interface{} { + return map[string]interface{}{ + "BoardsEnvironmentType": expandReleaseStringProperty(d["boards_environment_type"].(string)), + "LinkBoardsWorkItems": expandReleaseStringProperty(strconv.FormatBool(d["link_boards_work_items"].(bool))), + "JiraEnvironmentType": expandReleaseStringProperty(d["jira_environment_type"].(string)), + "LinkJiraWorkItems": expandReleaseStringProperty(strconv.FormatBool(d["link_jira_work_items"].(bool))), + } +} +func expandReleaseEnvironmentList(d []interface{}) []map[string]interface{} { + vs := make([]map[string]interface{}, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseEnvironmentProperties(val)) + } + } + return vs +} +func expandReleaseEnvironmentPropertiesListFirstOrNil(d []interface{}) interface{} { + d2 := expandReleaseEnvironmentList(d) + if len(d2) != 1 { + return nil + } + return d2[0] +} + +func expandReleaseDefinitionProperties(d map[string]interface{}) map[string]interface{} { + return map[string]interface{}{ + "DefinitionCreationSource": expandReleaseStringProperty(d["definition_creation_source"].(string)), + "IntegrateJiraWorkItems": expandReleaseStringProperty(strconv.FormatBool(d["integrate_jira_work_items"].(bool))), + "IntegrateBoardsWorkItems": expandReleaseStringProperty(strconv.FormatBool(d["integrate_boards_work_items"].(bool))), + "JiraServiceEndpointId": expandReleaseStringProperty(d["jira_service_endpoint_id"].(string)), + } +} +func expandReleaseDefinitionPropertiesList(d []interface{}) []map[string]interface{} { + vs := make([]map[string]interface{}, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseDefinitionProperties(val)) + } + } + return vs +} +func expandReleaseDefinitionPropertiesListFirstOrNil(d []interface{}) interface{} { + d2 := expandReleaseDefinitionPropertiesList(d) + if len(d2) != 1 { + return nil + } + return d2[0] +} + +func expandReleaseDefinitionTriggers(d map[string]interface{}) map[string]interface{} { + return map[string]interface{}{} +} +func expandReleaseDefinitionTriggersList(d []interface{}) []interface{} { + vs := make([]interface{}, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseDefinitionTriggers(val)) + } + } + return vs +} + +func expandReleaseCondition(d map[string]interface{}, t release.ConditionType) release.Condition { + vs := release.Condition{ConditionType: &t} + switch t { + case release.ConditionTypeValues.EnvironmentState: + vs.Name = converter.String(d["stage_name"].(string)) + vs.Value = converter.String("4") + case release.ConditionTypeValues.Event: + vs.Name = converter.String(d["event_name"].(string)) + vs.Value = converter.String("") + } + return vs +} +func expandReleaseConditionList(d []interface{}, t release.ConditionType, eventName *string) []release.Condition { + vs := make([]release.Condition, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + if val["event_name"] == "" && eventName != nil { + val["event_name"] = *eventName + } + vs = append(vs, expandReleaseCondition(val, t)) + } else if eventName != nil { + condition := map[string]interface{}{"event_name": *eventName} + vs = append(vs, expandReleaseCondition(condition, t)) + } + } + return vs +} + +func expandArtifactIncludeExclude(d map[string]interface{}, name string) release.Condition { + tags := make([]interface{}, 0, 0) + if m, ok := d["tags"].(*schema.Set); ok { + tags = m.List() + } + vs := map[string]interface{}{ + "sourceBranch": d["branch_name"], + "tags": tags, + "useBuildDefinitionBranch": false, + "createReleaseOnBuildTagging": false, + } + value, _ := json.Marshal(vs) + return release.Condition{ + Name: converter.String(name), + ConditionType: &release.ConditionTypeValues.Artifact, + Value: converter.String(string(value)), + } +} +func expandArtifactIncludeExcludeList(d []interface{}, name string) []release.Condition { + vs := make([]release.Condition, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandArtifactIncludeExclude(val, name)) + } + } + return vs +} + +func expandReleaseConditionArtifactFilter(d map[string]interface{}) []release.Condition { + includes := expandArtifactIncludeExcludeList(d["include"].([]interface{}), d["artifact_alias"].(string)) + excludes := expandArtifactIncludeExcludeList(d["exclude"].([]interface{}), d["artifact_alias"].(string)) + return append(includes, excludes...) +} +func expandReleaseConditionArtifactFilterList(d []interface{}) []release.Condition { + vs := make([]release.Condition, 0, 0) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseConditionArtifactFilter(val)...) + } + } + return vs +} + +func deployPhasesToInterface(deployPhases interface{}) *[]interface{} { + data, _ := json.Marshal(deployPhases) + var dp []interface{} + var _ = json.Unmarshal(data, &dp) + return &dp +} + +func expandJob(d map[string]interface{}, rank int) *ReleaseDeployPhase { + vs := &ReleaseDeployPhase{} + if a, ok := d["agent"].([]interface{}); ok && len(a) > 0 { + vs = expandReleaseDeployPhaseListFirstOrNil(a, release.DeployPhaseTypesValues.AgentBasedDeployment) + } + if dg, ok := d["deployment_group"].([]interface{}); ok && len(dg) > 0 { + vs = expandReleaseDeployPhaseListFirstOrNil(dg, release.DeployPhaseTypesValues.MachineGroupBasedDeployment) + } + if al, ok := d["agentless"].([]interface{}); ok && len(al) > 0 { + vs = expandReleaseDeployPhaseListFirstOrNil(al, release.DeployPhaseTypesValues.RunOnServer) + } + vs.Rank = converter.Int(rank) + return vs +} + +func expandJobsList(d []interface{}) []interface{} { + vs := make([]interface{}, 0, 0) + for i, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandJob(val, i+1)) + } + } + return vs +} + +func expandReleaseDefinitionEnvironment(d map[string]interface{}, rank int) release.ReleaseDefinitionEnvironment { + variableGroups := expandIntList(d["variable_groups"].([]interface{})) + deployStep := expandReleaseDefinitionDeployStepListFirstOrNil(d["deploy_step"].([]interface{})) + variables := expandReleaseConfigurationVariableValueList(d["variable"].([]interface{})) + demands := expandReleaseDefinitionDemandList(d["demand"].([]interface{})) + environmentOptions := expandReleaseEnvironmentOptionsListFirstOrNil(d["environment_options"].([]interface{})) + retentionPolicy := expandReleaseEnvironmentRetentionPolicyListFirstOrNil(d["retention_policy"].([]interface{})) + preDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["pre_deploy_approval"].([]interface{})) + postDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["post_deploy_approval"].([]interface{})) + properties := expandReleaseEnvironmentPropertiesListFirstOrNil(d["properties"].([]interface{})) + deployPhases := expandJobsList(d["job"].([]interface{})) + preDeploymentGates := expandReleaseDefinitionGatesStepListFirstOrNil(d["pre_deploy_gate"].([]interface{})) + postDeploymentGates := expandReleaseDefinitionGatesStepListFirstOrNil(d["post_deploy_gate"].([]interface{})) + afterStageConditions := expandReleaseConditionList(d["after_stage"].([]interface{}), release.ConditionTypeValues.EnvironmentState, nil) + afterReleaseConditions := expandReleaseConditionList(d["after_release"].([]interface{}), release.ConditionTypeValues.Event, converter.String("ReleaseStarted")) + artifactFilters := expandReleaseConditionArtifactFilterList(d["artifact_filter"].([]interface{})) + conditions := append(append(afterStageConditions, afterReleaseConditions...), artifactFilters...) + + return release.ReleaseDefinitionEnvironment{ + Id: converter.Int(d["id"].(int)), + Conditions: &conditions, + Demands: &demands, + DeployPhases: deployPhasesToInterface(deployPhases), + DeployStep: deployStep, + EnvironmentOptions: environmentOptions, + //EnvironmentTriggers: nil, + //ExecutionPolicy: nil, + //Id: converter.Int(d["id"].(int)), + Name: converter.String(d["name"].(string)), + PostDeployApprovals: postDeployApprovals, + PostDeploymentGates: preDeploymentGates, + PreDeployApprovals: preDeployApprovals, + PreDeploymentGates: postDeploymentGates, + //ProcessParameters: nil, + Properties: properties, + QueueId: nil, + Rank: converter.Int(rank), + RetentionPolicy: retentionPolicy, + //RunOptions: nil, + //Schedules: nil, + VariableGroups: &variableGroups, + Variables: &variables, + Owner: &webapi.IdentityRef{Id: converter.String(d["owner_id"].(string))}, + } +} +func expandReleaseDefinitionEnvironmentList(d []interface{}) []release.ReleaseDefinitionEnvironment { + vs := make([]release.ReleaseDefinitionEnvironment, 0, len(d)) + for i, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseDefinitionEnvironment(val, i+1)) + } + } + return vs +} + +func expandSingleMapList(d []interface{}) map[string]interface{} { + if len(d) == 1 { + if ds, ok := d[0].(map[string]interface{}); ok { + return ds + } + } + return nil +} + +func expandReleaseBuildArtifact(d map[string]interface{}) map[string]release.ArtifactSourceReference { + defaultType := DefaultVersionTypeValues.Latest + branch := "" + version := "" + tags := "" + + latest := expandSingleMapList(d["latest"].([]interface{})) + if latest != nil { + branch = latest["branch"].(string) + tags = latest["tags"].(string) + if branch != "" && tags != "" { + defaultType = DefaultVersionTypeValues.LatestWithBranchAndTags + } else if tags != "" { + defaultType = DefaultVersionTypeValues.LatestWithBuildDefinitionBranchAndTags + } + } + + specify := expandSingleMapList(d["specify"].([]interface{})) + if specify != nil { + version = specify["version"].(string) + if version != "" { + defaultType = DefaultVersionTypeValues.SpecificVersion + } else { + defaultType = DefaultVersionTypeValues.SelectDuringReleaseCreation + } + } + if defaultType == DefaultVersionTypeValues.Latest && len(d["specify"].([]interface{})) == 1 { + defaultType = DefaultVersionTypeValues.SelectDuringReleaseCreation + } + + return map[string]release.ArtifactSourceReference{ + //"artifactSourceDefinitionUrl": {Id: converter.String("")}, + "defaultVersionBranch": {Id: converter.String(branch)}, + "defaultVersionSpecific": {Id: converter.String(version)}, + "defaultVersionTags": {Id: converter.String(tags)}, + "defaultVersionType": {Id: converter.String(string(defaultType))}, + "definition": {Id: converter.String(d["build_pipeline_id"].(string))}, + "definitions": {Id: converter.String("")}, + "IsMultiDefinitionType": {Id: converter.String("False")}, + "project": {Id: converter.String(d["project_id"].(string))}, + //"repository": {Id: converter.String("")}, + } +} + +func expandReleaseArtifactDefinitionReference(d map[string]interface{}, t release.AgentArtifactType) map[string]release.ArtifactSourceReference { + switch t { + case release.AgentArtifactTypeValues.Build: + return expandReleaseBuildArtifact(d) + } + return nil +} + +func expandReleaseArtifact(d map[string]interface{}, t release.AgentArtifactType) release.Artifact { + definitionReference := expandReleaseArtifactDefinitionReference(d, t) + return release.Artifact{ + Alias: converter.String(d["alias"].(string)), + IsPrimary: converter.Bool(d["is_primary"].(bool)), + IsRetained: converter.Bool(d["is_retained"].(bool)), + Type: converter.String(strings.Title(string(t))), + DefinitionReference: &definitionReference, + } +} +func expandReleaseArtifactList(d []interface{}, t release.AgentArtifactType) []release.Artifact { + vs := make([]release.Artifact, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseArtifact(val, t)) + } + } + return vs +} + +func expandReleaseConfigurationVariableValue(d map[string]interface{}) (string, release.ConfigurationVariableValue) { + return d["name"].(string), release.ConfigurationVariableValue{ + AllowOverride: converter.Bool(d["allow_override"].(bool)), + Value: converter.String(d["value"].(string)), + IsSecret: converter.Bool(d["is_secret"].(bool)), + } +} +func expandReleaseConfigurationVariableValueList(d []interface{}) map[string]release.ConfigurationVariableValue { + vs := make(map[string]release.ConfigurationVariableValue) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + key, d2 := expandReleaseConfigurationVariableValue(val) + vs[key] = d2 + } + } + return vs +} + +func expandReleaseDefinitionDeployStep(d map[string]interface{}) release.ReleaseDefinitionDeployStep { + tasks := expandReleaseWorkFlowTaskList(d["task"].([]interface{})) + return release.ReleaseDefinitionDeployStep{ + Id: converter.Int(d["id"].(int)), + Tasks: &tasks, + } +} +func expandReleaseDefinitionDeployStepList(d []interface{}) []release.ReleaseDefinitionDeployStep { + vs := make([]release.ReleaseDefinitionDeployStep, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseDefinitionDeployStep(val)) + } + } + return vs +} +func expandReleaseDefinitionDeployStepListFirstOrNil(d []interface{}) *release.ReleaseDefinitionDeployStep { + d2 := expandReleaseDefinitionDeployStepList(d) + if len(d2) != 1 { + return nil + } + return &d2[0] +} + +func expandReleaseDeployPhase(d map[string]interface{}, t release.DeployPhaseTypes) ReleaseDeployPhase { + workflowTasks := expandReleaseWorkFlowTaskList(d["task"].([]interface{})) + var deploymentInput interface{} + switch t { + case release.DeployPhaseTypesValues.AgentBasedDeployment: + deploymentInput = expandReleaseAgentDeploymentInput(d) + case release.DeployPhaseTypesValues.MachineGroupBasedDeployment: + deploymentInput = expandReleaseMachineGroupDeploymentInput(d) + case release.DeployPhaseTypesValues.RunOnServer: + deploymentInput = expandReleaseServerDeploymentInput(d) + } + return ReleaseDeployPhase{ + DeploymentInput: &deploymentInput, + Rank: converter.Int(d["rank"].(int)), + PhaseType: &t, + Name: converter.String(d["name"].(string)), + //RefName: converter.String(d["ref_name"].(string)), + WorkflowTasks: &workflowTasks, + } +} +func expandReleaseDeployPhaseList(d []interface{}, t release.DeployPhaseTypes) []ReleaseDeployPhase { + vs := make([]ReleaseDeployPhase, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseDeployPhase(val, t)) + } + } + return vs +} +func expandReleaseDeployPhaseListFirstOrNil(d []interface{}, t release.DeployPhaseTypes) *ReleaseDeployPhase { + d2 := expandReleaseDeployPhaseList(d, t) + if len(d2) != 1 { + return nil + } + return &d2[0] +} + +func expandReleaseEnvironmentOptions(d map[string]interface{}) release.EnvironmentOptions { + return release.EnvironmentOptions{ + AutoLinkWorkItems: converter.Bool(d["auto_link_work_items"].(bool)), + BadgeEnabled: converter.Bool(d["badge_enabled"].(bool)), + PublishDeploymentStatus: converter.Bool(d["publish_deployment_status"].(bool)), + PullRequestDeploymentEnabled: converter.Bool(d["pull_request_deployment_enabled"].(bool)), + } +} +func expandReleaseEnvironmentOptionsList(d []interface{}) []release.EnvironmentOptions { + vs := make([]release.EnvironmentOptions, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseEnvironmentOptions(val)) + } + } + return vs +} +func expandReleaseEnvironmentOptionsListFirstOrNil(d []interface{}) *release.EnvironmentOptions { + d2 := expandReleaseEnvironmentOptionsList(d) + if len(d2) != 1 { + return nil + } + return &d2[0] +} + +func expandReleaseMachineGroupDeploymentInputMultiple(d map[string]interface{}) MachineGroupDeploymentMultiple { + return MachineGroupDeploymentMultiple{} +} +func expandReleaseMachineGroupDeploymentInputMultipleList(d []interface{}) []MachineGroupDeploymentMultiple { + vs := make([]MachineGroupDeploymentMultiple, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseMachineGroupDeploymentInputMultiple(val)) + } + } + return vs +} +func expandReleaseMachineGroupDeploymentInputMultipleListFirstOrNil(d []interface{}) *MachineGroupDeploymentMultiple { + d2 := expandReleaseMachineGroupDeploymentInputMultipleList(d) + if len(d2) != 1 { + return nil + } + return &d2[0] +} + +func expandReleaseMultiConfigInput(d map[string]interface{}) release.MultiConfigInput { + return release.MultiConfigInput{ + Multipliers: converter.String(d["multipliers"].(string)), + MaxNumberOfAgents: converter.Int(d["number_of_agents"].(int)), + ParallelExecutionType: &release.ParallelExecutionTypesValues.MultiConfiguration, + ContinueOnError: converter.Bool(d["continue_on_error"].(bool)), + } +} +func expandReleaseMultiConfigInputList(d []interface{}) []release.MultiConfigInput { + vs := make([]release.MultiConfigInput, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseMultiConfigInput(val)) + } + } + return vs +} +func expandReleaseMultiConfigInputListFirstOrNil(d []interface{}) *release.MultiConfigInput { + d2 := expandReleaseMultiConfigInputList(d) + if len(d2) != 1 { + return nil + } + return &d2[0] +} + +func expandReleaseParallelExecutionInputBase(d map[string]interface{}) release.ParallelExecutionInputBase { + return release.ParallelExecutionInputBase{ + MaxNumberOfAgents: converter.Int(d["max_number_of_agents"].(int)), + ParallelExecutionType: &release.ParallelExecutionTypesValues.MultiMachine, + ContinueOnError: converter.Bool(d["continue_on_error"].(bool)), + } +} +func expandReleaseParallelExecutionInputBaseList(d []interface{}) []release.ParallelExecutionInputBase { + vs := make([]release.ParallelExecutionInputBase, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseParallelExecutionInputBase(val)) + } + } + return vs +} +func expandReleaseParallelExecutionInputBaseListFirstOrNil(d []interface{}) *release.ParallelExecutionInputBase { + d2 := expandReleaseParallelExecutionInputBaseList(d) + if len(d2) != 1 { + return nil + } + return &d2[0] +} + +func expandReleaseAgentSpecification(d map[string]interface{}) release.AgentSpecification { + return release.AgentSpecification{ + Identifier: converter.String(d["agent_specification"].(string)), + } +} +func expandReleaseAgentSpecificationList(d []interface{}) []release.AgentSpecification { + vs := make([]release.AgentSpecification, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseAgentSpecification(val)) + } + } + return vs +} +func expandReleaseAgentSpecificationListFirstOrNil(d []interface{}) *release.AgentSpecification { + d2 := expandReleaseAgentSpecificationList(d) + if len(d2) != 1 { + return nil + } + return &d2[0] +} + +func expandReleaseHostedAzurePipelines(d map[string]interface{}) ReleaseHostedAzurePipelines { + agentSpecification := expandReleaseAgentSpecification(d) + return ReleaseHostedAzurePipelines{ + AgentSpecification: &agentSpecification, + QueueID: converter.Int(d["agent_pool_id"].(int)), + } +} +func expandReleaseHostedAzurePipelinesList(d []interface{}) []ReleaseHostedAzurePipelines { + vs := make([]ReleaseHostedAzurePipelines, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseHostedAzurePipelines(val)) + } + } + return vs +} +func expandReleaseHostedAzurePipelinesListFirstOrNil(d []interface{}) (*release.AgentSpecification, int) { + d2 := expandReleaseHostedAzurePipelinesList(d) + if len(d2) != 1 { + return nil, 0 + } + return d2[0].AgentSpecification, *d2[0].QueueID +} +func expandReleaseHostedAzurePipelinesSet(d *schema.Set) (*release.AgentSpecification, int) { + d2 := expandReleaseHostedAzurePipelinesList(d.List()) + if len(d2) != 1 { + return nil, 0 + } + return d2[0].AgentSpecification, *d2[0].QueueID +} + +func expandReleaseMachineGroupDeploymentInput(d map[string]interface{}) *release.MachineGroupDeploymentInput { + tags := tfhelper.ExpandStringList(d["tags"].([]interface{})) + // TODO : Which demand expansion is correct for this? + multiple := expandReleaseMachineGroupDeploymentInputMultipleListFirstOrNil(d["multiple"].([]interface{})) + deploymentHealthOption := DeploymentHealthOptionTypeValues.OneTargetAtATime + if multiple != nil { + deploymentHealthOption = DeploymentHealthOptionTypeValues.Custom + } + return &release.MachineGroupDeploymentInput{ + Condition: converter.String(d["condition"].(string)), + JobCancelTimeoutInMinutes: converter.Int(d["max_execution_time_in_minutes"].(int)), + OverrideInputs: nil, // TODO : OverrideInputs + TimeoutInMinutes: converter.Int(d["timeout_in_minutes"].(int)), + ArtifactsDownloadInput: &release.ArtifactsDownloadInput{ + // DownloadInputs: &downloadInputs, + }, + //Demands: &demands, + EnableAccessToken: converter.Bool(d["allow_scripts_to_access_oauth_token"].(bool)), // TODO : enable_access_token + QueueId: converter.Int(d["deployment_group_id"].(int)), + SkipArtifactsDownload: converter.Bool(d["skip_artifacts_download"].(bool)), + DeploymentHealthOption: converter.String(string(deploymentHealthOption)), + //HealthPercent: + Tags: &tags, + } +} +func expandReleaseAgentDeploymentInput(d map[string]interface{}) AgentDeploymentInput { + buildArtifactDownloads := expandReleaseArtifactDownloadInputBaseList(d["build_artifact_download"].([]interface{}), release.AgentArtifactTypeValues.Build) + downloadInputs := append(buildArtifactDownloads) + + demands := expandReleaseDeployPhaseDemandList(d["demand"].([]interface{})) + agentPoolPrivate := expandReleaseAgentSpecificationListFirstOrNil(d["agent_pool_private"].([]interface{})) + + agentPoolHostedAzurePipelines, queueID := expandReleaseHostedAzurePipelinesListFirstOrNil(d["agent_pool_hosted_azure_pipelines"].([]interface{})) + //if agentPoolPrivate != nil && agentPoolHostedAzurePipelines != nil { // TODO : how to solve + // return nil, fmt.Errorf("conflit %s and %s specify only one", "agent_pool_hosted_azure_pipelines", "agent_pool_private") + //} + var agentSpecification *release.AgentSpecification + if agentPoolHostedAzurePipelines != nil { + agentSpecification = agentPoolHostedAzurePipelines + } else { + agentSpecification = agentPoolPrivate + } + + var parallelExecution interface{} = &release.ExecutionInput{ + ParallelExecutionType: &release.ParallelExecutionTypesValues.None, + } + multiConfiguration := expandReleaseMultiConfigInputListFirstOrNil(d["multi_configuration"].([]interface{})) + multiAgent := expandReleaseParallelExecutionInputBaseListFirstOrNil(d["multi_agent"].([]interface{})) + //if multiConfiguration != nil && multiAgent != nil { // TODO : how to solve + // return nil, fmt.Errorf("conflit %s and %s specify only one", "multi_configuration", "multi_agent") + //} + if multiConfiguration != nil { + parallelExecution = multiConfiguration + } else if multiAgent != nil { + parallelExecution = multiAgent + } + + return AgentDeploymentInput{ + Condition: converter.String(d["condition"].(string)), + JobCancelTimeoutInMinutes: converter.Int(d["max_execution_time_in_minutes"].(int)), + OverrideInputs: nil, // TODO : OverrideInputs + TimeoutInMinutes: converter.Int(d["timeout_in_minutes"].(int)), + Demands: &demands, + EnableAccessToken: converter.Bool(d["allow_scripts_to_access_oauth_token"].(bool)), // TODO : enable_access_token + QueueID: &queueID, + SkipArtifactsDownload: converter.Bool(d["skip_artifacts_download"].(bool)), + AgentSpecification: agentSpecification, + // ImageID: , + ParallelExecution: ¶llelExecution, + ArtifactsDownloadInput: &release.ArtifactsDownloadInput{ + DownloadInputs: &downloadInputs, + }, + } +} +func expandReleaseServerDeploymentInput(d map[string]interface{}) *ServerDeploymentInput { + var parallelExecution interface{} = &release.ExecutionInput{ + ParallelExecutionType: &release.ParallelExecutionTypesValues.None, + } + multiConfiguration := expandReleaseMultiConfigInputListFirstOrNil(d["multi_configuration"].([]interface{})) + if multiConfiguration != nil { + parallelExecution = multiConfiguration + } + return &ServerDeploymentInput{ + Condition: converter.String(d["condition"].(string)), + JobCancelTimeoutInMinutes: converter.Int(d["max_execution_time_in_minutes"].(int)), + OverrideInputs: nil, // TODO : OverrideInputs + TimeoutInMinutes: converter.Int(d["timeout_in_minutes"].(int)), + ParallelExecution: ¶llelExecution, + } +} + +func expandReleaseArtifactDownloadInputBase(d map[string]interface{}, t release.AgentArtifactType) release.ArtifactDownloadInputBase { + mode := ArtifactDownloadModeTypeValues.All + artifactItems := make([]string, 0, 0) + artifactItems = tfhelper.ExpandStringList(d["include"].([]interface{})) + if len(artifactItems) > 0 { + if artifactItems[0] == "*" { + artifactItems = []string{} + mode = ArtifactDownloadModeTypeValues.All + } else { + mode = ArtifactDownloadModeTypeValues.Selective + } + } else { + mode = ArtifactDownloadModeTypeValues.Skip + } + return release.ArtifactDownloadInputBase{ + Alias: converter.String(d["artifact_alias"].(string)), + ArtifactDownloadMode: converter.String(string(mode)), + ArtifactItems: &artifactItems, + ArtifactType: converter.String(strings.Title(string(t))), + } +} +func expandReleaseArtifactDownloadInputBaseList(d []interface{}, t release.AgentArtifactType) []release.ArtifactDownloadInputBase { + vs := make([]release.ArtifactDownloadInputBase, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseArtifactDownloadInputBase(val, t)) + } + } + return vs +} + +func expandReleaseDeployPhaseDemand(d map[string]interface{}) string { + name := d["name"].(string) + configValue := d["value"].(string) + if len(configValue) > 0 { + name += " -equals " + configValue + } + return name +} +func expandReleaseDeployPhaseDemandList(d []interface{}) []interface{} { + vs := make([]interface{}, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseDeployPhaseDemand(val)) + } + } + return vs +} + +func expandReleaseDefinitionDemand(d map[string]interface{}) ReleaseDefinitionDemand { + name := d["name"].(string) + configValue := d["value"].(string) + if len(configValue) > 0 { + name += " -equals " + configValue + } + return ReleaseDefinitionDemand{ + Name: converter.String(name), + } +} +func expandReleaseDefinitionDemandList(d []interface{}) []interface{} { + vs := make([]interface{}, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseDefinitionDemand(val)) + } + } + return vs +} + +func expandReleaseWorkFlowTask(d map[string]interface{}) release.WorkflowTask { + task := strings.Split(d["task"].(string), "@") + taskName, version := task[0], task[1] + taskID := distributedtask.TaskNameToUUID[taskName] + + inputs := expandStringMapString(d["inputs"].(map[string]interface{})) + environment := expandStringMapString(d["environment"].(map[string]interface{})) + overrideInputs := expandStringMapString(d["override_inputs"].(map[string]interface{})) + + return release.WorkflowTask{ + TaskId: &taskID, + Name: converter.String(d["display_name"].(string)), + AlwaysRun: converter.Bool(d["always_run"].(bool)), + Condition: converter.String(d["condition"].(string)), + ContinueOnError: converter.Bool(d["continue_on_error"].(bool)), + DefinitionType: converter.String("task"), + Enabled: converter.Bool(d["enabled"].(bool)), + TimeoutInMinutes: converter.Int(d["timeout_in_minutes"].(int)), + Environment: &environment, + Inputs: &inputs, + OverrideInputs: &overrideInputs, + Version: &version, + } +} +func expandReleaseWorkFlowTaskList(d []interface{}) []release.WorkflowTask { + vs := make([]release.WorkflowTask, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseWorkFlowTask(val)) + } + } + return vs +} + +func expandReleaseEnvironmentRetentionPolicy(d map[string]interface{}) release.EnvironmentRetentionPolicy { + return release.EnvironmentRetentionPolicy{ + DaysToKeep: converter.Int(d["days_to_keep"].(int)), + RetainBuild: converter.Bool(d["retain_build"].(bool)), + ReleasesToKeep: converter.Int(d["releases_to_keep"].(int)), + } +} +func expandReleaseEnvironmentRetentionPolicyList(d []interface{}) []release.EnvironmentRetentionPolicy { + vs := make([]release.EnvironmentRetentionPolicy, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseEnvironmentRetentionPolicy(val)) + } + } + return vs +} +func expandReleaseEnvironmentRetentionPolicyListFirstOrNil(d []interface{}) *release.EnvironmentRetentionPolicy { + d2 := expandReleaseEnvironmentRetentionPolicyList(d) + if len(d2) != 1 { + return nil + } + return &d2[0] +} + +func automaticReleaseDefinitionApprovalStep() release.ReleaseDefinitionApprovalStep { + return release.ReleaseDefinitionApprovalStep{ + IsAutomated: converter.Bool(true), + IsNotificationOn: converter.Bool(false), + Rank: converter.Int(1), + } +} + +func automaticReleaseDefinitionApprovals() release.ReleaseDefinitionApprovals { + return release.ReleaseDefinitionApprovals{ + Approvals: &[]release.ReleaseDefinitionApprovalStep{automaticReleaseDefinitionApprovalStep()}, + } +} + +func expandReleaseDefinitionApprovalStep(d map[string]interface{}, rank int) release.ReleaseDefinitionApprovalStep { + vs := release.ReleaseDefinitionApprovalStep{ + Id: converter.Int(d["id"].(int)), + IsAutomated: converter.Bool(true), + IsNotificationOn: converter.Bool(false), + Rank: converter.Int(rank), + } + + if d["approver_id"] != "" { + vs.IsAutomated = converter.Bool(false) + vs.Approver = &webapi.IdentityRef{Id: converter.String(d["approver_id"].(string))} + } + return vs +} +func expandReleaseDefinitionApprovalStepList(d []interface{}) []release.ReleaseDefinitionApprovalStep { + vs := make([]release.ReleaseDefinitionApprovalStep, 0, len(d)) + for i, v := range d { + if val, ok := v.(map[string]interface{}); ok { + if val["id"] != nil { + vs = append(vs, expandReleaseDefinitionApprovalStep(val, i+1)) + } + } + } + if len(vs) == 0 { + vs = append(vs, automaticReleaseDefinitionApprovalStep()) + } + return vs +} + +func expandReleaseApprovalOptions(d map[string]interface{}) release.ApprovalOptions { + executionOrder := release.ApprovalExecutionOrder(d["execution_order"].(string)) + return release.ApprovalOptions{ + AutoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped: converter.Bool(d["auto_triggered_and_previous_environment_approved_can_be_skipped"].(bool)), + EnforceIdentityRevalidation: converter.Bool(d["enforce_identity_revalidation"].(bool)), + ExecutionOrder: &executionOrder, + ReleaseCreatorCanBeApprover: converter.Bool(d["release_creator_can_be_approver"].(bool)), + RequiredApproverCount: converter.Int(d["required_approver_count"].(int)), + TimeoutInMinutes: converter.Int(d["timeout_in_minutes"].(int)), + } +} +func expandReleaseApprovalOptionsList(d []interface{}) []release.ApprovalOptions { + vs := make([]release.ApprovalOptions, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseApprovalOptions(val)) + } + } + return vs +} +func expandReleaseApprovalOptionsListFirstOrNil(d []interface{}) *release.ApprovalOptions { + d2 := expandReleaseApprovalOptionsList(d) + if len(d2) != 1 { + return nil + } + return &d2[0] +} + +func expandReleaseDefinitionApprovals(d map[string]interface{}) release.ReleaseDefinitionApprovals { + approvals := expandReleaseDefinitionApprovalStepList(d["approval"].([]interface{})) + // TODO : expand approval Options first and then pass them into this method. + //approvalOptions := expandReleaseApprovalOptionsListFirstOrNil(d["approval_options"].([]interface{})) + return release.ReleaseDefinitionApprovals{ + Approvals: &approvals, + // ApprovalOptions: approvalOptions, + } +} +func expandReleaseDefinitionApprovalsList(d []interface{}) []release.ReleaseDefinitionApprovals { + vs := make([]release.ReleaseDefinitionApprovals, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseDefinitionApprovals(val)) + } + } + if len(vs) == 0 { + vs = append(vs, automaticReleaseDefinitionApprovals()) + } + return vs +} +func expandReleaseDefinitionApprovalsListFirstOrNil(d []interface{}) *release.ReleaseDefinitionApprovals { + d2 := expandReleaseDefinitionApprovalsList(d) + if len(d2) != 1 { + return nil + } + return &d2[0] +} + +func expandReleaseDefinitionGate(d map[string]interface{}) release.ReleaseDefinitionGate { + workflowTasks := expandReleaseWorkFlowTaskList(d["task"].([]interface{})) + return release.ReleaseDefinitionGate{ + Tasks: &workflowTasks, + } +} +func expandReleaseDefinitionGateList(d []interface{}) []release.ReleaseDefinitionGate { + vs := make([]release.ReleaseDefinitionGate, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseDefinitionGate(val)) + } + } + return vs +} + +func expandReleaseDefinitionGatesStep(d map[string]interface{}) release.ReleaseDefinitionGatesStep { + gates := expandReleaseDefinitionGateList(d["gate"].([]interface{})) + return release.ReleaseDefinitionGatesStep{ + Id: converter.Int(d["id"].(int)), + Gates: &gates, + // GatesOptions: expandReleaseDefinitionGatesOptionsList(d["gates_options"].([]interface{})), + } +} +func expandReleaseDefinitionGatesStepList(d []interface{}) []release.ReleaseDefinitionGatesStep { + vs := make([]release.ReleaseDefinitionGatesStep, 0, len(d)) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, expandReleaseDefinitionGatesStep(val)) + } + } + return vs +} +func expandReleaseDefinitionGatesStepListFirstOrNil(d []interface{}) *release.ReleaseDefinitionGatesStep { + d2 := expandReleaseDefinitionGatesStepList(d) + if len(d2) != 1 { + return nil + } + return &d2[0] +} + +func flattenStringList(list []*string) []interface{} { + vs := make([]interface{}, 0, len(list)) + for _, v := range list { + vs = append(vs, *v) + } + return vs +} +func flattenStringSet(list []*string) *schema.Set { + return schema.NewSet(schema.HashString, flattenStringList(list)) +} + +func flattenIntList(list []*int) []interface{} { + vs := make([]interface{}, 0, len(list)) + for _, v := range list { + vs = append(vs, *v) + } + return vs +} +func flattenIntSet(list []*int) *schema.Set { + return schema.NewSet(schema.HashString, flattenIntList(list)) +} + +func flattenStringMap(m *map[string]string) map[string]interface{} { + if m == nil { + return nil + } + vs := map[string]interface{}{} + for k, v := range *m { + if v != "" { + vs[k] = v + } + } + return vs +} + +func flattenReleaseDefinitionVariables(m *map[string]release.ConfigurationVariableValue) interface{} { + if m == nil { + return nil + } + d := make([]map[string]interface{}, len(*m)) + index := 0 + for k, v := range *m { + d[index] = map[string]interface{}{ + "name": k, + "value": converter.ToString(v.Value, ""), + "is_secret": converter.ToBool(v.IsSecret, false), + } + index = index + 1 + } + return d +} + +func flattenReleaseDefinitionEnvironmentOptions(m *release.EnvironmentOptions) interface{} { + if m == nil { + return nil + } + return []map[string]interface{}{{ + "auto_link_work_items": m.AutoLinkWorkItems, + "badge_enabled": m.BadgeEnabled, + "publish_deployment_status": m.PublishDeploymentStatus, + "pull_request_deployment_enabled": m.PullRequestDeploymentEnabled, + }} +} + +func flattenReleasePropertiesMap(d interface{}) interface{} { + if d2, ok := d.(map[string]interface{}); ok { + if t, ok := d2["$type"].(string); ok { + switch t { + case "System.String": + if v, ok := d2["$value"].(string); ok { + if b, err := strconv.ParseBool(v); err == nil { + return b + } + return v + } + case "System.Boolean": + fallthrough + case "System.Bool": + return d2["$value"].(bool) + } + } + } + return nil +} + +func flattenReleaseEnvironmentProperties(m interface{}) interface{} { + if properties, ok := m.(map[string]interface{}); ok { + d := map[string]interface{}{ + "boards_environment_type": flattenReleasePropertiesMap(properties["BoardsEnvironmentType"]), + "link_boards_work_items": flattenReleasePropertiesMap(properties["LinkBoardsWorkItems"]), + "jira_environment_type": flattenReleasePropertiesMap(properties["JiraEnvironmentType"]), + "link_jira_work_items": flattenReleasePropertiesMap(properties["LinkJiraWorkItems"]), + } + return []map[string]interface{}{d} + } + return nil +} + +func flattenReleaseDefinitionProperties(m interface{}) interface{} { + if properties, ok := m.(map[string]interface{}); ok { + d := map[string]interface{}{ + "definition_creation_source": flattenReleasePropertiesMap(properties["DefinitionCreationSource"]), + "integrate_jira_work_items": flattenReleasePropertiesMap(properties["IntegrateBoardsWorkItems"]), + "integrate_boards_work_items": flattenReleasePropertiesMap(properties["IntegrateJiraWorkItems"]), + "jira_service_endpoint_id": flattenReleasePropertiesMap(properties["JiraServiceEndpointId"]), + } + return []map[string]interface{}{d} + } + return nil +} + +func flattenReleaseWorkflowTask(m release.WorkflowTask) map[string]interface{} { + task := distributedtask.TaskUUIDToName[*m.TaskId] + "@" + *m.Version + return map[string]interface{}{ + "task": task, + "display_name": m.Name, + "inputs": flattenStringMap(m.Inputs), + "condition": m.Condition, + "continue_on_error": m.ContinueOnError, + "always_run": m.AlwaysRun, + "enabled": m.Enabled, + "environment": flattenStringMap(m.Environment), + "override_inputs": flattenStringMap(m.OverrideInputs), + "timeout_in_minutes": m.TimeoutInMinutes, + } +} +func flattenReleaseWorkflowTaskList(m *[]release.WorkflowTask) []map[string]interface{} { + ds := make([]map[string]interface{}, 0, len(*m)) + for _, d := range *m { + ds = append(ds, flattenReleaseWorkflowTask(d)) + } + return ds +} + +func flattenReleaseDeployPhaseDemand(m interface{}) map[string]interface{} { + if ms, ok := m.(string); ok { + m2 := strings.Split(ms, "-equals") + var value string + if len(m2) == 2 { + value = strings.TrimSpace(m2[1]) + } + return map[string]interface{}{ + "name": strings.TrimSpace(m2[0]), + "value": value, + } + } + return nil +} +func flattenReleaseDeployPhaseDemandList(m *[]interface{}) []map[string]interface{} { + ds := make([]map[string]interface{}, 0, len(*m)) + for _, d := range *m { + ds = append(ds, flattenReleaseDeployPhaseDemand(d)) + } + return ds +} + +func flattenReleaseArtifactDownloadBase(m release.ArtifactDownloadInputBase) map[string]interface{} { + include := *m.ArtifactItems + if strings.EqualFold(*m.ArtifactDownloadMode, string(ArtifactDownloadModeTypeValues.All)) { + include = []string{"*"} + } + return map[string]interface{}{ + "artifact_alias": m.Alias, + "include": include, + } +} +func flattenReleaseArtifactDownloadBaseList(m *[]release.ArtifactDownloadInputBase, t release.AgentArtifactType) []map[string]interface{} { + ds := make([]map[string]interface{}, 0, 0) + for _, d := range *m { + if strings.EqualFold(*d.ArtifactType, string(t)) { + ds = append(ds, flattenReleaseArtifactDownloadBase(d)) + } + } + return ds +} + +func flattenReleaseDefinitionDeployStep(m *release.ReleaseDefinitionDeployStep) []map[string]interface{} { + if m == nil { + return nil + } + ms := map[string]interface{}{"id": m.Id} + if m.Tasks != nil { + ms["task"] = flattenReleaseWorkflowTaskList(m.Tasks) + } + return []map[string]interface{}{ms} +} + +func flattenReleaseDefinitionHostedAgentSpecification(m *release.AgentSpecification, rai *release.AgentDeploymentInput) []map[string]interface{} { + if m == nil { + return nil + } + return []map[string]interface{}{{ + "agent_pool_id": rai.QueueId, + "agent_specification": m.Identifier, + }} +} + +func flattenReleaseAgentDeploymentInput(rdp *release.ReleaseDeployPhase, rai *release.AgentDeploymentInput, rwt *[]release.WorkflowTask) map[string]interface{} { + d := map[string]interface{}{ + "rank": rdp.Rank, + "name": rdp.Name, + "task": flattenReleaseWorkflowTaskList(rwt), + "agent_pool_hosted_azure_pipelines": flattenReleaseDefinitionHostedAgentSpecification(rai.AgentSpecification, rai), + "build_artifact_download": flattenReleaseArtifactDownloadBaseList(rai.ArtifactsDownloadInput.DownloadInputs, release.AgentArtifactTypeValues.Build), + "timeout_in_minutes": rai.TimeoutInMinutes, + "max_execution_time_in_minutes": rai.JobCancelTimeoutInMinutes, + "condition": rai.Condition, + "skip_artifacts_download": rai.SkipArtifactsDownload, + "allow_scripts_to_access_oauth_token": rai.EnableAccessToken, + "demand": flattenReleaseDeployPhaseDemandList(rai.Demands), + //"override_inputs": overrideInputs, // rai.OverrideInputs + //"agent_pool_private": "array", // ??? + //"multi_configuration": "array", // ??? + //"multi_agent": "array", // ??? + } + return d +} + +func flattenReleaseServerInput(rdp *release.ReleaseDeployPhase, rai *release.ServerDeploymentInput, rwt *[]release.WorkflowTask) map[string]interface{} { + d := map[string]interface{}{ + "rank": rdp.Rank, + "name": rdp.Name, + "task": flattenReleaseWorkflowTaskList(rwt), + "timeout_in_minutes": rai.TimeoutInMinutes, + "max_execution_time_in_minutes": rai.JobCancelTimeoutInMinutes, + "condition": rai.Condition, + //"override_inputs": overrideInputs, // rai.OverrideInputs + //"multi_configuration": "array", // ??? + } + return d +} + +func flattenReleaseGatesDeploymentInput(m *release.GatesDeploymentInput) interface{} { + // TODO : + return map[string]interface{}{} +} + +func flattenReleaseMachineGroupDeploymentInput(m *release.MachineGroupDeploymentInput) interface{} { + // TODO : + return map[string]interface{}{} +} + +func flattenReleaseServerDeploymentInput(m *release.ServerDeploymentInput) interface{} { + // TODO : + return map[string]interface{}{} +} + +func unmarshalAgentDeploymentInput(deployPhase []byte, agentDeploymentInput []byte, workflowTasks []byte) (*release.ReleaseDeployPhase, *release.AgentDeploymentInput, *[]release.WorkflowTask) { + var d release.ReleaseDeployPhase + _ = json.Unmarshal(deployPhase, &d) + + var d2 release.AgentDeploymentInput + _ = json.Unmarshal(agentDeploymentInput, &d2) + + var d3 []release.WorkflowTask + _ = json.Unmarshal(workflowTasks, &d3) + return &d, &d2, &d3 +} + +func unmarshalServerDeploymentInput(deployPhase []byte, agentDeploymentInput []byte, workflowTasks []byte) (*release.ReleaseDeployPhase, *release.ServerDeploymentInput, *[]release.WorkflowTask) { + var d release.ReleaseDeployPhase + _ = json.Unmarshal(deployPhase, &d) + + var d2 release.ServerDeploymentInput + _ = json.Unmarshal(agentDeploymentInput, &d2) + + var d3 []release.WorkflowTask + _ = json.Unmarshal(workflowTasks, &d3) + return &d, &d2, &d3 +} + +func flattenReleaseDeploymentInput(m map[string]interface{}) map[string]interface{} { + deployPhase, err := json.MarshalIndent(m, "", " ") + agentDeploymentInput, err2 := json.MarshalIndent(m["deploymentInput"], "", " ") + workflowTasks, _ := json.MarshalIndent(m["workflowTasks"], "", " ") + if err != nil || err2 != nil { + return nil + } + + switch release.DeployPhaseTypes(m["phaseType"].(string)) { + case release.DeployPhaseTypesValues.AgentBasedDeployment: + return map[string]interface{}{ + "agent": []map[string]interface{}{ + flattenReleaseAgentDeploymentInput(unmarshalAgentDeploymentInput(deployPhase, agentDeploymentInput, workflowTasks)), + }, + } + case release.DeployPhaseTypesValues.RunOnServer: + return map[string]interface{}{ + "agentless": []map[string]interface{}{ + flattenReleaseServerInput(unmarshalServerDeploymentInput(deployPhase, agentDeploymentInput, workflowTasks)), + }, + } + } + return nil +} + +func flattenReleaseDeployPhasesList(m *[]interface{}) []map[string]interface{} { + ds := make([]map[string]interface{}, 0, 0) + if m != nil { + for _, d := range *m { + ds = append(ds, flattenReleaseDeploymentInput(d.(map[string]interface{}))) + } + } + return ds +} + +func flattenReleaseDefinitionApprovalStep(m release.ReleaseDefinitionApprovalStep) map[string]interface{} { + ds := map[string]interface{}{ + "id": m.Id, + "rank": m.Rank, + } + if m.Approver != nil { + ds["approver_id"] = m.Approver.Id + } + return ds +} +func flattenReleaseDefinitionApprovalStepList(m *[]release.ReleaseDefinitionApprovalStep) []map[string]interface{} { + ds := make([]map[string]interface{}, 0, 0) + for _, d := range *m { + ds = append(ds, flattenReleaseDefinitionApprovalStep(d)) + } + return ds +} + +func flattenReleaseDefinitionApprovals(m *release.ReleaseDefinitionApprovals) []map[string]interface{} { + return []map[string]interface{}{{ + "approval": flattenReleaseDefinitionApprovalStepList(m.Approvals), + }} +} + +func flattenReleaseEnvironmentRetentionPolicy(m *release.EnvironmentRetentionPolicy) []map[string]interface{} { + return []map[string]interface{}{{ + "retain_build": m.RetainBuild, + "releases_to_keep": m.ReleasesToKeep, + "days_to_keep": m.DaysToKeep, + }} +} + +func flattenReleaseDefinitionGate(m release.ReleaseDefinitionGate) map[string]interface{} { + return map[string]interface{}{ + "task": flattenReleaseWorkflowTaskList(m.Tasks), + } +} +func flattenReleaseDefinitionGateList(m *[]release.ReleaseDefinitionGate) []map[string]interface{} { + ds := make([]map[string]interface{}, 0, 0) + for _, d := range *m { + ds = append(ds, flattenReleaseDefinitionGate(d)) + } + return ds +} + +func flattenReleaseReleaseDefinitionGatesOptions(m *release.ReleaseDefinitionGatesOptions) []map[string]interface{} { + if m == nil { + return nil + } + return []map[string]interface{}{{ + "is_enabled": m.IsEnabled, + "minimum_success_duration": m.MinimumSuccessDuration, + "sampling_interval": m.SamplingInterval, + "stabilization_time": m.StabilizationTime, + "timeout": m.Timeout, + }} +} +func flattenReleaseDefinitionGatesStep(m *release.ReleaseDefinitionGatesStep) []map[string]interface{} { + return []map[string]interface{}{{ + "id": m.Id, + "gate": flattenReleaseDefinitionGateList(m.Gates), + "gates_options": flattenReleaseReleaseDefinitionGatesOptions(m.GatesOptions), + }} +} + +func flattenCondition(m release.Condition, t release.ConditionType) map[string]interface{} { + switch t { + case release.ConditionTypeValues.EnvironmentState: + return map[string]interface{}{ + "stage_name": m.Name, + "trigger_even_when_stages_partially_succeed": *m.Value != "4", + } + case release.ConditionTypeValues.Event: + return map[string]interface{}{ + "event_name": m.Name, + } + } + return nil +} +func flattenConditionList(m *[]release.Condition, t release.ConditionType) []map[string]interface{} { + ds := make([]map[string]interface{}, 0, 0) + for _, d := range *m { + if *d.ConditionType == t { + ds = append(ds, flattenCondition(d, t)) + } + } + return ds +} + +func flattenArtifactFilterInclude(m map[string]interface{}, isInclude bool) map[string]interface{} { + ds := map[string]interface{}{"branch_name": m["sourceBranch"]} + if isInclude { + ds["tags"] = m["tags"] + } + return ds +} + +func flattenArtifactFilterIncludeExcludeList(m []release.Condition, isInclude bool) []map[string]interface{} { + ds := make([]map[string]interface{}, 0, 0) + for _, d := range m { + var m2 map[string]interface{} + if err := json.Unmarshal([]byte(*d.Value), &m2); err == nil { + if branch, ok := m2["sourceBranch"].(string); ok { + if isInclude == !strings.HasPrefix(branch, "-") { + ds = append(ds, flattenArtifactFilterInclude(m2, isInclude)) + } + } + } + } + return ds +} + +func filterReleaseCondition(m *[]release.Condition, t release.ConditionType) []release.Condition { + ds := make([]release.Condition, 0, 0) + for _, d := range *m { + if *d.ConditionType == t { + ds = append(ds, d) + } + } + return ds +} + +func flattenArtifactFilter(m []release.Condition, alias string) map[string]interface{} { + return map[string]interface{}{ + "artifact_alias": alias, + "include": flattenArtifactFilterIncludeExcludeList(m, true), + "exclude": flattenArtifactFilterIncludeExcludeList(m, false), + } +} +func flattenArtifactFilterGroup(m map[string][]release.Condition) []map[string]interface{} { + ds := make([]map[string]interface{}, 0, len(m)) + for k, d := range m { + ds = append(ds, flattenArtifactFilter(d, k)) + } + return ds +} +func flattenArtifactFilterList(m *[]release.Condition) []map[string]interface{} { + artifacts := filterReleaseCondition(m, release.ConditionTypeValues.Artifact) + groups := map[string][]release.Condition{} + for _, v := range artifacts { + groups[*v.Name] = append(groups[*v.Name], v) + } + return flattenArtifactFilterGroup(groups) +} + +func flattenReleaseDefinitionEnvironment(m release.ReleaseDefinitionEnvironment) interface{} { + var ownerID *string + if m.Owner != nil { + ownerID = m.Owner.Id + } + return map[string]interface{}{ + "id": m.Id, + "rank": m.Rank, + "name": m.Name, + "owner_id": ownerID, + "variable": flattenReleaseDefinitionVariables(m.Variables), + "variable_groups": m.VariableGroups, + "pre_deploy_approval": flattenReleaseDefinitionApprovals(m.PreDeployApprovals), + "deploy_step": flattenReleaseDefinitionDeployStep(m.DeployStep), + "post_deploy_approval": flattenReleaseDefinitionApprovals(m.PostDeployApprovals), + "retention_policy": flattenReleaseEnvironmentRetentionPolicy(m.RetentionPolicy), + "pre_deploy_gate": flattenReleaseDefinitionGatesStep(m.PreDeploymentGates), + "post_deploy_gate": flattenReleaseDefinitionGatesStep(m.PostDeploymentGates), + "after_stage": flattenConditionList(m.Conditions, release.ConditionTypeValues.EnvironmentState), + "after_release": flattenConditionList(m.Conditions, release.ConditionTypeValues.Event), + "artifact_filter": flattenArtifactFilterList(m.Conditions), + "job": flattenReleaseDeployPhasesList(m.DeployPhases), + "properties": flattenReleaseEnvironmentProperties(m.Properties), + "environment_options": flattenReleaseDefinitionEnvironmentOptions(m.EnvironmentOptions), + } +} +func flattenReleaseDefinitionEnvironmentList(m *[]release.ReleaseDefinitionEnvironment) []interface{} { + m2 := *m + sort.Slice(m2, func(i, j int) bool { + return *m2[i].Rank < *m2[j].Rank + }) + ds := make([]interface{}, 0, len(*m)) + for _, d := range m2 { + Log(d.Rank) + ds = append(ds, flattenReleaseDefinitionEnvironment(d)) + } + return ds +} + +func flattenReleaseDefinitionTriggers(m interface{}) interface{} { + return map[string]interface{}{} +} +func flattenReleaseDefinitionTriggersList(m *[]interface{}) []interface{} { + ds := make([]interface{}, 0, len(*m)) + for _, d := range *m { + ds = append(ds, flattenReleaseDefinitionTriggers(d)) + } + return ds +} + +func flattenReleaseDefinitionBuildArtifacts(m release.Artifact) map[string]interface{} { + dr := *m.DefinitionReference + ds := map[string]interface{}{ + "project_id": dr["project"].Id, + "build_pipeline_id": dr["definition"].Id, + "alias": m.Alias, + "is_primary": m.IsPrimary, + "is_retained": m.IsRetained, + } + switch *dr["defaultVersionType"].Id { + case string(DefaultVersionTypeValues.Latest): + fallthrough + case string(DefaultVersionTypeValues.LatestWithBranchAndTags): + fallthrough + case string(DefaultVersionTypeValues.LatestWithBuildDefinitionBranchAndTags): + ds["latest"] = []map[string]interface{}{{ + "branch": dr["defaultVersionBranch"].Id, + "tags": dr["defaultVersionTags"].Id, + }} + break + case string(DefaultVersionTypeValues.SelectDuringReleaseCreation): + fallthrough + case string(DefaultVersionTypeValues.SpecificVersion): + ds["specify"] = []map[string]interface{}{{ + "version": dr["defaultVersionSpecific"].Id, + }} + break + } + return ds +} +func flattenReleaseDefinitionBuildArtifactsList(m *[]release.Artifact) []map[string]interface{} { + ds := make([]map[string]interface{}, 0, len(*m)) + for _, d := range *m { + ds = append(ds, flattenReleaseDefinitionBuildArtifacts(d)) + } + return ds +} + +func flattenReleaseDefinitionArtifactsList(m *[]release.Artifact, t release.AgentArtifactType) []map[string]interface{} { + switch t { + case release.AgentArtifactTypeValues.Build: + return flattenReleaseDefinitionBuildArtifactsList(m) + } + return nil +} diff --git a/azuredevops/internal/service/release/resource_release_definition_test.go b/azuredevops/internal/service/release/resource_release_definition_test.go new file mode 100644 index 000000000..4cf3a2f1a --- /dev/null +++ b/azuredevops/internal/service/release/resource_release_definition_test.go @@ -0,0 +1,392 @@ +package release + +import ( + "encoding/json" + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" + "github.com/stretchr/testify/require" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/utils/converter" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" + "sort" + "strings" + "testing" + "time" + + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops/release" +) + +var testReleaseProjectID = uuid.New().String() + +// format and parse to remove monotonic clock +var now, _ = time.Parse(time.RFC3339, time.Now().Format(time.RFC3339)) + +var properties interface{} + +var testReleaseDefinition = release.ReleaseDefinition{ + Id: converter.Int(100), + Revision: converter.Int(1), + Name: converter.String("Name"), + Path: converter.String("\\"), + VariableGroups: &[]int{}, + Source: &release.ReleaseDefinitionSourceValues.RestApi, + Description: converter.String("Description"), + Variables: &map[string]release.ConfigurationVariableValue{ + "releaseLevel": { + Value: converter.String("$(System.DefaultWorkingDirectory)/Directory"), + IsSecret: converter.Bool(false), + AllowOverride: converter.Bool(false), + }, + }, + Environments: &[]release.ReleaseDefinitionEnvironment{ + { + Id: converter.Int(50), + Name: converter.String("Stage 1"), + Rank: converter.Int(1), + + Variables: &map[string]release.ConfigurationVariableValue{ + "stageLevel": { + Value: converter.String("$(System.DefaultWorkingDirectory)/Directory"), + IsSecret: converter.Bool(false), + AllowOverride: converter.Bool(false), + }, + }, + VariableGroups: &[]int{}, + + PreDeployApprovals: &release.ReleaseDefinitionApprovals{ + Approvals: &[]release.ReleaseDefinitionApprovalStep{{ + Id: converter.Int(101), + Rank: converter.Int(1), + IsAutomated: converter.Bool(true), + IsNotificationOn: converter.Bool(false), + }}, + }, + PostDeployApprovals: &release.ReleaseDefinitionApprovals{ + Approvals: &[]release.ReleaseDefinitionApprovalStep{{ + Id: converter.Int(202), + Rank: converter.Int(1), + IsAutomated: converter.Bool(true), + IsNotificationOn: converter.Bool(false), + }}, + }, + DeployStep: &release.ReleaseDefinitionDeployStep{ + Id: converter.Int(303), + Tasks: &[]release.WorkflowTask{}, + }, + + Demands: &[]interface{}{}, + // CurrentRelease: &release.ReleaseShallowReference{}, + Conditions: &[]release.Condition{ + { + Name: converter.String("ReleaseStarted"), + ConditionType: &release.ConditionTypeValues.Event, + Value: converter.String(""), + }, + { + Name: converter.String("Build Artifact"), + ConditionType: &release.ConditionTypeValues.Artifact, + Value: converter.String("{\"sourceBranch\":\"master\",\"tags\":[\"major\",\"minor\",\"patch\"],\"useBuildDefinitionBranch\":false,\"createReleaseOnBuildTagging\":false}"), + }, + { + Name: converter.String("Build Artifact"), + ConditionType: &release.ConditionTypeValues.Artifact, + Value: converter.String("{\"sourceBranch\":\"develop\",\"tags\":[],\"useBuildDefinitionBranch\":false,\"createReleaseOnBuildTagging\":false}"), + }, + { + Name: converter.String("Build Artifact"), + ConditionType: &release.ConditionTypeValues.Artifact, + Value: converter.String("{\"sourceBranch\":\"-poc*\",\"tags\":[],\"useBuildDefinitionBranch\":false,\"createReleaseOnBuildTagging\":false}"), + }, + { + Name: converter.String("Another Artifact"), + ConditionType: &release.ConditionTypeValues.Artifact, + Value: converter.String("{\"sourceBranch\":\"master\",\"tags\":[\"tag\"],\"useBuildDefinitionBranch\":false,\"createReleaseOnBuildTagging\":false}"), + }, + }, + + Properties: map[string]interface{}{ + "BoardsEnvironmentType": map[string]interface{}{ + "$type": "System.String", + "$value": string(DeploymentTypeValues.Development), + }, + "LinkBoardsWorkItems": map[string]interface{}{ + "$type": "System.String", + "$value": "true", + }, + "JiraEnvironmentType": map[string]interface{}{ + "$type": "System.String", + "$value": string(DeploymentTypeValues.Unmapped), + }, + "LinkJiraWorkItems": map[string]interface{}{ + "$type": "System.String", + "$value": "true", + }, + }, + + //Schedules: &[]release.ReleaseSchedule{}, + + RetentionPolicy: &release.EnvironmentRetentionPolicy{ + DaysToKeep: converter.Int(1), + ReleasesToKeep: converter.Int(2), + RetainBuild: converter.Bool(false), + }, + + PreDeploymentGates: &release.ReleaseDefinitionGatesStep{ + Id: converter.Int(1), + GatesOptions: nil, + Gates: &[]release.ReleaseDefinitionGate{}, + }, + + PostDeploymentGates: &release.ReleaseDefinitionGatesStep{ + Id: converter.Int(1), + GatesOptions: nil, + Gates: &[]release.ReleaseDefinitionGate{}, + }, + Owner: &webapi.IdentityRef{ + Id: converter.String(testReleaseProjectID), + }, + + DeployPhases: &[]interface{}{ + map[string]interface{}{ + "deploymentInput": map[string]interface{}{ + "parallelExecution": map[string]interface{}{ + "parallelExecutionType": "none", + }, + "agentSpecification": map[string]interface{}{ + "identifier": "ubuntu-18.04", + }, + "skipArtifactsDownload": false, + "artifactsDownloadInput": map[string]interface{}{ + "downloadInputs": []interface{}{ + map[string]interface{}{ + "alias": "Build Artifact", + "artifactType": strings.Title(string(release.AgentArtifactTypeValues.Build)), + "artifactDownloadMode": string(ArtifactDownloadModeTypeValues.All), + "artifactItems": []interface{}{}, + }, + }, + }, + "queueId": float64(52), + "demands": []interface{}{"sh", "browser -equals chrome"}, + "enableAccessToken": false, + "timeoutInMinutes": float64(0), + "jobCancelTimeoutInMinutes": float64(1), + "condition": "succeeded()", + // "overrideInputs": interface{}{}, + }, + "rank": float64(1), + "phaseType": "agentBasedDeployment", + "name": "TERRAFORM", + "workflowTasks": []interface{}{ + map[string]interface{}{ + "environment": map[string]interface{}{}, + "taskId": "d9bafed4-0b18-4f58-968d-86655b4d2ce9", + "version": "2.*", + "name": "Command Line Task", + "enabled": true, + "alwaysRun": false, + "continueOnError": false, + "timeoutInMinutes": float64(0), + "definitionType": "task", + "overrideInputs": map[string]interface{}{}, + "condition": "succeeded()", + "inputs": map[string]interface{}{ + "script": "chmod 0777 -R .terraform/plugins", + "workingDirectory": "$(artifactRoot)", + "failOnStderr": "false", + }, + }, + }, + }, + }, + EnvironmentOptions: &release.EnvironmentOptions{ + AutoLinkWorkItems: converter.Bool(true), + BadgeEnabled: converter.Bool(true), + PublishDeploymentStatus: converter.Bool(true), + PullRequestDeploymentEnabled: converter.Bool(false), + }, + }, + { + Id: converter.Int(51), + Name: converter.String("Stage 2"), + Rank: converter.Int(2), + + Variables: &map[string]release.ConfigurationVariableValue{}, + VariableGroups: &[]int{}, + + PreDeployApprovals: &release.ReleaseDefinitionApprovals{ + Approvals: &[]release.ReleaseDefinitionApprovalStep{{ + Id: converter.Int(1001), + Rank: converter.Int(1), + IsAutomated: converter.Bool(true), + IsNotificationOn: converter.Bool(false), + }}, + }, + PostDeployApprovals: &release.ReleaseDefinitionApprovals{ + Approvals: &[]release.ReleaseDefinitionApprovalStep{{ + Id: converter.Int(2002), + Rank: converter.Int(1), + IsAutomated: converter.Bool(true), + IsNotificationOn: converter.Bool(false), + }}, + }, + DeployStep: &release.ReleaseDefinitionDeployStep{ + Id: converter.Int(3003), + Tasks: &[]release.WorkflowTask{}, + }, + + Demands: &[]interface{}{}, + Conditions: &[]release.Condition{ + { + Name: converter.String("Stage 1"), + ConditionType: &release.ConditionTypeValues.EnvironmentState, + Value: converter.String("4"), + }, + }, + + Properties: properties, + + //Schedules: &[]release.ReleaseSchedule{}, + + RetentionPolicy: &release.EnvironmentRetentionPolicy{ + DaysToKeep: converter.Int(1), + ReleasesToKeep: converter.Int(2), + RetainBuild: converter.Bool(false), + }, + + PreDeploymentGates: &release.ReleaseDefinitionGatesStep{ + Id: converter.Int(1), + GatesOptions: nil, + Gates: &[]release.ReleaseDefinitionGate{}, + }, + + PostDeploymentGates: &release.ReleaseDefinitionGatesStep{ + Id: converter.Int(1), + GatesOptions: nil, + Gates: &[]release.ReleaseDefinitionGate{}, + }, + Owner: &webapi.IdentityRef{ + Id: converter.String(testReleaseProjectID), + }, + DeployPhases: &[]interface{}{}, + }, + }, + Triggers: &[]interface{}{}, + Tags: &[]string{}, + ReleaseNameFormat: converter.String("Release-$(rev:r)"), + Url: converter.String(fmt.Sprintf("https://vsrm.dev.azure.com/Demo/%s/_apis/Release/definitions/2", testReleaseProjectID)), + Properties: map[string]interface{}{ + "DefinitionCreationSource": map[string]interface{}{ + "$type": "System.String", + "$value": "ReleaseNew", + }, + "IntegrateBoardsWorkItems": map[string]interface{}{ + "$type": "System.String", + "$value": "true", + }, + "IntegrateJiraWorkItems": map[string]interface{}{ + "$type": "System.String", + "$value": "true", + }, + "JiraServiceEndpointId": map[string]interface{}{ + "$type": "System.String", + "$value": uuid.New().String(), + }, + }, + IsDeleted: converter.Bool(false), + Comment: converter.String("Changes made by Terraform"), + CreatedOn: &azuredevops.Time{Time: now}, + ModifiedOn: &azuredevops.Time{Time: now}, + Artifacts: &[]release.Artifact{ + { + Alias: converter.String("Build Artifact"), + DefinitionReference: &map[string]release.ArtifactSourceReference{ + /* + "artifactSourceDefinitionUrl": { + Id: converter.String(""), + Name: converter.String(""), + }, + */ + "defaultVersionBranch": { + Id: converter.String(""), + //Name: converter.String(""), + }, + "defaultVersionSpecific": { + Id: converter.String(""), + //Name: converter.String(""), + }, + "defaultVersionTags": { + Id: converter.String(""), + //Name: converter.String(""), + }, + "defaultVersionType": { + Id: converter.String("selectDuringReleaseCreationType"), + //Name: converter.String("Specify at the time of release creation"), + }, + "definition": { + Id: converter.String("190"), + //Name: converter.String("Build Pipeline"), + }, + "definitions": { + Id: converter.String(""), + //Name: converter.String(""), + }, + "IsMultiDefinitionType": { + Id: converter.String("False"), + //Name: converter.String("False"), + }, + "project": { + Id: converter.String(testReleaseProjectID), + //Name: converter.String("Project"), + }, + /* + "repository": { + Id: converter.String(""), + Name: converter.String(""), + }, + */ + }, + IsPrimary: converter.Bool(true), + IsRetained: converter.Bool(false), + Type: converter.String(strings.Title(string(release.AgentArtifactTypeValues.Build))), + }, + }, +} + +// verifies that the flatten/expand round trip yields the same release definition +func TestAzureDevOpsReleaseDefinition_ExpandFlatten_Roundtrip(t *testing.T) { + resourceData := schema.TestResourceDataRaw(t, ResourceReleaseDefinition().Schema, nil) + flattenReleaseDefinition(resourceData, &testReleaseDefinition, testReleaseProjectID) + + releaseDefinitionAfterRoundTrip, projectID, err := expandReleaseDefinition(resourceData) + + require.Nil(t, err) + require.Equal(t, sortReleaseDefinition(testReleaseDefinition), sortReleaseDefinition(*releaseDefinitionAfterRoundTrip)) + require.Equal(t, testReleaseProjectID, projectID) +} + +func sortReleaseDefinition(b release.ReleaseDefinition) release.ReleaseDefinition { + if b.Environments != nil { + for _, e := range *b.Environments { + if e.Conditions != nil { + for _, c := range *e.Conditions { + if c.Value != nil && strings.Contains(*c.Value, "{") { + var m map[string]interface{} + if err := json.Unmarshal([]byte(*c.Value), &m); err == nil { + if m2, ok := m["tags"].([]interface{}); ok { + tags := tfhelper.ExpandStringList(m2) + sort.Strings(tags) + m["tags"] = tags + } + value, _ := json.Marshal(m) + *c.Value = string(value) + } + } + } + } + } + } + return b +} diff --git a/azuredevops/provider.go b/azuredevops/provider.go index 07a29a864..b48c27002 100644 --- a/azuredevops/provider.go +++ b/azuredevops/provider.go @@ -11,6 +11,7 @@ import ( "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/service/memberentitlementmanagement" "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/service/permissions" "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/service/policy" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/service/release" "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/service/serviceendpoint" "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/service/taskagent" "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/service/workitemtracking" @@ -27,6 +28,7 @@ func Provider() *schema.Provider { "azuredevops_branch_policy_work_item_linking": policy.ResourceBranchPolicyWorkItemLinking(), "azuredevops_branch_policy_comment_resolution": policy.ResourceBranchPolicyCommentResolution(), "azuredevops_build_definition": build.ResourceBuildDefinition(), + "azuredevops_release_definition": release.ResourceReleaseDefinition(), "azuredevops_project": core.ResourceProject(), "azuredevops_project_features": core.ResourceProjectFeatures(), "azuredevops_variable_group": taskagent.ResourceVariableGroup(), diff --git a/azuredevops/provider_test.go b/azuredevops/provider_test.go index 8dd11e443..3f4e25005 100644 --- a/azuredevops/provider_test.go +++ b/azuredevops/provider_test.go @@ -11,6 +11,7 @@ func TestProvider_HasChildResources(t *testing.T) { expectedResources := []string{ "azuredevops_resource_authorization", "azuredevops_build_definition", + "azuredevops_release_definition", "azuredevops_branch_policy_build_validation", "azuredevops_branch_policy_min_reviewers", "azuredevops_branch_policy_auto_reviewers", From e315f3399e3071f7f2c5dfa0447b7efe500a7da8 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Tue, 1 Sep 2020 14:43:27 -0700 Subject: [PATCH 03/41] fix tests & lint --- .../service/build/resource_build_definition.go | 10 +++++++--- .../service/build/resource_build_definition_test.go | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/azuredevops/internal/service/build/resource_build_definition.go b/azuredevops/internal/service/build/resource_build_definition.go index 846ebc94d..0f5864835 100644 --- a/azuredevops/internal/service/build/resource_build_definition.go +++ b/azuredevops/internal/service/build/resource_build_definition.go @@ -333,6 +333,10 @@ func flattenBuildDefinition(d *schema.ResourceData, buildDefinition *build.Build d.Set("path", *buildDefinition.Path) + if buildDefinition.Tags != nil { + d.Set("tags", *buildDefinition.Tags) + } + d.Set("variable_groups", flattenVariableGroups(buildDefinition)) d.Set(bdVariable, flattenBuildVariables(d, buildDefinition)) @@ -475,7 +479,7 @@ func flattenVariableGroups(buildDefinition *build.BuildDefinition) []int { func flattenRepository(buildDefinition *build.BuildDefinition) interface{} { yamlFilePath := "" - githubEnterpriseUrl := "" + githubEnterpriseURL := "" // The process member can be of many types -- the only typing information // available from the compiler is `interface{}` so we can probe for known @@ -493,7 +497,7 @@ func flattenRepository(buildDefinition *build.BuildDefinition) interface{} { if err != nil { return fmt.Errorf("Unable to parse repository URL: %+v ", err) } - githubEnterpriseUrl = fmt.Sprintf("%s://%s", url.Scheme, url.Host) + githubEnterpriseURL = fmt.Sprintf("%s://%s", url.Scheme, url.Host) } reportBuildStatus, err := strconv.ParseBool((*buildDefinition.Repository.Properties)["reportBuildStatus"]) @@ -506,7 +510,7 @@ func flattenRepository(buildDefinition *build.BuildDefinition) interface{} { "repo_type": *buildDefinition.Repository.Type, "branch_name": *buildDefinition.Repository.DefaultBranch, "service_connection_id": (*buildDefinition.Repository.Properties)["connectedServiceId"], - "github_enterprise_url": githubEnterpriseUrl, + "github_enterprise_url": githubEnterpriseURL, "report_build_status": reportBuildStatus, }} } diff --git a/azuredevops/internal/service/build/resource_build_definition_test.go b/azuredevops/internal/service/build/resource_build_definition_test.go index 7dfbffab8..fbee52c75 100644 --- a/azuredevops/internal/service/build/resource_build_definition_test.go +++ b/azuredevops/internal/service/build/resource_build_definition_test.go @@ -159,6 +159,7 @@ var testBuildDefinitionBitbucketWithCITrigger = build.BuildDefinition{ Type: &build.DefinitionTypeValues.Build, Quality: &build.DefinitionQualityValues.Definition, VariableGroups: &[]build.VariableGroup{}, + Tags: &[]string{}, } // This definition matches the overall structure of what a configured GitHub Enterprise git repository would @@ -197,6 +198,7 @@ var testBuildDefinitionGitHubEnterpriseWithCITrigger = build.BuildDefinition{ Type: &build.DefinitionTypeValues.Build, Quality: &build.DefinitionQualityValues.Definition, VariableGroups: &[]build.VariableGroup{}, + Tags: &[]string{}, } // This definition matches the overall structure of what a configured Bitbucket git repository would From c044181a6533120e6579656ccb8d18b0f41dbe26 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Wed, 2 Sep 2020 06:49:44 -0700 Subject: [PATCH 04/41] update build docs --- website/docs/r/build_definition.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/r/build_definition.html.markdown b/website/docs/r/build_definition.html.markdown index 38e4ea7da..a65b6c0a2 100644 --- a/website/docs/r/build_definition.html.markdown +++ b/website/docs/r/build_definition.html.markdown @@ -109,6 +109,7 @@ The following arguments are supported: - `pull_request_trigger` - (Optional) Pull Request Integration Integration trigger. - `variable_groups` - (Optional) A list of variable group IDs (integers) to link to the build definition. - `variable` - (Optional) A list of `variable` blocks, as documented below. +- `tags` - (Optional) A list of tags. `variable` block supports the following: From 6187002b8de3dbed5a2f9d8bdf42391ec3cfefe6 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Thu, 3 Sep 2020 13:44:03 -0700 Subject: [PATCH 05/41] added acc test --- .../resource_build_definition_test.go | 27 ++++++++++++++++++- .../internal/acceptancetests/testutils/hcl.go | 24 +++++++++++++++++ azuredevops/internal/model/tags.go | 2 +- .../build/resource_build_definition.go | 2 +- 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/azuredevops/internal/acceptancetests/resource_build_definition_test.go b/azuredevops/internal/acceptancetests/resource_build_definition_test.go index decc99674..8b5be0ec4 100644 --- a/azuredevops/internal/acceptancetests/resource_build_definition_test.go +++ b/azuredevops/internal/acceptancetests/resource_build_definition_test.go @@ -134,6 +134,31 @@ func TestAccBuildDefinitionBitbucket_Create(t *testing.T) { }) } +// Verifies a build for with tags can create and update +func TestAccBuildDefinition_WithTags_CreateAndUpdate(t *testing.T) { + name := testutils.GenerateResourceName() + tfNode := "azuredevops_build_definition.build" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testutils.PreCheck(t, nil) }, + Providers: testutils.GetProviders(), + CheckDestroy: checkBuildDefinitionDestroyed, + Steps: []resource.TestStep{ + { + Config: testutils.HclBuildDefinitionWithTags([]string{"one", "two"}, name), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(tfNode, "tags.#", "2"), + ), + }, { + Config: testutils.HclBuildDefinitionWithTags([]string{"one", "two", "three"}, name), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(tfNode, "tags.#", "3"), + ), + }, + }, + }) +} + // Verifies a build for with variables can create and update, including secret variables func TestAccBuildDefinition_WithVariables_CreateAndUpdate(t *testing.T) { name := testutils.GenerateResourceName() @@ -210,7 +235,7 @@ func checkBuildDefinitionExists(expectedName string) resource.TestCheckFunc { } // verifies that all build definitions referenced in the state are destroyed. This will be invoked -// *after* terrafform destroys the resource but *before* the state is wiped clean. +// *after* terraform destroys the resource but *before* the state is wiped clean. func checkBuildDefinitionDestroyed(s *terraform.State) error { for _, resource := range s.RootModule().Resources { if resource.Type != "azuredevops_build_definition" { diff --git a/azuredevops/internal/acceptancetests/testutils/hcl.go b/azuredevops/internal/acceptancetests/testutils/hcl.go index 73a258215..75f1856f1 100644 --- a/azuredevops/internal/acceptancetests/testutils/hcl.go +++ b/azuredevops/internal/acceptancetests/testutils/hcl.go @@ -1,6 +1,7 @@ package testutils import ( + "encoding/json" "fmt" "strings" ) @@ -574,6 +575,29 @@ func HclBuildDefinitionWithVariables(varValue, secretVarValue, name string) stri return fmt.Sprintf("%s\n%s", repoAndProjectResource, buildDefinitionResource) } +// HclBuildDefinitionWithTags A build definition with tags +func HclBuildDefinitionWithTags(tags []string, name string) string { + jsonTags, _ := json.MarshalIndent(tags, "", "") + buildDefinitionResource := fmt.Sprintf(` +resource "azuredevops_build_definition" "build" { + project_id = azuredevops_project.project.id + name = "%s" + + repository { + repo_type = "TfsGit" + repo_id = azuredevops_git_repository.repository.id + branch_name = azuredevops_git_repository.repository.default_branch + yml_path = "azure-pipelines.yml" + } + + tags = %s +}`, + name, jsonTags) + repoAndProjectResource := HclGitRepoResource(name, name+"-repo", "Clean") + + return fmt.Sprintf("%s\n%s", repoAndProjectResource, buildDefinitionResource) +} + // HclGroupMembershipResource full terraform stanza to standup a group membership func HclGroupMembershipResource(projectName, groupName, userPrincipalName string) string { membershipDependenciesStanza := HclGroupMembershipDependencies(projectName, groupName, userPrincipalName) diff --git a/azuredevops/internal/model/tags.go b/azuredevops/internal/model/tags.go index 2263acb4c..284c6a02a 100644 --- a/azuredevops/internal/model/tags.go +++ b/azuredevops/internal/model/tags.go @@ -3,7 +3,7 @@ package model import "github.com/hashicorp/terraform-plugin-sdk/helper/schema" // TagsSchema list of tags -var TagsSchema = &schema.Schema{ +var TagsSchema = schema.Schema{ Type: schema.TypeList, Optional: true, Elem: &schema.Schema{ diff --git a/azuredevops/internal/service/build/resource_build_definition.go b/azuredevops/internal/service/build/resource_build_definition.go index 0f5864835..f7baedc04 100644 --- a/azuredevops/internal/service/build/resource_build_definition.go +++ b/azuredevops/internal/service/build/resource_build_definition.go @@ -294,7 +294,7 @@ func ResourceBuildDefinition() *schema.Resource { }, }, }, - "tags": model.TagsSchema, + "tags": &model.TagsSchema, }, } } From ccc3a75faa607c0191d37997f0d79bb707e8ceba Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Thu, 3 Sep 2020 13:51:34 -0700 Subject: [PATCH 06/41] fix tags syntax --- .../internal/service/release/resource_release_definition.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index ae4fbc436..bcaf2ef07 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -857,7 +857,7 @@ func ResourceReleaseDefinition() *schema.Resource { Type: schema.TypeInt, Required: true, }, - "tags": model.TagsSchema, + "tags": &model.TagsSchema, "multiple": { Type: schema.TypeList, Optional: true, @@ -1099,7 +1099,7 @@ func ResourceReleaseDefinition() *schema.Resource { Type: schema.TypeBool, Computed: true, }, - "tags": model.TagsSchema, + "tags": &model.TagsSchema, "properties": releaseDefinitionProperties, "comment": { Type: schema.TypeString, @@ -1474,7 +1474,7 @@ func expandStringMapString(d map[string]interface{}) map[string]string { if s, ok := v.(string); ok { vs[k] = s } else if s, ok := v.(int); ok { - vs[k] = string(s) + vs[k] = fmt.Sprint(s) } else if b, ok := v.(bool); ok { vs[k] = strconv.FormatBool(b) } else if f, ok := v.(float64); ok { From 199745e2ee5bb722c90ec8de9c411a56459335e3 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Thu, 3 Sep 2020 20:36:03 -0700 Subject: [PATCH 07/41] adding acc test --- .../resource_release_definition_test.go | 170 ++++++++++ .../internal/acceptancetests/testutils/hcl.go | 297 ++++++++++++++++++ 2 files changed, 467 insertions(+) create mode 100644 azuredevops/internal/acceptancetests/resource_release_definition_test.go diff --git a/azuredevops/internal/acceptancetests/resource_release_definition_test.go b/azuredevops/internal/acceptancetests/resource_release_definition_test.go new file mode 100644 index 000000000..964473f69 --- /dev/null +++ b/azuredevops/internal/acceptancetests/resource_release_definition_test.go @@ -0,0 +1,170 @@ +// +build all resource_release_definition +// +build !exclude_resource_release_definition + +package acceptancetests + +import ( + "fmt" + "github.com/microsoft/azure-devops-go-api/azuredevops/release" + "strconv" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/acceptancetests/testutils" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/client" +) + +// validates that an apply followed by another apply (i.e., resource update) will be reflected in AzDO and the +// underlying terraform state. +func TestAccReleaseDefinition_Create_Update_Import(t *testing.T) { + projectName := testutils.GenerateResourceName() + releaseDefinitionPathEmpty := `\` + releaseDefinitionNameFirst := testutils.GenerateResourceName() + releaseDefinitionNameSecond := testutils.GenerateResourceName() + //releaseDefinitionNameThird := testutils.GenerateResourceName() + + releaseDefinitionPathFirst := `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) + releaseDefinitionPathSecond := `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) + + releaseDefinitionPathThird := `\` + releaseDefinitionNameFirst + `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) + releaseDefinitionPathFourth := `\` + releaseDefinitionNameSecond + `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) + + tfReleaseDefNode := "azuredevops_release_definition.release" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testutils.PreCheck(t, nil) }, + Providers: testutils.GetProviders(), + CheckDestroy: checkReleaseDefinitionDestroyed, + Steps: []resource.TestStep{ + { + Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, releaseDefinitionPathEmpty), + Check: resource.ComposeTestCheckFunc( + checkReleaseDefinitionExists(releaseDefinitionNameFirst), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), + resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathEmpty), + ), + }, { + Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameSecond, releaseDefinitionPathEmpty), + Check: resource.ComposeTestCheckFunc( + checkReleaseDefinitionExists(releaseDefinitionNameSecond), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameSecond), + resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathEmpty), + ), + }, { + Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, releaseDefinitionPathFirst), + Check: resource.ComposeTestCheckFunc( + checkReleaseDefinitionExists(releaseDefinitionNameFirst), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), + resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathFirst), + ), + }, { + Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, + releaseDefinitionPathSecond), + Check: resource.ComposeTestCheckFunc( + checkReleaseDefinitionExists(releaseDefinitionNameFirst), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), + resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathSecond), + ), + }, { + Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, releaseDefinitionPathThird), + Check: resource.ComposeTestCheckFunc( + checkReleaseDefinitionExists(releaseDefinitionNameFirst), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), + resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathThird), + ), + }, { + Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, releaseDefinitionPathFourth), + Check: resource.ComposeTestCheckFunc( + checkReleaseDefinitionExists(releaseDefinitionNameFirst), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), + resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathFourth), + ), + }, + //{ + // Config: testutils.HclReleaseDefinitionAgentless(projectName, gitRepoName, releaseDefinitionNameThird, releaseDefinitionPathEmpty), + // Check: resource.ComposeTestCheckFunc( + // checkReleaseDefinitionExists(releaseDefinitionNameThird), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "repository.0.repo_id"), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameThird), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathEmpty), + // ), + //}, + { + // Resource Acceptance Testing https://www.terraform.io/docs/extend/resources/import.html#resource-acceptance-testing-implementation + ResourceName: tfReleaseDefNode, + ImportStateIdFunc: testutils.ComputeProjectQualifiedResourceImportID(tfReleaseDefNode), + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +// Given the name of an AzDO release definition, this will return a function that will check whether +// or not the definition (1) exists in the state and (2) exist in AzDO and (3) has the correct name +func checkReleaseDefinitionExists(expectedName string) resource.TestCheckFunc { + return func(s *terraform.State) error { + releaseDef, ok := s.RootModule().Resources["azuredevops_release_definition.release"] + if !ok { + return fmt.Errorf("Did not find a release definition in the TF state") + } + + releaseDefinition, err := getReleaseDefinitionFromResource(releaseDef) + if err != nil { + return err + } + + if *releaseDefinition.Name != expectedName { + return fmt.Errorf("Release Definition has Name=%s, but expected Name=%s", *releaseDefinition.Name, expectedName) + } + + return nil + } +} + +// verifies that all release definitions referenced in the state are destroyed. This will be invoked +// *after* terraform destroys the resource but *before* the state is wiped clean. +func checkReleaseDefinitionDestroyed(s *terraform.State) error { + for _, resource := range s.RootModule().Resources { + if resource.Type != "azuredevops_release_definition" { + continue + } + + // indicates the release definition still exists - this should fail the test + if _, err := getReleaseDefinitionFromResource(resource); err == nil { + return fmt.Errorf("Unexpectedly found a release definition that should be deleted") + } + } + + return nil +} + +// given a resource from the state, return a release definition (and error) +func getReleaseDefinitionFromResource(resource *terraform.ResourceState) (*release.ReleaseDefinition, error) { + releaseDefID, err := strconv.Atoi(resource.Primary.ID) + if err != nil { + return nil, err + } + + projectID := resource.Primary.Attributes["project_id"] + clients := testutils.GetProvider().Meta().(*client.AggregatedClient) + return clients.ReleaseClient.GetReleaseDefinition(clients.Ctx, release.GetReleaseDefinitionArgs{ + Project: &projectID, + DefinitionId: &releaseDefID, + }) +} diff --git a/azuredevops/internal/acceptancetests/testutils/hcl.go b/azuredevops/internal/acceptancetests/testutils/hcl.go index 75f1856f1..b45a94cd8 100644 --- a/azuredevops/internal/acceptancetests/testutils/hcl.go +++ b/azuredevops/internal/acceptancetests/testutils/hcl.go @@ -747,3 +747,300 @@ resource "azuredevops_git_permissions" "git-permissions" { } `, projectResource, gitRepository) } + +// TestAccReleaseDefinitionTasks yaml of release tasks +func YamlReleaseJobTasks() string { + return ` +#refName: '' +# definitionType: task +# taskId: a433f589-fce1-4460-9ee6-44a624aeb1fb +# version: 0.* +- task: DownloadBuildArtifacts@0 + displayName: "Download Build Artifacts" # name: Download Build Artifacts + environment: # default nil + FOO: bar + enabled: true # default +# alwaysRun: false # default + continueOnError: false # default + timeoutInMinutes: 0 + overrideInputs: # default nil + version: abc + condition: succeeded() # default + inputs: + buildType: current # default + project: 0350d34d-fc00-4e9d-b1c5-78f8a7350b25 + definition: 80 + specificBuildWithTriggering: false # default + buildVersionToDownload: specific # default + allowPartiallySucceededBuilds: false # default + branchName: refs/heads/master + buildId: '' # default + tags: '' # default + downloadType: specific # default + artifactName: '' + itemPattern: "**" + downloadPath: "$(System.DefaultWorkingDirectory)" + parallelizationLimit: '8' +# taskId: d9bafed4-0b18-4f58-968d-86655b4d2ce9 +# version: 2.* +- task: CmdLine@2 + displayName: Add Permissions to AWS Provider Plugin Facility + inputs: + script: | + ls -R + chmod 0777 -R .terraform/plugins + workingDirectory: "$(System.DefaultWorkingDirectory)/Infrastructure/AWS/environments/dev-1/us-west-2/service_facility/" + failOnStderr: false +- task: TerraformInstaller@0 + displayName: "Install Terraform 0.12.13" + inputs: + terraformVersion: '0.12.13' +- task: AWSShellScript@1 + displayName: "Terraform Apply Tenant" + inputs: + awsCredentials: 'merlin-shared-azure-pipelines-build' + regionName: 'us-west-2' + scriptType: 'inline' + inlineScript: | + terraform apply tfplan + disableAutoCwd: true + workingDirectory: '$(System.DefaultWorkingDirectory)/Infrastructure/AWS/environments/dev-1/us-west-2/service_tenant/' +` +} + +// HclReleaseDefinition HCL describing an AzDO release definition with agent jobs +func HclReleaseDefinitionAgent(projectName string, releaseDefinitionName string, releasePath string) string { + projectResource := HclProjectResource(projectName) + tasks := YamlReleaseJobTasks() + releaseDefinitionResource := fmt.Sprintf(` +resource "azuredevops_release_definition" "release" { + project_id = "DevOps" + name = "%s" + path = "\\" + + stage { + name = "Stage 1" + rank = 1 + + agent_job { + name = "Agent job 1" + rank = 1 + demand { + name = "equals_condition_name" + value = "x" + } + demand { + name = "exists_condition_name" + } + agent_pool_hosted_azure_pipelines { + agent_pool_id = 2069 + agent_specification = "ubuntu-18.04" + } + timeout_in_minutes = 0 + max_execution_time_in_minutes = 1 + condition = "succeeded()" + // overrideInput {} // TODO + // enable_access_token ? Do we need this on this level? + } + + agent_job { + name = "Agent job 3" + rank = 3 + agent_pool_hosted_azure_pipelines { + agent_pool_id = 2069 + agent_specification = "ubuntu-18.04" + } + + multi_configuration { + multipliers = "OperatingSystem" + number_of_agents = 1 + } + + condition = "succeeded()" + // overrideInput {} // TODO + // enable_access_token ? Do we need this on this level? + } + + agent_job { + name = "Agent job 2" + rank = 2 + agent_pool_hosted_azure_pipelines { + agent_pool_id = 2069 + agent_specification = "ubuntu-18.04" + } + multi_agent { + max_number_of_agents = 1 + } + condition = "succeeded()" + // overrideInput {} // TODO + // enable_access_token ? Do we need this on this level? + + dynamic "task" { + for_each = local.tasks + content { + always_run = lookup(task.value, "alwaysRun", null) + condition = lookup(task.value, "condition", null) + continue_on_error = lookup(task.value, "continueOnError", null) + enabled = lookup(task.value, "enabled", null) + display_name = lookup(task.value, "displayName", null) + override_input = lookup(task.value, "overrideInput", null) + inputs = lookup(task.value, "inputs", null) + timeout_in_minutes = lookup(task.value, "timeoutInMinutes", null) + // task MUST come last as it overwites the task + task = lookup(task.value, "task", null) + } + } + } + + pre_deploy_approval { + approval { + is_automated = true + rank = 1 + } + } + + post_deploy_approval { + approval { + is_automated = true + rank = 1 + } + } + + retention_policy { + days_to_keep = 1 + releases_to_keep = 1 + } + } +} + +locals { + tasks = yamldecode(< Date: Fri, 4 Sep 2020 15:24:54 -0700 Subject: [PATCH 08/41] adding group for ownership of the release pipeline, escape path --- .../resource_release_definition_test.go | 26 +++--- .../internal/acceptancetests/testutils/hcl.go | 83 +++++++++++-------- 2 files changed, 62 insertions(+), 47 deletions(-) diff --git a/azuredevops/internal/acceptancetests/resource_release_definition_test.go b/azuredevops/internal/acceptancetests/resource_release_definition_test.go index 964473f69..4471666fd 100644 --- a/azuredevops/internal/acceptancetests/resource_release_definition_test.go +++ b/azuredevops/internal/acceptancetests/resource_release_definition_test.go @@ -23,7 +23,7 @@ func TestAccReleaseDefinition_Create_Update_Import(t *testing.T) { releaseDefinitionPathEmpty := `\` releaseDefinitionNameFirst := testutils.GenerateResourceName() releaseDefinitionNameSecond := testutils.GenerateResourceName() - //releaseDefinitionNameThird := testutils.GenerateResourceName() + releaseDefinitionNameThird := testutils.GenerateResourceName() releaseDefinitionPathFirst := `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) releaseDefinitionPathSecond := `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) @@ -92,19 +92,17 @@ func TestAccReleaseDefinition_Create_Update_Import(t *testing.T) { resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathFourth), ), - }, - //{ - // Config: testutils.HclReleaseDefinitionAgentless(projectName, gitRepoName, releaseDefinitionNameThird, releaseDefinitionPathEmpty), - // Check: resource.ComposeTestCheckFunc( - // checkReleaseDefinitionExists(releaseDefinitionNameThird), - // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), - // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), - // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "repository.0.repo_id"), - // resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameThird), - // resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathEmpty), - // ), - //}, - { + }, { + Config: testutils.HclReleaseDefinitionAgentless(projectName, gitRepoName, releaseDefinitionNameThird, releaseDefinitionPathEmpty), + Check: resource.ComposeTestCheckFunc( + checkReleaseDefinitionExists(releaseDefinitionNameThird), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + resource.TestCheckResourceAttrSet(tfReleaseDefNode, "repository.0.repo_id"), + resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameThird), + resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathEmpty), + ), + }, { // Resource Acceptance Testing https://www.terraform.io/docs/extend/resources/import.html#resource-acceptance-testing-implementation ResourceName: tfReleaseDefNode, ImportStateIdFunc: testutils.ComputeProjectQualifiedResourceImportID(tfReleaseDefNode), diff --git a/azuredevops/internal/acceptancetests/testutils/hcl.go b/azuredevops/internal/acceptancetests/testutils/hcl.go index b45a94cd8..455a4fea0 100644 --- a/azuredevops/internal/acceptancetests/testutils/hcl.go +++ b/azuredevops/internal/acceptancetests/testutils/hcl.go @@ -813,14 +813,21 @@ func HclReleaseDefinitionAgent(projectName string, releaseDefinitionName string, projectResource := HclProjectResource(projectName) tasks := YamlReleaseJobTasks() releaseDefinitionResource := fmt.Sprintf(` + +resource "azuredevops_group" "release" { + scope = azuredevops_project.project.id + display_name = "release" +} + resource "azuredevops_release_definition" "release" { - project_id = "DevOps" + project_id = azuredevops_project.project.id name = "%s" path = "\\" stage { name = "Stage 1" rank = 1 + owner_id = azuredevops_group.release.id agent_job { name = "Agent job 1" @@ -920,7 +927,7 @@ YAML ) } -`, releaseDefinitionName, tasks) +`, releaseDefinitionName, releasePath, tasks) return fmt.Sprintf("%s\n%s", projectResource, releaseDefinitionResource) } @@ -929,17 +936,15 @@ func HclReleaseDefinitionDeploymentGroup(projectName string, releaseDefinitionNa projectResource := HclProjectResource(projectName) releaseDefinitionResource := fmt.Sprintf(` resource "azuredevops_release_definition" "release" { - project_id = "DevOps" // TODO: revert this back to azuredevops_project.project.id + project_id = azuredevops_project.project.id name = "%s" - path = "\\" + path = "%s" stage { name = "Stage 1" - rank = 1 deployment_group_job { name = "Deployment group job 1" - rank = 1 deployment_group_id = 1619 // QueueID //DeploymentHealthOption: OneAtATime tags = ["deployment_group_job_1"] @@ -952,7 +957,6 @@ resource "azuredevops_release_definition" "release" { deployment_group_job { name = "Deployment group job 2" - rank = 2 deployment_group_id = 1619 tags = ["deployment_group_job_2"] multiple { //DeploymentHealthOption: Custom @@ -984,55 +988,62 @@ resource "azuredevops_release_definition" "release" { releases_to_keep = 1 } } -}`, releaseDefinitionName) +}`, releaseDefinitionName, releasePath) return fmt.Sprintf("%s\n%s", projectResource, releaseDefinitionResource) } // HclReleaseDefinition HCL describing an AzDO build definition with agentless jobs func HclReleaseDefinitionAgentless(projectName string, releaseDefinitionName string, releasePath string) string { projectResource := HclProjectResource(projectName) + escapedReleasePath := strings.ReplaceAll(releasePath, `\`, `\\`) releaseDefinitionResource := fmt.Sprintf(` +resource "azuredevops_group" "release" { + scope = azuredevops_project.project.id + display_name = "release" +} + resource "azuredevops_release_definition" "release" { - project_id = "DevOps" + project_id = azuredevops_project.project.id name = "%s" - path = "\\" + path = "%s" stage { name = "Stage 1" - rank = 1 + owner_id = azuredevops_group.release.origin_id - agentless_job { - name = "Agentless job 1" - rank = 1 + job { + agentless { + name = "Agentless job 1" - max_execution_time_in_minutes = 1 - timeout_in_minutes = 0 - condition = "succeeded()" - } - - agentless_job { - name = "Agentless job 2" - rank = 2 + max_execution_time_in_minutes = 1 + timeout_in_minutes = 0 + condition = "succeeded()" + } + } + + job { + agentless { + name = "Agentless job 2" - multi_configuration { - multipliers = "OperatingSystem" + multi_configuration { + multipliers = "OperatingSystem" + } + max_execution_time_in_minutes = 1 + timeout_in_minutes = 0 + condition = "succeeded()" } - max_execution_time_in_minutes = 1 - timeout_in_minutes = 0 - condition = "succeeded()" - } + } + + deploy_step { + } pre_deploy_approval { approval { - is_automated = true - rank = 1 } } post_deploy_approval { approval { - is_automated = true - rank = 1 } } @@ -1040,7 +1051,13 @@ resource "azuredevops_release_definition" "release" { days_to_keep = 1 releases_to_keep = 1 } + + pre_deploy_gate { + } + + post_deploy_gate { + } } -}`, releaseDefinitionName) +}`, releaseDefinitionName, escapedReleasePath) return fmt.Sprintf("%s\n%s", projectResource, releaseDefinitionResource) } From b88d971b529143f2bda4b01d8d74ef994fb352de Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Tue, 8 Sep 2020 13:01:43 -0700 Subject: [PATCH 09/41] adding data for agent queue & adding origin id to group data --- .../internal/service/graph/data_group.go | 7 ++ .../service/taskagent/data_agent_queue.go | 73 +++++++++++++++++++ azuredevops/provider.go | 1 + azuredevops/provider_test.go | 1 + 4 files changed, 82 insertions(+) create mode 100644 azuredevops/internal/service/taskagent/data_agent_queue.go diff --git a/azuredevops/internal/service/graph/data_group.go b/azuredevops/internal/service/graph/data_group.go index 9161e2eec..2891f45ce 100644 --- a/azuredevops/internal/service/graph/data_group.go +++ b/azuredevops/internal/service/graph/data_group.go @@ -33,6 +33,10 @@ func DataGroup() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "origin_id": { + Type: schema.TypeString, + Computed: true, + }, }, } } @@ -66,6 +70,9 @@ func dataSourceGroupRead(d *schema.ResourceData, m interface{}) error { d.SetId(*targetGroup.Descriptor) d.Set("descriptor", *targetGroup.Descriptor) + if targetGroup.OriginId != nil { + d.Set("origin_id", *targetGroup.OriginId) + } return nil } diff --git a/azuredevops/internal/service/taskagent/data_agent_queue.go b/azuredevops/internal/service/taskagent/data_agent_queue.go new file mode 100644 index 000000000..694a8c0ed --- /dev/null +++ b/azuredevops/internal/service/taskagent/data_agent_queue.go @@ -0,0 +1,73 @@ +package taskagent + +import ( + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/microsoft/azure-devops-go-api/azuredevops/taskagent" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/client" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/utils/converter" + "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/utils/suppress" + "strconv" +) + +// DataAgentQueue schema and implementation for agent queue source +func DataAgentQueue() *schema.Resource { + return &schema.Resource{ + Read: dataSourceAgentQueueRead, + Schema: map[string]*schema.Schema{ + projectID: { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + DiffSuppressFunc: suppress.CaseDifference, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + }, + } +} + +func dataSourceAgentQueueRead(d *schema.ResourceData, m interface{}) error { + agentQueueName := d.Get("name").(string) + projectID := d.Get("project_id").(string) + clients := m.(*client.AggregatedClient) + + agentQueue, err := getAgentQueueByName(clients, &agentQueueName, &projectID) + if err != nil { + return fmt.Errorf("Error getting agent queue by name: %v", err) + } + + flattenAzureAgentQueue(d, agentQueue) + return nil +} + +func flattenAzureAgentQueue(d *schema.ResourceData, agentQueue *taskagent.TaskAgentQueue) { + d.SetId(strconv.Itoa(*agentQueue.Id)) + d.Set("name", converter.ToString(agentQueue.Name, "")) + d.Set("pool_id", strconv.Itoa(*agentQueue.Pool.Id)) + //d.Set("project_id", *agentQueue.ProjectId) +} + +func getAgentQueueByName(clients *client.AggregatedClient, name, projectID *string) (*taskagent.TaskAgentQueue, error) { + agentQueues, err := clients.TaskAgentClient.GetAgentQueuesByNames(clients.Ctx, taskagent.GetAgentQueuesByNamesArgs{ + Project: projectID, + QueueNames: &[]string{*name}, + }) + + if err != nil { + return nil, err + } + + if len(*agentQueues) > 1 { + return nil, fmt.Errorf("Found multiple agent queue for name: %s. Agent queues found: %v", *name, agentQueues) + } + + if len(*agentQueues) == 0 { + return nil, fmt.Errorf("Unable to find agent queue with name: %s", *name) + } + + return &(*agentQueues)[0], nil +} diff --git a/azuredevops/provider.go b/azuredevops/provider.go index b48c27002..469264711 100644 --- a/azuredevops/provider.go +++ b/azuredevops/provider.go @@ -54,6 +54,7 @@ func Provider() *schema.Provider { DataSourcesMap: map[string]*schema.Resource{ "azuredevops_agent_pool": taskagent.DataAgentPool(), "azuredevops_agent_pools": taskagent.DataAgentPools(), + "azuredevops_agent_queue": taskagent.DataAgentQueue(), "azuredevops_client_config": service.DataClientConfig(), "azuredevops_group": graph.DataGroup(), "azuredevops_project": core.DataProject(), diff --git a/azuredevops/provider_test.go b/azuredevops/provider_test.go index 3f4e25005..7676eee16 100644 --- a/azuredevops/provider_test.go +++ b/azuredevops/provider_test.go @@ -60,6 +60,7 @@ func TestProvider_HasChildDataSources(t *testing.T) { "azuredevops_users", "azuredevops_agent_pool", "azuredevops_agent_pools", + "azuredevops_agent_queue", "azuredevops_area", "azuredevops_iteration", } From f179fba702d71c52b7fe87f409c3758e87b9a517 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Tue, 8 Sep 2020 13:02:22 -0700 Subject: [PATCH 10/41] update to test, got it running, not passing --- .../resource_release_definition_test.go | 141 +++++++++--------- .../internal/acceptancetests/testutils/hcl.go | 130 ++++++---------- 2 files changed, 118 insertions(+), 153 deletions(-) diff --git a/azuredevops/internal/acceptancetests/resource_release_definition_test.go b/azuredevops/internal/acceptancetests/resource_release_definition_test.go index 4471666fd..07e9b41b2 100644 --- a/azuredevops/internal/acceptancetests/resource_release_definition_test.go +++ b/azuredevops/internal/acceptancetests/resource_release_definition_test.go @@ -9,7 +9,6 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/acceptancetests/testutils" @@ -22,15 +21,16 @@ func TestAccReleaseDefinition_Create_Update_Import(t *testing.T) { projectName := testutils.GenerateResourceName() releaseDefinitionPathEmpty := `\` releaseDefinitionNameFirst := testutils.GenerateResourceName() - releaseDefinitionNameSecond := testutils.GenerateResourceName() - releaseDefinitionNameThird := testutils.GenerateResourceName() + //releaseDefinitionNameSecond := testutils.GenerateResourceName() + //releaseDefinitionNameThird := testutils.GenerateResourceName() - releaseDefinitionPathFirst := `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) - releaseDefinitionPathSecond := `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) + //releaseDefinitionPathFirst := `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) + //releaseDefinitionPathSecond := `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) - releaseDefinitionPathThird := `\` + releaseDefinitionNameFirst + `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) - releaseDefinitionPathFourth := `\` + releaseDefinitionNameSecond + `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) + //releaseDefinitionPathThird := `\` + releaseDefinitionNameFirst + `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) + //releaseDefinitionPathFourth := `\` + releaseDefinitionNameSecond + `\` + acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) + c1 := testutils.HclReleaseDefinitionAgent(projectName, releaseDefinitionNameFirst, releaseDefinitionPathEmpty) tfReleaseDefNode := "azuredevops_release_definition.release" resource.Test(t, resource.TestCase{ PreCheck: func() { testutils.PreCheck(t, nil) }, @@ -38,7 +38,7 @@ func TestAccReleaseDefinition_Create_Update_Import(t *testing.T) { CheckDestroy: checkReleaseDefinitionDestroyed, Steps: []resource.TestStep{ { - Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, releaseDefinitionPathEmpty), + Config: c1, Check: resource.ComposeTestCheckFunc( checkReleaseDefinitionExists(releaseDefinitionNameFirst), resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), @@ -46,69 +46,70 @@ func TestAccReleaseDefinition_Create_Update_Import(t *testing.T) { resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathEmpty), ), - }, { - Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameSecond, releaseDefinitionPathEmpty), - Check: resource.ComposeTestCheckFunc( - checkReleaseDefinitionExists(releaseDefinitionNameSecond), - resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), - resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), - resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameSecond), - resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathEmpty), - ), - }, { - Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, releaseDefinitionPathFirst), - Check: resource.ComposeTestCheckFunc( - checkReleaseDefinitionExists(releaseDefinitionNameFirst), - resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), - resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), - resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), - resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathFirst), - ), - }, { - Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, - releaseDefinitionPathSecond), - Check: resource.ComposeTestCheckFunc( - checkReleaseDefinitionExists(releaseDefinitionNameFirst), - resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), - resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), - resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), - resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathSecond), - ), - }, { - Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, releaseDefinitionPathThird), - Check: resource.ComposeTestCheckFunc( - checkReleaseDefinitionExists(releaseDefinitionNameFirst), - resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), - resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), - resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), - resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathThird), - ), - }, { - Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, releaseDefinitionPathFourth), - Check: resource.ComposeTestCheckFunc( - checkReleaseDefinitionExists(releaseDefinitionNameFirst), - resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), - resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), - resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), - resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathFourth), - ), - }, { - Config: testutils.HclReleaseDefinitionAgentless(projectName, gitRepoName, releaseDefinitionNameThird, releaseDefinitionPathEmpty), - Check: resource.ComposeTestCheckFunc( - checkReleaseDefinitionExists(releaseDefinitionNameThird), - resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), - resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), - resource.TestCheckResourceAttrSet(tfReleaseDefNode, "repository.0.repo_id"), - resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameThird), - resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathEmpty), - ), - }, { - // Resource Acceptance Testing https://www.terraform.io/docs/extend/resources/import.html#resource-acceptance-testing-implementation - ResourceName: tfReleaseDefNode, - ImportStateIdFunc: testutils.ComputeProjectQualifiedResourceImportID(tfReleaseDefNode), - ImportState: true, - ImportStateVerify: true, }, + //{ + // Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameSecond, releaseDefinitionPathEmpty), + // Check: resource.ComposeTestCheckFunc( + // checkReleaseDefinitionExists(releaseDefinitionNameSecond), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameSecond), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathEmpty), + // ), + //}, { + // Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, releaseDefinitionPathFirst), + // Check: resource.ComposeTestCheckFunc( + // checkReleaseDefinitionExists(releaseDefinitionNameFirst), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathFirst), + // ), + //}, { + // Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, + // releaseDefinitionPathSecond), + // Check: resource.ComposeTestCheckFunc( + // checkReleaseDefinitionExists(releaseDefinitionNameFirst), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathSecond), + // ), + //}, { + // Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, releaseDefinitionPathThird), + // Check: resource.ComposeTestCheckFunc( + // checkReleaseDefinitionExists(releaseDefinitionNameFirst), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathThird), + // ), + //}, { + // Config: testutils.HclReleaseDefinitionAgentless(projectName, releaseDefinitionNameFirst, releaseDefinitionPathFourth), + // Check: resource.ComposeTestCheckFunc( + // checkReleaseDefinitionExists(releaseDefinitionNameFirst), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameFirst), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathFourth), + // ), + //}, { + // Config: testutils.HclReleaseDefinitionAgentless(projectName, gitRepoName, releaseDefinitionNameThird, releaseDefinitionPathEmpty), + // Check: resource.ComposeTestCheckFunc( + // checkReleaseDefinitionExists(releaseDefinitionNameThird), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "project_id"), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "revision"), + // resource.TestCheckResourceAttrSet(tfReleaseDefNode, "repository.0.repo_id"), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "name", releaseDefinitionNameThird), + // resource.TestCheckResourceAttr(tfReleaseDefNode, "path", releaseDefinitionPathEmpty), + // ), + //}, { + // // Resource Acceptance Testing https://www.terraform.io/docs/extend/resources/import.html#resource-acceptance-testing-implementation + // ResourceName: tfReleaseDefNode, + // ImportStateIdFunc: testutils.ComputeProjectQualifiedResourceImportID(tfReleaseDefNode), + // ImportState: true, + // ImportStateVerify: true, + //}, }, }) } diff --git a/azuredevops/internal/acceptancetests/testutils/hcl.go b/azuredevops/internal/acceptancetests/testutils/hcl.go index 455a4fea0..2b4965ae7 100644 --- a/azuredevops/internal/acceptancetests/testutils/hcl.go +++ b/azuredevops/internal/acceptancetests/testutils/hcl.go @@ -811,111 +811,68 @@ func YamlReleaseJobTasks() string { // HclReleaseDefinition HCL describing an AzDO release definition with agent jobs func HclReleaseDefinitionAgent(projectName string, releaseDefinitionName string, releasePath string) string { projectResource := HclProjectResource(projectName) + escapedReleasePath := strings.ReplaceAll(releasePath, `\`, `\\`) tasks := YamlReleaseJobTasks() releaseDefinitionResource := fmt.Sprintf(` +data "azuredevops_group" "group" { + project_id = azuredevops_project.project.id + name = "Build Administrators" +} -resource "azuredevops_group" "release" { - scope = azuredevops_project.project.id - display_name = "release" +data "azuredevops_agent_pool" "pool" { + name = "Azure Pipelines" +} + +data "azuredevops_agent_queue" "queue" { + project_id = azuredevops_project.project.id + name = "Azure Pipelines" } resource "azuredevops_release_definition" "release" { project_id = azuredevops_project.project.id name = "%s" - path = "\\" + path = "%s" stage { name = "Stage 1" - rank = 1 - owner_id = azuredevops_group.release.id - - agent_job { - name = "Agent job 1" - rank = 1 - demand { - name = "equals_condition_name" - value = "x" - } - demand { - name = "exists_condition_name" - } - agent_pool_hosted_azure_pipelines { - agent_pool_id = 2069 - agent_specification = "ubuntu-18.04" - } - timeout_in_minutes = 0 - max_execution_time_in_minutes = 1 - condition = "succeeded()" - // overrideInput {} // TODO - // enable_access_token ? Do we need this on this level? - } + owner_id = data.azuredevops_group.group.origin_id + variable_groups = [] - agent_job { - name = "Agent job 3" - rank = 3 - agent_pool_hosted_azure_pipelines { - agent_pool_id = 2069 - agent_specification = "ubuntu-18.04" - } - - multi_configuration { - multipliers = "OperatingSystem" - number_of_agents = 1 - } + job { + agent { + name = "Agent job 1" + timeout_in_minutes = 0 + max_execution_time_in_minutes = 1 + allow_scripts_to_access_oauth_token = false + skip_artifacts_download = false - condition = "succeeded()" - // overrideInput {} // TODO - // enable_access_token ? Do we need this on this level? + agent_pool_hosted_azure_pipelines { + agent_pool_id = data.azuredevops_agent_queue.queue.id + agent_specification = "ubuntu-18.04" + } + } } - agent_job { - name = "Agent job 2" - rank = 2 - agent_pool_hosted_azure_pipelines { - agent_pool_id = 2069 - agent_specification = "ubuntu-18.04" - } - multi_agent { - max_number_of_agents = 1 - } - condition = "succeeded()" - // overrideInput {} // TODO - // enable_access_token ? Do we need this on this level? - - dynamic "task" { - for_each = local.tasks - content { - always_run = lookup(task.value, "alwaysRun", null) - condition = lookup(task.value, "condition", null) - continue_on_error = lookup(task.value, "continueOnError", null) - enabled = lookup(task.value, "enabled", null) - display_name = lookup(task.value, "displayName", null) - override_input = lookup(task.value, "overrideInput", null) - inputs = lookup(task.value, "inputs", null) - timeout_in_minutes = lookup(task.value, "timeoutInMinutes", null) - // task MUST come last as it overwites the task - task = lookup(task.value, "task", null) - } - } + deploy_step { } pre_deploy_approval { approval { - is_automated = true - rank = 1 } } post_deploy_approval { approval { - is_automated = true - rank = 1 } } retention_policy { - days_to_keep = 1 - releases_to_keep = 1 + } + + pre_deploy_gate { + } + + post_deploy_gate { } } } @@ -927,14 +884,20 @@ YAML ) } -`, releaseDefinitionName, releasePath, tasks) +`, releaseDefinitionName, escapedReleasePath, tasks) return fmt.Sprintf("%s\n%s", projectResource, releaseDefinitionResource) } // HclReleaseDefinition HCL describing an AzDO release definition with deployment group jobs func HclReleaseDefinitionDeploymentGroup(projectName string, releaseDefinitionName string, releasePath string) string { projectResource := HclProjectResource(projectName) + escapedReleasePath := strings.ReplaceAll(releasePath, `\`, `\\`) releaseDefinitionResource := fmt.Sprintf(` +data "azuredevops_group" "group" { + project_id = azuredevops_project.project.id + name = "Build Administrators" +} + resource "azuredevops_release_definition" "release" { project_id = azuredevops_project.project.id name = "%s" @@ -942,6 +905,7 @@ resource "azuredevops_release_definition" "release" { stage { name = "Stage 1" + owner_id = data.azuredevops_group.group.origin_id deployment_group_job { name = "Deployment group job 1" @@ -988,7 +952,7 @@ resource "azuredevops_release_definition" "release" { releases_to_keep = 1 } } -}`, releaseDefinitionName, releasePath) +}`, releaseDefinitionName, escapedReleasePath) return fmt.Sprintf("%s\n%s", projectResource, releaseDefinitionResource) } @@ -997,9 +961,9 @@ func HclReleaseDefinitionAgentless(projectName string, releaseDefinitionName str projectResource := HclProjectResource(projectName) escapedReleasePath := strings.ReplaceAll(releasePath, `\`, `\\`) releaseDefinitionResource := fmt.Sprintf(` -resource "azuredevops_group" "release" { - scope = azuredevops_project.project.id - display_name = "release" +data "azuredevops_group" "group" { + project_id = azuredevops_project.project.id + name = "Build Administrators" } resource "azuredevops_release_definition" "release" { @@ -1009,7 +973,7 @@ resource "azuredevops_release_definition" "release" { stage { name = "Stage 1" - owner_id = azuredevops_group.release.origin_id + owner_id = data.azuredevops_group.group.origin_id job { agentless { From 5bdd03c326e56e6968b88867785180c38f50df38 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Wed, 9 Sep 2020 08:13:11 -0700 Subject: [PATCH 11/41] fix import name --- .../resource_release_definition_test.go | 4 ++-- .../service/release/resource_release_definition.go | 12 ++++++------ .../release/resource_release_definition_test.go | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/azuredevops/internal/acceptancetests/resource_release_definition_test.go b/azuredevops/internal/acceptancetests/resource_release_definition_test.go index 07e9b41b2..dc58b04bb 100644 --- a/azuredevops/internal/acceptancetests/resource_release_definition_test.go +++ b/azuredevops/internal/acceptancetests/resource_release_definition_test.go @@ -11,8 +11,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" - "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/acceptancetests/testutils" - "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/client" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/acceptancetests/testutils" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" ) // validates that an apply followed by another apply (i.e., resource update) will be reflected in AzDO and the diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index bcaf2ef07..d6c31aa07 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -8,12 +8,12 @@ import ( "github.com/microsoft/azure-devops-go-api/azuredevops" "github.com/microsoft/azure-devops-go-api/azuredevops/release" "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" - "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/client" - "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/model" - "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/service/distributedtask" - "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/utils/converter" - "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" - "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/utils/validate" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/model" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/distributedtask" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/converter" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/validate" "log" "regexp" "sort" diff --git a/azuredevops/internal/service/release/resource_release_definition_test.go b/azuredevops/internal/service/release/resource_release_definition_test.go index 4cf3a2f1a..c74cb5583 100644 --- a/azuredevops/internal/service/release/resource_release_definition_test.go +++ b/azuredevops/internal/service/release/resource_release_definition_test.go @@ -6,9 +6,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/microsoft/azure-devops-go-api/azuredevops" "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/converter" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" "github.com/stretchr/testify/require" - "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/utils/converter" - "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" "sort" "strings" "testing" From b875ccbd56067a8cdc1ec4c0f118209d3a6573d7 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Wed, 9 Sep 2020 10:37:45 -0700 Subject: [PATCH 12/41] move tasks to taskagent --- .../service/release/resource_release_definition.go | 8 ++++---- .../{distributedtask/task.go => taskagent/tasks.go} | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename azuredevops/internal/service/{distributedtask/task.go => taskagent/tasks.go} (99%) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index d6c31aa07..2f4c90dc9 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -10,7 +10,7 @@ import ( "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/model" - "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/distributedtask" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/taskagent" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/converter" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/validate" @@ -174,7 +174,7 @@ func ResourceReleaseDefinition() *schema.Resource { } task := strings.Split(v, "@") taskName := task[0] - if _, ok := distributedtask.TaskNameToUUID[taskName]; !ok { + if _, ok := taskagent.TaskNameToUUID[taskName]; !ok { return nil, []error{fmt.Errorf("unkown task %q", taskName)} } return nil, nil @@ -2207,7 +2207,7 @@ func expandReleaseDefinitionDemandList(d []interface{}) []interface{} { func expandReleaseWorkFlowTask(d map[string]interface{}) release.WorkflowTask { task := strings.Split(d["task"].(string), "@") taskName, version := task[0], task[1] - taskID := distributedtask.TaskNameToUUID[taskName] + taskID := taskagent.TaskNameToUUID[taskName] inputs := expandStringMapString(d["inputs"].(map[string]interface{})) environment := expandStringMapString(d["environment"].(map[string]interface{})) @@ -2515,7 +2515,7 @@ func flattenReleaseDefinitionProperties(m interface{}) interface{} { } func flattenReleaseWorkflowTask(m release.WorkflowTask) map[string]interface{} { - task := distributedtask.TaskUUIDToName[*m.TaskId] + "@" + *m.Version + task := taskagent.TaskUUIDToName[*m.TaskId] + "@" + *m.Version return map[string]interface{}{ "task": task, "display_name": m.Name, diff --git a/azuredevops/internal/service/distributedtask/task.go b/azuredevops/internal/service/taskagent/tasks.go similarity index 99% rename from azuredevops/internal/service/distributedtask/task.go rename to azuredevops/internal/service/taskagent/tasks.go index bbd3d8878..4ed7047c2 100644 --- a/azuredevops/internal/service/distributedtask/task.go +++ b/azuredevops/internal/service/taskagent/tasks.go @@ -1,4 +1,4 @@ -package distributedtask +package taskagent import "github.com/google/uuid" From 51a31faad4ba8adbbcb90c289fe804c971f2c996 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Wed, 9 Sep 2020 13:47:44 -0700 Subject: [PATCH 13/41] added support for approval options --- .../release/resource_release_definition.go | 44 ++++++++++++++----- .../resource_release_definition_test.go | 16 ++++++- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 2f4c90dc9..588aca1c2 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1689,8 +1689,9 @@ func expandReleaseDefinitionEnvironment(d map[string]interface{}, rank int) rele demands := expandReleaseDefinitionDemandList(d["demand"].([]interface{})) environmentOptions := expandReleaseEnvironmentOptionsListFirstOrNil(d["environment_options"].([]interface{})) retentionPolicy := expandReleaseEnvironmentRetentionPolicyListFirstOrNil(d["retention_policy"].([]interface{})) - preDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["pre_deploy_approval"].([]interface{})) - postDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["post_deploy_approval"].([]interface{})) + approvalOptions := expandReleaseApprovalOptionsListFirstOrNil(d["approval_options"].([]interface{})) + preDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["pre_deploy_approval"].([]interface{}), approvalOptions) + postDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["post_deploy_approval"].([]interface{}), approvalOptions) properties := expandReleaseEnvironmentPropertiesListFirstOrNil(d["properties"].([]interface{})) deployPhases := expandJobsList(d["job"].([]interface{})) preDeploymentGates := expandReleaseDefinitionGatesStepListFirstOrNil(d["pre_deploy_gate"].([]interface{})) @@ -2333,20 +2334,18 @@ func expandReleaseApprovalOptionsListFirstOrNil(d []interface{}) *release.Approv return &d2[0] } -func expandReleaseDefinitionApprovals(d map[string]interface{}) release.ReleaseDefinitionApprovals { +func expandReleaseDefinitionApprovals(d map[string]interface{}, approvalOptions *release.ApprovalOptions) release.ReleaseDefinitionApprovals { approvals := expandReleaseDefinitionApprovalStepList(d["approval"].([]interface{})) - // TODO : expand approval Options first and then pass them into this method. - //approvalOptions := expandReleaseApprovalOptionsListFirstOrNil(d["approval_options"].([]interface{})) return release.ReleaseDefinitionApprovals{ - Approvals: &approvals, - // ApprovalOptions: approvalOptions, + Approvals: &approvals, + ApprovalOptions: approvalOptions, } } -func expandReleaseDefinitionApprovalsList(d []interface{}) []release.ReleaseDefinitionApprovals { +func expandReleaseDefinitionApprovalsList(d []interface{}, approvalOptions *release.ApprovalOptions) []release.ReleaseDefinitionApprovals { vs := make([]release.ReleaseDefinitionApprovals, 0, len(d)) for _, v := range d { if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseDefinitionApprovals(val)) + vs = append(vs, expandReleaseDefinitionApprovals(val, approvalOptions)) } } if len(vs) == 0 { @@ -2354,8 +2353,8 @@ func expandReleaseDefinitionApprovalsList(d []interface{}) []release.ReleaseDefi } return vs } -func expandReleaseDefinitionApprovalsListFirstOrNil(d []interface{}) *release.ReleaseDefinitionApprovals { - d2 := expandReleaseDefinitionApprovalsList(d) +func expandReleaseDefinitionApprovalsListFirstOrNil(d []interface{}, approvalOptions *release.ApprovalOptions) *release.ReleaseDefinitionApprovals { + d2 := expandReleaseDefinitionApprovalsList(d, approvalOptions) if len(d2) != 1 { return nil } @@ -2727,6 +2726,28 @@ func flattenReleaseDefinitionApprovalStepList(m *[]release.ReleaseDefinitionAppr return ds } +func flattenApprovalOptions(m1, m2 *release.ApprovalOptions) []map[string]interface{} { + var m *release.ApprovalOptions + if m1 != nil && m2 == nil { + m = m1 + } else if m2 != nil { + m = m2 + } + + if m == nil { + return nil + } + + return []map[string]interface{}{{ + "auto_triggered_and_previous_environment_approved_can_be_skipped": m.AutoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped, + "enforce_identity_revalidation": m.EnforceIdentityRevalidation, + "execution_order": m.ExecutionOrder, + "release_creator_can_be_approver": m.ReleaseCreatorCanBeApprover, + "required_approver_count": m.RequiredApproverCount, + "timeout_in_minutes": m.TimeoutInMinutes, + }} +} + func flattenReleaseDefinitionApprovals(m *release.ReleaseDefinitionApprovals) []map[string]interface{} { return []map[string]interface{}{{ "approval": flattenReleaseDefinitionApprovalStepList(m.Approvals), @@ -2866,6 +2887,7 @@ func flattenReleaseDefinitionEnvironment(m release.ReleaseDefinitionEnvironment) "owner_id": ownerID, "variable": flattenReleaseDefinitionVariables(m.Variables), "variable_groups": m.VariableGroups, + "approval_options": flattenApprovalOptions(m.PreDeployApprovals.ApprovalOptions, m.PostDeployApprovals.ApprovalOptions), "pre_deploy_approval": flattenReleaseDefinitionApprovals(m.PreDeployApprovals), "deploy_step": flattenReleaseDefinitionDeployStep(m.DeployStep), "post_deploy_approval": flattenReleaseDefinitionApprovals(m.PostDeployApprovals), diff --git a/azuredevops/internal/service/release/resource_release_definition_test.go b/azuredevops/internal/service/release/resource_release_definition_test.go index c74cb5583..5f8dc9c00 100644 --- a/azuredevops/internal/service/release/resource_release_definition_test.go +++ b/azuredevops/internal/service/release/resource_release_definition_test.go @@ -25,6 +25,15 @@ var now, _ = time.Parse(time.RFC3339, time.Now().Format(time.RFC3339)) var properties interface{} +var approvalOptions = release.ApprovalOptions{ + RequiredApproverCount: converter.Int(1), + ReleaseCreatorCanBeApprover: converter.Bool(false), + AutoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped: converter.Bool(false), + EnforceIdentityRevalidation: converter.Bool(false), + TimeoutInMinutes: converter.Int(0), + ExecutionOrder: &release.ApprovalExecutionOrderValues.AfterSuccessfulGates, +} + var testReleaseDefinition = release.ReleaseDefinition{ Id: converter.Int(100), Revision: converter.Int(1), @@ -62,6 +71,7 @@ var testReleaseDefinition = release.ReleaseDefinition{ IsAutomated: converter.Bool(true), IsNotificationOn: converter.Bool(false), }}, + ApprovalOptions: &approvalOptions, }, PostDeployApprovals: &release.ReleaseDefinitionApprovals{ Approvals: &[]release.ReleaseDefinitionApprovalStep{{ @@ -70,6 +80,7 @@ var testReleaseDefinition = release.ReleaseDefinition{ IsAutomated: converter.Bool(true), IsNotificationOn: converter.Bool(false), }}, + ApprovalOptions: &approvalOptions, }, DeployStep: &release.ReleaseDefinitionDeployStep{ Id: converter.Int(303), @@ -362,8 +373,11 @@ func TestAzureDevOpsReleaseDefinition_ExpandFlatten_Roundtrip(t *testing.T) { releaseDefinitionAfterRoundTrip, projectID, err := expandReleaseDefinition(resourceData) + sortedExpected := sortReleaseDefinition(testReleaseDefinition) + sortedActual := sortReleaseDefinition(*releaseDefinitionAfterRoundTrip) + require.Nil(t, err) - require.Equal(t, sortReleaseDefinition(testReleaseDefinition), sortReleaseDefinition(*releaseDefinitionAfterRoundTrip)) + require.Equal(t, sortedExpected, sortedActual) require.Equal(t, testReleaseProjectID, projectID) } From 1cf865bb9ad26851ccbee188f11740500a4cf195 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Wed, 9 Sep 2020 14:33:11 -0700 Subject: [PATCH 14/41] update notes --- .../internal/service/release/resource_release_definition.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 588aca1c2..0ff043832 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -33,7 +33,7 @@ Due to the limitation of tf-11115 it is not possible to nest maps. So the workar TODO : Based on the info above any of the Min: 1, Max: 1, items will MOST LIKELY become TypeList instead of TypeSet. TODO : Otherwise a custom schema.Schema.Set function will need to be created to identify them in the set. -This fixes the behaviour of apply. Otherwise sometimes apply marking data as changed because of nexted children. +This fixes the behaviour of apply. Otherwise apply will sometimes result in changes. */ func ResourceReleaseDefinition() *schema.Resource { From c012ef5d0eadc3ab0b3ec08d1c7450202b43266d Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Wed, 9 Sep 2020 15:05:34 -0700 Subject: [PATCH 15/41] remove todo notes --- .../release/resource_release_definition.go | 57 +++---------------- 1 file changed, 8 insertions(+), 49 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 0ff043832..0c45333ff 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -99,18 +99,6 @@ func ResourceReleaseDefinition() *schema.Resource { }, } - // TODO : import these from YAML - //taskInputValidation := map[string]*schema.Schema{ - // "expression": { - // Type: schema.TypeString, - // Required: true, - // }, - // "message": { - // Type: schema.TypeString, - // Optional: true, - // }, - //} - demand := map[string]*schema.Schema{ "name": { Type: schema.TypeString, @@ -662,7 +650,6 @@ func ResourceReleaseDefinition() *schema.Resource { }, }, // TODO : How to solve "ignore" if empty and new is isAutomated? - // NOTE : Currently the compare between Set is not showing partial update but is complete remove and add. } retentionPolicy := &schema.Schema{ @@ -2047,7 +2034,6 @@ func expandReleaseHostedAzurePipelinesSet(d *schema.Set) (*release.AgentSpecific func expandReleaseMachineGroupDeploymentInput(d map[string]interface{}) *release.MachineGroupDeploymentInput { tags := tfhelper.ExpandStringList(d["tags"].([]interface{})) - // TODO : Which demand expansion is correct for this? multiple := expandReleaseMachineGroupDeploymentInputMultipleListFirstOrNil(d["multiple"].([]interface{})) deploymentHealthOption := DeploymentHealthOptionTypeValues.OneTargetAtATime if multiple != nil { @@ -2058,16 +2044,12 @@ func expandReleaseMachineGroupDeploymentInput(d map[string]interface{}) *release JobCancelTimeoutInMinutes: converter.Int(d["max_execution_time_in_minutes"].(int)), OverrideInputs: nil, // TODO : OverrideInputs TimeoutInMinutes: converter.Int(d["timeout_in_minutes"].(int)), - ArtifactsDownloadInput: &release.ArtifactsDownloadInput{ - // DownloadInputs: &downloadInputs, - }, - //Demands: &demands, - EnableAccessToken: converter.Bool(d["allow_scripts_to_access_oauth_token"].(bool)), // TODO : enable_access_token - QueueId: converter.Int(d["deployment_group_id"].(int)), - SkipArtifactsDownload: converter.Bool(d["skip_artifacts_download"].(bool)), - DeploymentHealthOption: converter.String(string(deploymentHealthOption)), - //HealthPercent: - Tags: &tags, + ArtifactsDownloadInput: &release.ArtifactsDownloadInput{}, + EnableAccessToken: converter.Bool(d["allow_scripts_to_access_oauth_token"].(bool)), + QueueId: converter.Int(d["deployment_group_id"].(int)), + SkipArtifactsDownload: converter.Bool(d["skip_artifacts_download"].(bool)), + DeploymentHealthOption: converter.String(string(deploymentHealthOption)), + Tags: &tags, } } func expandReleaseAgentDeploymentInput(d map[string]interface{}) AgentDeploymentInput { @@ -2108,12 +2090,11 @@ func expandReleaseAgentDeploymentInput(d map[string]interface{}) AgentDeployment OverrideInputs: nil, // TODO : OverrideInputs TimeoutInMinutes: converter.Int(d["timeout_in_minutes"].(int)), Demands: &demands, - EnableAccessToken: converter.Bool(d["allow_scripts_to_access_oauth_token"].(bool)), // TODO : enable_access_token + EnableAccessToken: converter.Bool(d["allow_scripts_to_access_oauth_token"].(bool)), QueueID: &queueID, SkipArtifactsDownload: converter.Bool(d["skip_artifacts_download"].(bool)), AgentSpecification: agentSpecification, - // ImageID: , - ParallelExecution: ¶llelExecution, + ParallelExecution: ¶llelExecution, ArtifactsDownloadInput: &release.ArtifactsDownloadInput{ DownloadInputs: &downloadInputs, }, @@ -2382,7 +2363,6 @@ func expandReleaseDefinitionGatesStep(d map[string]interface{}) release.ReleaseD return release.ReleaseDefinitionGatesStep{ Id: converter.Int(d["id"].(int)), Gates: &gates, - // GatesOptions: expandReleaseDefinitionGatesOptionsList(d["gates_options"].([]interface{})), } } func expandReleaseDefinitionGatesStepList(d []interface{}) []release.ReleaseDefinitionGatesStep { @@ -2612,10 +2592,6 @@ func flattenReleaseAgentDeploymentInput(rdp *release.ReleaseDeployPhase, rai *re "skip_artifacts_download": rai.SkipArtifactsDownload, "allow_scripts_to_access_oauth_token": rai.EnableAccessToken, "demand": flattenReleaseDeployPhaseDemandList(rai.Demands), - //"override_inputs": overrideInputs, // rai.OverrideInputs - //"agent_pool_private": "array", // ??? - //"multi_configuration": "array", // ??? - //"multi_agent": "array", // ??? } return d } @@ -2628,27 +2604,10 @@ func flattenReleaseServerInput(rdp *release.ReleaseDeployPhase, rai *release.Ser "timeout_in_minutes": rai.TimeoutInMinutes, "max_execution_time_in_minutes": rai.JobCancelTimeoutInMinutes, "condition": rai.Condition, - //"override_inputs": overrideInputs, // rai.OverrideInputs - //"multi_configuration": "array", // ??? } return d } -func flattenReleaseGatesDeploymentInput(m *release.GatesDeploymentInput) interface{} { - // TODO : - return map[string]interface{}{} -} - -func flattenReleaseMachineGroupDeploymentInput(m *release.MachineGroupDeploymentInput) interface{} { - // TODO : - return map[string]interface{}{} -} - -func flattenReleaseServerDeploymentInput(m *release.ServerDeploymentInput) interface{} { - // TODO : - return map[string]interface{}{} -} - func unmarshalAgentDeploymentInput(deployPhase []byte, agentDeploymentInput []byte, workflowTasks []byte) (*release.ReleaseDeployPhase, *release.AgentDeploymentInput, *[]release.WorkflowTask) { var d release.ReleaseDeployPhase _ = json.Unmarshal(deployPhase, &d) From 53c2c89891fe8e8e2d0e634329817897b69d3d24 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Wed, 9 Sep 2020 16:00:59 -0700 Subject: [PATCH 16/41] fix applying options for "pre" & "post" with unique execution_order --- .../release/resource_release_definition.go | 35 +++++-------------- .../resource_release_definition_test.go | 31 ++++++++++------ 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 0c45333ff..8f9d97e75 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -14,7 +14,6 @@ import ( "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/converter" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/validate" - "log" "regexp" "sort" "strconv" @@ -22,11 +21,6 @@ import ( "time" ) -func Log(i interface{}) { - d, _ := json.MarshalIndent(i, "", " ") - log.Println(string(d)) -} - /* NOTE : https://www.terraform.io/docs/extend/writing-custom-providers.html Due to the limitation of tf-11115 it is not possible to nest maps. So the workaround is to let only the innermost data structure be of the type TypeMap: in this case driver_options. The outer data structures are of TypeList which can only have one item. @@ -254,15 +248,6 @@ func ResourceReleaseDefinition() *schema.Resource { Type: schema.TypeBool, Optional: true, }, - "execution_order": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{ - string(release.ApprovalExecutionOrderValues.AfterGatesAlways), - string(release.ApprovalExecutionOrderValues.AfterSuccessfulGates), - string(release.ApprovalExecutionOrderValues.BeforeGates), - }, false), - }, "release_creator_can_be_approver": { Type: schema.TypeBool, Optional: true, @@ -1676,9 +1661,10 @@ func expandReleaseDefinitionEnvironment(d map[string]interface{}, rank int) rele demands := expandReleaseDefinitionDemandList(d["demand"].([]interface{})) environmentOptions := expandReleaseEnvironmentOptionsListFirstOrNil(d["environment_options"].([]interface{})) retentionPolicy := expandReleaseEnvironmentRetentionPolicyListFirstOrNil(d["retention_policy"].([]interface{})) - approvalOptions := expandReleaseApprovalOptionsListFirstOrNil(d["approval_options"].([]interface{})) - preDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["pre_deploy_approval"].([]interface{}), approvalOptions) - postDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["post_deploy_approval"].([]interface{}), approvalOptions) + preApprovalOptions := expandReleaseApprovalOptionsListFirstOrNil(d["approval_options"].([]interface{}), release.ApprovalExecutionOrderValues.BeforeGates) + postApprovalOptions := expandReleaseApprovalOptionsListFirstOrNil(d["approval_options"].([]interface{}), release.ApprovalExecutionOrderValues.AfterSuccessfulGates) + preDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["pre_deploy_approval"].([]interface{}), preApprovalOptions) + postDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["post_deploy_approval"].([]interface{}), postApprovalOptions) properties := expandReleaseEnvironmentPropertiesListFirstOrNil(d["properties"].([]interface{})) deployPhases := expandJobsList(d["job"].([]interface{})) preDeploymentGates := expandReleaseDefinitionGatesStepListFirstOrNil(d["pre_deploy_gate"].([]interface{})) @@ -2287,8 +2273,7 @@ func expandReleaseDefinitionApprovalStepList(d []interface{}) []release.ReleaseD return vs } -func expandReleaseApprovalOptions(d map[string]interface{}) release.ApprovalOptions { - executionOrder := release.ApprovalExecutionOrder(d["execution_order"].(string)) +func expandReleaseApprovalOptions(d map[string]interface{}, executionOrder release.ApprovalExecutionOrder) release.ApprovalOptions { return release.ApprovalOptions{ AutoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped: converter.Bool(d["auto_triggered_and_previous_environment_approved_can_be_skipped"].(bool)), EnforceIdentityRevalidation: converter.Bool(d["enforce_identity_revalidation"].(bool)), @@ -2298,17 +2283,17 @@ func expandReleaseApprovalOptions(d map[string]interface{}) release.ApprovalOpti TimeoutInMinutes: converter.Int(d["timeout_in_minutes"].(int)), } } -func expandReleaseApprovalOptionsList(d []interface{}) []release.ApprovalOptions { +func expandReleaseApprovalOptionsList(d []interface{}, executionOrder release.ApprovalExecutionOrder) []release.ApprovalOptions { vs := make([]release.ApprovalOptions, 0, len(d)) for _, v := range d { if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseApprovalOptions(val)) + vs = append(vs, expandReleaseApprovalOptions(val, executionOrder)) } } return vs } -func expandReleaseApprovalOptionsListFirstOrNil(d []interface{}) *release.ApprovalOptions { - d2 := expandReleaseApprovalOptionsList(d) +func expandReleaseApprovalOptionsListFirstOrNil(d []interface{}, executionOrder release.ApprovalExecutionOrder) *release.ApprovalOptions { + d2 := expandReleaseApprovalOptionsList(d, executionOrder) if len(d2) != 1 { return nil } @@ -2700,7 +2685,6 @@ func flattenApprovalOptions(m1, m2 *release.ApprovalOptions) []map[string]interf return []map[string]interface{}{{ "auto_triggered_and_previous_environment_approved_can_be_skipped": m.AutoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped, "enforce_identity_revalidation": m.EnforceIdentityRevalidation, - "execution_order": m.ExecutionOrder, "release_creator_can_be_approver": m.ReleaseCreatorCanBeApprover, "required_approver_count": m.RequiredApproverCount, "timeout_in_minutes": m.TimeoutInMinutes, @@ -2868,7 +2852,6 @@ func flattenReleaseDefinitionEnvironmentList(m *[]release.ReleaseDefinitionEnvir }) ds := make([]interface{}, 0, len(*m)) for _, d := range m2 { - Log(d.Rank) ds = append(ds, flattenReleaseDefinitionEnvironment(d)) } return ds diff --git a/azuredevops/internal/service/release/resource_release_definition_test.go b/azuredevops/internal/service/release/resource_release_definition_test.go index 5f8dc9c00..6419e76d8 100644 --- a/azuredevops/internal/service/release/resource_release_definition_test.go +++ b/azuredevops/internal/service/release/resource_release_definition_test.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/microsoft/azure-devops-go-api/azuredevops" "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" + _tmp "github.com/microsoft/terraform-provider-azuredevops/.tmp" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/converter" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" "github.com/stretchr/testify/require" @@ -25,15 +26,6 @@ var now, _ = time.Parse(time.RFC3339, time.Now().Format(time.RFC3339)) var properties interface{} -var approvalOptions = release.ApprovalOptions{ - RequiredApproverCount: converter.Int(1), - ReleaseCreatorCanBeApprover: converter.Bool(false), - AutoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped: converter.Bool(false), - EnforceIdentityRevalidation: converter.Bool(false), - TimeoutInMinutes: converter.Int(0), - ExecutionOrder: &release.ApprovalExecutionOrderValues.AfterSuccessfulGates, -} - var testReleaseDefinition = release.ReleaseDefinition{ Id: converter.Int(100), Revision: converter.Int(1), @@ -71,7 +63,14 @@ var testReleaseDefinition = release.ReleaseDefinition{ IsAutomated: converter.Bool(true), IsNotificationOn: converter.Bool(false), }}, - ApprovalOptions: &approvalOptions, + ApprovalOptions: &release.ApprovalOptions{ + RequiredApproverCount: converter.Int(1), + ReleaseCreatorCanBeApprover: converter.Bool(false), + AutoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped: converter.Bool(false), + EnforceIdentityRevalidation: converter.Bool(false), + TimeoutInMinutes: converter.Int(0), + ExecutionOrder: &release.ApprovalExecutionOrderValues.BeforeGates, + }, }, PostDeployApprovals: &release.ReleaseDefinitionApprovals{ Approvals: &[]release.ReleaseDefinitionApprovalStep{{ @@ -80,7 +79,14 @@ var testReleaseDefinition = release.ReleaseDefinition{ IsAutomated: converter.Bool(true), IsNotificationOn: converter.Bool(false), }}, - ApprovalOptions: &approvalOptions, + ApprovalOptions: &release.ApprovalOptions{ + RequiredApproverCount: converter.Int(1), + ReleaseCreatorCanBeApprover: converter.Bool(false), + AutoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped: converter.Bool(false), + EnforceIdentityRevalidation: converter.Bool(false), + TimeoutInMinutes: converter.Int(0), + ExecutionOrder: &release.ApprovalExecutionOrderValues.AfterSuccessfulGates, + }, }, DeployStep: &release.ReleaseDefinitionDeployStep{ Id: converter.Int(303), @@ -376,6 +382,9 @@ func TestAzureDevOpsReleaseDefinition_ExpandFlatten_Roundtrip(t *testing.T) { sortedExpected := sortReleaseDefinition(testReleaseDefinition) sortedActual := sortReleaseDefinition(*releaseDefinitionAfterRoundTrip) + _tmp.Log(sortedExpected) + _tmp.Log(sortedActual) + require.Nil(t, err) require.Equal(t, sortedExpected, sortedActual) require.Equal(t, testReleaseProjectID, projectID) From dce72a36d953d705d41d7b5669b6576ef8eb9d2a Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Thu, 10 Sep 2020 10:50:35 -0700 Subject: [PATCH 17/41] custom timeout for pre and post --- .../release/resource_release_definition.go | 31 ++++++++++++++----- .../resource_release_definition_test.go | 6 ++-- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 8f9d97e75..5992c7a3e 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -256,7 +256,6 @@ func ResourceReleaseDefinition() *schema.Resource { Type: schema.TypeInt, Optional: true, }, - "timeout_in_minutes": timeoutInMinutes, }, }, } @@ -631,7 +630,8 @@ func ResourceReleaseDefinition() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "approval": approval, + "approval": approval, + "timeout_in_minutes": timeoutInMinutes, }, }, // TODO : How to solve "ignore" if empty and new is isAutomated? @@ -2280,7 +2280,6 @@ func expandReleaseApprovalOptions(d map[string]interface{}, executionOrder relea ExecutionOrder: &executionOrder, ReleaseCreatorCanBeApprover: converter.Bool(d["release_creator_can_be_approver"].(bool)), RequiredApproverCount: converter.Int(d["required_approver_count"].(int)), - TimeoutInMinutes: converter.Int(d["timeout_in_minutes"].(int)), } } func expandReleaseApprovalOptionsList(d []interface{}, executionOrder release.ApprovalExecutionOrder) []release.ApprovalOptions { @@ -2302,6 +2301,10 @@ func expandReleaseApprovalOptionsListFirstOrNil(d []interface{}, executionOrder func expandReleaseDefinitionApprovals(d map[string]interface{}, approvalOptions *release.ApprovalOptions) release.ReleaseDefinitionApprovals { approvals := expandReleaseDefinitionApprovalStepList(d["approval"].([]interface{})) + timeoutInMinutes := converter.Int(d["timeout_in_minutes"].(int)) + if timeoutInMinutes != nil && approvalOptions != nil { + approvalOptions.TimeoutInMinutes = timeoutInMinutes + } return release.ReleaseDefinitionApprovals{ Approvals: &approvals, ApprovalOptions: approvalOptions, @@ -2408,11 +2411,19 @@ func flattenReleaseDefinitionVariables(m *map[string]release.ConfigurationVariab } d := make([]map[string]interface{}, len(*m)) index := 0 - for k, v := range *m { + + keys := make([]string, 0, len(*m)) + for k := range *m { + keys = append(keys, k) + } + sort.Strings(keys) + + for _, k := range keys { + m2 := (*m)[k] d[index] = map[string]interface{}{ "name": k, - "value": converter.ToString(v.Value, ""), - "is_secret": converter.ToBool(v.IsSecret, false), + "value": converter.ToString(m2.Value, ""), + "is_secret": converter.ToBool(m2.IsSecret, false), } index = index + 1 } @@ -2687,13 +2698,17 @@ func flattenApprovalOptions(m1, m2 *release.ApprovalOptions) []map[string]interf "enforce_identity_revalidation": m.EnforceIdentityRevalidation, "release_creator_can_be_approver": m.ReleaseCreatorCanBeApprover, "required_approver_count": m.RequiredApproverCount, - "timeout_in_minutes": m.TimeoutInMinutes, }} } func flattenReleaseDefinitionApprovals(m *release.ReleaseDefinitionApprovals) []map[string]interface{} { + timeoutInMinutes := 0 + if m.ApprovalOptions != nil { + timeoutInMinutes = *m.ApprovalOptions.TimeoutInMinutes + } return []map[string]interface{}{{ - "approval": flattenReleaseDefinitionApprovalStepList(m.Approvals), + "approval": flattenReleaseDefinitionApprovalStepList(m.Approvals), + "timeout_in_minutes": timeoutInMinutes, }} } diff --git a/azuredevops/internal/service/release/resource_release_definition_test.go b/azuredevops/internal/service/release/resource_release_definition_test.go index 6419e76d8..bcc4604fc 100644 --- a/azuredevops/internal/service/release/resource_release_definition_test.go +++ b/azuredevops/internal/service/release/resource_release_definition_test.go @@ -68,7 +68,7 @@ var testReleaseDefinition = release.ReleaseDefinition{ ReleaseCreatorCanBeApprover: converter.Bool(false), AutoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped: converter.Bool(false), EnforceIdentityRevalidation: converter.Bool(false), - TimeoutInMinutes: converter.Int(0), + TimeoutInMinutes: converter.Int(120), ExecutionOrder: &release.ApprovalExecutionOrderValues.BeforeGates, }, }, @@ -84,7 +84,7 @@ var testReleaseDefinition = release.ReleaseDefinition{ ReleaseCreatorCanBeApprover: converter.Bool(false), AutoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped: converter.Bool(false), EnforceIdentityRevalidation: converter.Bool(false), - TimeoutInMinutes: converter.Int(0), + TimeoutInMinutes: converter.Int(60), ExecutionOrder: &release.ApprovalExecutionOrderValues.AfterSuccessfulGates, }, }, @@ -386,7 +386,7 @@ func TestAzureDevOpsReleaseDefinition_ExpandFlatten_Roundtrip(t *testing.T) { _tmp.Log(sortedActual) require.Nil(t, err) - require.Equal(t, sortedExpected, sortedActual) + require.Equal(t, sortedActual, sortedExpected) require.Equal(t, testReleaseProjectID, projectID) } From 89b0bef1238b05467f7235229d786f411cdd4178 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Thu, 10 Sep 2020 13:20:50 -0700 Subject: [PATCH 18/41] add note for required with, remove debug log --- .../internal/service/release/resource_release_definition.go | 1 + .../service/release/resource_release_definition_test.go | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 5992c7a3e..eb2ee6b99 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -634,6 +634,7 @@ func ResourceReleaseDefinition() *schema.Resource { "timeout_in_minutes": timeoutInMinutes, }, }, + // RequiredWith: []string{"stage.$.pre_deploy_approval.0.approval", "stage.$.pre_deploy_approval.0.timeout_in_minutes", "stage.$.post_deploy_approval.0.approval", "stage.$.post_deploy_approval.0.timeout_in_minutes"}}, // TODO : How to solve "ignore" if empty and new is isAutomated? } diff --git a/azuredevops/internal/service/release/resource_release_definition_test.go b/azuredevops/internal/service/release/resource_release_definition_test.go index bcc4604fc..ab67af2f2 100644 --- a/azuredevops/internal/service/release/resource_release_definition_test.go +++ b/azuredevops/internal/service/release/resource_release_definition_test.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/microsoft/azure-devops-go-api/azuredevops" "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" - _tmp "github.com/microsoft/terraform-provider-azuredevops/.tmp" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/converter" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" "github.com/stretchr/testify/require" @@ -382,9 +381,6 @@ func TestAzureDevOpsReleaseDefinition_ExpandFlatten_Roundtrip(t *testing.T) { sortedExpected := sortReleaseDefinition(testReleaseDefinition) sortedActual := sortReleaseDefinition(*releaseDefinitionAfterRoundTrip) - _tmp.Log(sortedExpected) - _tmp.Log(sortedActual) - require.Nil(t, err) require.Equal(t, sortedActual, sortedExpected) require.Equal(t, testReleaseProjectID, projectID) From f785f1d18f87d84ee63fd019c09e5034f2734f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Bart=C3=ADk?= <16442967+marekaf@users.noreply.github.com> Date: Mon, 8 Feb 2021 13:59:02 +0100 Subject: [PATCH 19/41] add new os versions to agent_specification validation (#1) --- .../service/release/resource_release_definition.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index eb2ee6b99..3f171d197 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -3,6 +3,12 @@ package release import ( "encoding/json" "fmt" + "regexp" + "sort" + "strconv" + "strings" + "time" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/microsoft/azure-devops-go-api/azuredevops" @@ -14,11 +20,6 @@ import ( "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/converter" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/validate" - "regexp" - "sort" - "strconv" - "strings" - "time" ) /* @@ -732,8 +733,10 @@ func ResourceReleaseDefinition() *schema.Resource { ValidateFunc: validation.StringInSlice([]string{ "macOS-10.13", "macOS-10.14", + "macOS-10.15", "ubuntu-16.04", "ubuntu-18.04", + "ubuntu-20.04", "vs2015-win2012r2", "vs2017-win2016", "win1803", From d0fdccb5ccea90c360b3277c92a2c8fb4aca0dd6 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Wed, 1 Jun 2022 17:46:27 -0700 Subject: [PATCH 20/41] go fmt --- azuredevops/internal/acceptancetests/testutils/hcl.go | 2 -- azuredevops/provider.go | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/azuredevops/internal/acceptancetests/testutils/hcl.go b/azuredevops/internal/acceptancetests/testutils/hcl.go index 38620c91a..6cc027b15 100644 --- a/azuredevops/internal/acceptancetests/testutils/hcl.go +++ b/azuredevops/internal/acceptancetests/testutils/hcl.go @@ -1196,7 +1196,6 @@ resource "azuredevops_release_definition" "release" { return fmt.Sprintf("%s\n%s", projectResource, releaseDefinitionResource) } - func HclTeamConfiguration(projectName string, teamName string, teamDescription string, teamAdministrators *[]string, teamMembers *[]string) string { var teamResource string projectResource := HclProjectResource(projectName) @@ -1258,4 +1257,3 @@ func HclEnvironmentResource(projectName string, environmentName string) string { projectResource := HclProjectResource(projectName) return fmt.Sprintf("%s\n%s", projectResource, azureEnvironmentResource) } - diff --git a/azuredevops/provider.go b/azuredevops/provider.go index 8e100cbf7..e605a7e85 100644 --- a/azuredevops/provider.go +++ b/azuredevops/provider.go @@ -34,7 +34,7 @@ func Provider() *schema.Provider { "azuredevops_branch_policy_merge_types": branch.ResourceBranchPolicyMergeTypes(), "azuredevops_branch_policy_status_check": branch.ResourceBranchPolicyStatusCheck(), "azuredevops_build_definition": build.ResourceBuildDefinition(), - "azuredevops_release_definition": release.ResourceReleaseDefinition(), + "azuredevops_release_definition": release.ResourceReleaseDefinition(), "azuredevops_project": core.ResourceProject(), "azuredevops_project_features": core.ResourceProjectFeatures(), "azuredevops_project_pipeline_settings": core.ResourceProjectPipelineSettings(), @@ -135,8 +135,8 @@ func providerConfigure(p *schema.Provider) schema.ConfigureContextFunc { terraformVersion = "0.11+compatible" } - client, err := client.GetAzdoClient(d.Get("personal_access_token").(string), d.Get("org_service_url").(string), terraformVersion) + azdoClient, err := client.GetAzdoClient(d.Get("personal_access_token").(string), d.Get("org_service_url").(string), terraformVersion) - return client, diag.FromErr(err) + return azdoClient, diag.FromErr(err) } } From cefc7d2396e22b26b49c45446f0884b983286757 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Wed, 1 Jun 2022 17:46:51 -0700 Subject: [PATCH 21/41] update to latest versions --- .../resource_release_definition_test.go | 1 + .../release/resource_release_definition.go | 10 +++++----- .../release/resource_release_definition_test.go | 16 ++++++++-------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/azuredevops/internal/acceptancetests/resource_release_definition_test.go b/azuredevops/internal/acceptancetests/resource_release_definition_test.go index dc58b04bb..45d917011 100644 --- a/azuredevops/internal/acceptancetests/resource_release_definition_test.go +++ b/azuredevops/internal/acceptancetests/resource_release_definition_test.go @@ -1,3 +1,4 @@ +//go:build (all || resource_release_definition) && !exclude_resource_release_definition // +build all resource_release_definition // +build !exclude_resource_release_definition diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 3f171d197..8f6b0a43c 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -9,11 +9,11 @@ import ( "strings" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - "github.com/microsoft/azure-devops-go-api/azuredevops" - "github.com/microsoft/azure-devops-go-api/azuredevops/release" - "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/microsoft/azure-devops-go-api/azuredevops/v6" + "github.com/microsoft/azure-devops-go-api/azuredevops/v6/release" + "github.com/microsoft/azure-devops-go-api/azuredevops/v6/webapi" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/model" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/service/taskagent" diff --git a/azuredevops/internal/service/release/resource_release_definition_test.go b/azuredevops/internal/service/release/resource_release_definition_test.go index ab67af2f2..9bdb46d90 100644 --- a/azuredevops/internal/service/release/resource_release_definition_test.go +++ b/azuredevops/internal/service/release/resource_release_definition_test.go @@ -3,19 +3,19 @@ package release import ( "encoding/json" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/microsoft/azure-devops-go-api/azuredevops" - "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" - "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/converter" - "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" - "github.com/stretchr/testify/require" "sort" "strings" "testing" "time" "github.com/google/uuid" - "github.com/microsoft/azure-devops-go-api/azuredevops/release" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/microsoft/azure-devops-go-api/azuredevops/v6" + "github.com/microsoft/azure-devops-go-api/azuredevops/v6/release" + "github.com/microsoft/azure-devops-go-api/azuredevops/v6/webapi" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/converter" + "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper" + "github.com/stretchr/testify/require" ) var testReleaseProjectID = uuid.New().String() @@ -161,7 +161,7 @@ var testReleaseDefinition = release.ReleaseDefinition{ Gates: &[]release.ReleaseDefinitionGate{}, }, Owner: &webapi.IdentityRef{ - Id: converter.String(testReleaseProjectID), + Id: converter.String("library"), // Supported values are "library", "agentcloud", }, DeployPhases: &[]interface{}{ From 6eb8ba2c20ad4064b33ebaf19034b6416ab287be Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Wed, 1 Jun 2022 17:55:01 -0700 Subject: [PATCH 22/41] update to latest versions with deps --- .../resource_release_definition_test.go | 2 - azuredevops/internal/model/tags.go | 2 +- .../azuredevops/release/client.go | 1583 +++++++++ .../azuredevops/release/models.go | 3064 +++++++++++++++++ vendor/modules.txt | 1 + 5 files changed, 4649 insertions(+), 3 deletions(-) create mode 100644 vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/client.go create mode 100644 vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/models.go diff --git a/azuredevops/internal/acceptancetests/resource_release_definition_test.go b/azuredevops/internal/acceptancetests/resource_release_definition_test.go index 45d917011..3105f13dd 100644 --- a/azuredevops/internal/acceptancetests/resource_release_definition_test.go +++ b/azuredevops/internal/acceptancetests/resource_release_definition_test.go @@ -10,8 +10,6 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/acceptancetests/testutils" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" ) diff --git a/azuredevops/internal/model/tags.go b/azuredevops/internal/model/tags.go index 284c6a02a..88f4a6497 100644 --- a/azuredevops/internal/model/tags.go +++ b/azuredevops/internal/model/tags.go @@ -1,6 +1,6 @@ package model -import "github.com/hashicorp/terraform-plugin-sdk/helper/schema" +import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" // TagsSchema list of tags var TagsSchema = schema.Schema{ diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/client.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/client.go new file mode 100644 index 000000000..dc6f66b5f --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/client.go @@ -0,0 +1,1583 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package release + +import ( + "bytes" + "context" + "encoding/json" + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "io" + "net/http" + "net/url" + "strconv" + "strings" +) + +var ResourceAreaId, _ = uuid.Parse("efc2f575-36ef-48e9-b672-0c6fb4a48ac5") + +type Client interface { + // [Preview API] Creates a new folder. + CreateFolder(context.Context, CreateFolderArgs) (*Folder, error) + // Create a release. + CreateRelease(context.Context, CreateReleaseArgs) (*Release, error) + // Create a release definition + CreateReleaseDefinition(context.Context, CreateReleaseDefinitionArgs) (*ReleaseDefinition, error) + // [Preview API] Deletes a definition folder for given folder name and path and all it's existing definitions. + DeleteFolder(context.Context, DeleteFolderArgs) error + // Delete a release definition. + DeleteReleaseDefinition(context.Context, DeleteReleaseDefinitionArgs) error + // Get a list of approvals + GetApprovals(context.Context, GetApprovalsArgs) (*GetApprovalsResponseValue, error) + // [Preview API] Get release definition for a given definitionId and revision + GetDefinitionRevision(context.Context, GetDefinitionRevisionArgs) (io.ReadCloser, error) + GetDeployments(context.Context, GetDeploymentsArgs) (*GetDeploymentsResponseValue, error) + // [Preview API] Gets folders. + GetFolders(context.Context, GetFoldersArgs) (*[]Folder, error) + // [Preview API] Get logs for a release Id. + GetLogs(context.Context, GetLogsArgs) (io.ReadCloser, error) + // Get manual intervention for a given release and manual intervention id. + GetManualIntervention(context.Context, GetManualInterventionArgs) (*ManualIntervention, error) + // List all manual interventions for a given release. + GetManualInterventions(context.Context, GetManualInterventionsArgs) (*[]ManualIntervention, error) + // Get a Release + GetRelease(context.Context, GetReleaseArgs) (*Release, error) + // Get a release definition. + GetReleaseDefinition(context.Context, GetReleaseDefinitionArgs) (*ReleaseDefinition, error) + // [Preview API] Get revision history for a release definition + GetReleaseDefinitionHistory(context.Context, GetReleaseDefinitionHistoryArgs) (*[]ReleaseDefinitionRevision, error) + // Get a list of release definitions. + GetReleaseDefinitions(context.Context, GetReleaseDefinitionsArgs) (*GetReleaseDefinitionsResponseValue, error) + // [Preview API] Get a release environment. + GetReleaseEnvironment(context.Context, GetReleaseEnvironmentArgs) (*ReleaseEnvironment, error) + // Get release for a given revision number. + GetReleaseRevision(context.Context, GetReleaseRevisionArgs) (io.ReadCloser, error) + // Get a list of releases + GetReleases(context.Context, GetReleasesArgs) (*GetReleasesResponseValue, error) + // [Preview API] Get a release task attachment. + GetReleaseTaskAttachmentContent(context.Context, GetReleaseTaskAttachmentContentArgs) (io.ReadCloser, error) + // [Preview API] Get the release task attachments. + GetReleaseTaskAttachments(context.Context, GetReleaseTaskAttachmentsArgs) (*[]ReleaseTaskAttachment, error) + // [Preview API] Gets the task log of a release as a plain text file. + GetTaskLog(context.Context, GetTaskLogArgs) (io.ReadCloser, error) + // [Preview API] Updates an existing folder at given existing path. + UpdateFolder(context.Context, UpdateFolderArgs) (*Folder, error) + // [Preview API] Updates the gate for a deployment. + UpdateGates(context.Context, UpdateGatesArgs) (*ReleaseGates, error) + // Update manual intervention. + UpdateManualIntervention(context.Context, UpdateManualInterventionArgs) (*ManualIntervention, error) + // Update a complete release object. + UpdateRelease(context.Context, UpdateReleaseArgs) (*Release, error) + // Update status of an approval + UpdateReleaseApproval(context.Context, UpdateReleaseApprovalArgs) (*ReleaseApproval, error) + // Update a release definition. + UpdateReleaseDefinition(context.Context, UpdateReleaseDefinitionArgs) (*ReleaseDefinition, error) + // [Preview API] Update the status of a release environment + UpdateReleaseEnvironment(context.Context, UpdateReleaseEnvironmentArgs) (*ReleaseEnvironment, error) + // Update few properties of a release. + UpdateReleaseResource(context.Context, UpdateReleaseResourceArgs) (*Release, error) +} + +type ClientImpl struct { + Client azuredevops.Client +} + +func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { + client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) + if err != nil { + return nil, err + } + return &ClientImpl{ + Client: *client, + }, nil +} + +// [Preview API] Creates a new folder. +func (client *ClientImpl) CreateFolder(ctx context.Context, args CreateFolderArgs) (*Folder, error) { + if args.Folder == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Folder"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + body, marshalErr := json.Marshal(*args.Folder) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Folder + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateFolder function +type CreateFolderArgs struct { + // (required) Folder to create. + Folder *Folder + // (required) Project ID or project name + Project *string +} + +// Create a release. +func (client *ClientImpl) CreateRelease(ctx context.Context, args CreateReleaseArgs) (*Release, error) { + if args.ReleaseStartMetadata == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseStartMetadata"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + body, marshalErr := json.Marshal(*args.ReleaseStartMetadata) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Release + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateRelease function +type CreateReleaseArgs struct { + // (required) Metadata to create a release. + ReleaseStartMetadata *ReleaseStartMetadata + // (required) Project ID or project name + Project *string +} + +// Create a release definition +func (client *ClientImpl) CreateReleaseDefinition(ctx context.Context, args CreateReleaseDefinitionArgs) (*ReleaseDefinition, error) { + if args.ReleaseDefinition == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseDefinition"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + body, marshalErr := json.Marshal(*args.ReleaseDefinition) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") + resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ReleaseDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the CreateReleaseDefinition function +type CreateReleaseDefinitionArgs struct { + // (required) release definition object to create. + ReleaseDefinition *ReleaseDefinition + // (required) Project ID or project name + Project *string +} + +// [Preview API] Deletes a definition folder for given folder name and path and all it's existing definitions. +func (client *ClientImpl) DeleteFolder(ctx context.Context, args DeleteFolderArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Path == nil || *args.Path == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Path"} + } + routeValues["path"] = *args.Path + + locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.2", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteFolder function +type DeleteFolderArgs struct { + // (required) Project ID or project name + Project *string + // (required) Path of the folder to delete. + Path *string +} + +// Delete a release definition. +func (client *ClientImpl) DeleteReleaseDefinition(ctx context.Context, args DeleteReleaseDefinitionArgs) error { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DefinitionId == nil { + return &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + queryParams := url.Values{} + if args.Comment != nil { + queryParams.Add("comment", *args.Comment) + } + if args.ForceDelete != nil { + queryParams.Add("forceDelete", strconv.FormatBool(*args.ForceDelete)) + } + locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") + _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return err + } + + return nil +} + +// Arguments for the DeleteReleaseDefinition function +type DeleteReleaseDefinitionArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release definition. + DefinitionId *int + // (optional) Comment for deleting a release definition. + Comment *string + // (optional) 'true' to automatically cancel any in-progress release deployments and proceed with release definition deletion . Default is 'false'. + ForceDelete *bool +} + +// Get a list of approvals +func (client *ClientImpl) GetApprovals(ctx context.Context, args GetApprovalsArgs) (*GetApprovalsResponseValue, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + queryParams := url.Values{} + if args.AssignedToFilter != nil { + queryParams.Add("assignedToFilter", *args.AssignedToFilter) + } + if args.StatusFilter != nil { + queryParams.Add("statusFilter", string(*args.StatusFilter)) + } + if args.ReleaseIdsFilter != nil { + var stringList []string + for _, item := range *args.ReleaseIdsFilter { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("releaseIdsFilter", listAsString) + } + if args.TypeFilter != nil { + queryParams.Add("typeFilter", string(*args.TypeFilter)) + } + if args.Top != nil { + queryParams.Add("top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", strconv.Itoa(*args.ContinuationToken)) + } + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + if args.IncludeMyGroupApprovals != nil { + queryParams.Add("includeMyGroupApprovals", strconv.FormatBool(*args.IncludeMyGroupApprovals)) + } + locationId, _ := uuid.Parse("b47c6458-e73b-47cb-a770-4df1e8813a91") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GetApprovalsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetApprovals function +type GetApprovalsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Approvals assigned to this user. + AssignedToFilter *string + // (optional) Approvals with this status. Default is 'pending'. + StatusFilter *ApprovalStatus + // (optional) Approvals for release id(s) mentioned in the filter. Multiple releases can be mentioned by separating them with ',' e.g. releaseIdsFilter=1,2,3,4. + ReleaseIdsFilter *[]int + // (optional) Approval with this type. + TypeFilter *ApprovalType + // (optional) Number of approvals to get. Default is 50. + Top *int + // (optional) Gets the approvals after the continuation token provided. + ContinuationToken *int + // (optional) Gets the results in the defined order of created approvals. Default is 'descending'. + QueryOrder *ReleaseQueryOrder + // (optional) 'true' to include my group approvals. Default is 'false'. + IncludeMyGroupApprovals *bool +} + +// Return type for the GetApprovals function +type GetApprovalsResponseValue struct { + Value []ReleaseApproval + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Get release definition for a given definitionId and revision +func (client *ClientImpl) GetDefinitionRevision(ctx context.Context, args GetDefinitionRevisionArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + if args.Revision == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Revision"} + } + routeValues["revision"] = strconv.Itoa(*args.Revision) + + locationId, _ := uuid.Parse("258b82e0-9d41-43f3-86d6-fef14ddd44bc") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "text/plain", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetDefinitionRevision function +type GetDefinitionRevisionArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the definition. + DefinitionId *int + // (required) Id of the revision. + Revision *int +} + +func (client *ClientImpl) GetDeployments(ctx context.Context, args GetDeploymentsArgs) (*GetDeploymentsResponseValue, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + queryParams := url.Values{} + if args.DefinitionId != nil { + queryParams.Add("definitionId", strconv.Itoa(*args.DefinitionId)) + } + if args.DefinitionEnvironmentId != nil { + queryParams.Add("definitionEnvironmentId", strconv.Itoa(*args.DefinitionEnvironmentId)) + } + if args.CreatedBy != nil { + queryParams.Add("createdBy", *args.CreatedBy) + } + if args.MinModifiedTime != nil { + queryParams.Add("minModifiedTime", (*args.MinModifiedTime).AsQueryParameter()) + } + if args.MaxModifiedTime != nil { + queryParams.Add("maxModifiedTime", (*args.MaxModifiedTime).AsQueryParameter()) + } + if args.DeploymentStatus != nil { + queryParams.Add("deploymentStatus", string(*args.DeploymentStatus)) + } + if args.OperationStatus != nil { + queryParams.Add("operationStatus", string(*args.OperationStatus)) + } + if args.LatestAttemptsOnly != nil { + queryParams.Add("latestAttemptsOnly", strconv.FormatBool(*args.LatestAttemptsOnly)) + } + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", strconv.Itoa(*args.ContinuationToken)) + } + if args.CreatedFor != nil { + queryParams.Add("createdFor", *args.CreatedFor) + } + if args.MinStartedTime != nil { + queryParams.Add("minStartedTime", (*args.MinStartedTime).AsQueryParameter()) + } + if args.MaxStartedTime != nil { + queryParams.Add("maxStartedTime", (*args.MaxStartedTime).AsQueryParameter()) + } + if args.SourceBranch != nil { + queryParams.Add("sourceBranch", *args.SourceBranch) + } + locationId, _ := uuid.Parse("b005ef73-cddc-448e-9ba2-5193bf36b19f") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GetDeploymentsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetDeployments function +type GetDeploymentsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) + DefinitionId *int + // (optional) + DefinitionEnvironmentId *int + // (optional) + CreatedBy *string + // (optional) + MinModifiedTime *azuredevops.Time + // (optional) + MaxModifiedTime *azuredevops.Time + // (optional) + DeploymentStatus *DeploymentStatus + // (optional) + OperationStatus *DeploymentOperationStatus + // (optional) + LatestAttemptsOnly *bool + // (optional) + QueryOrder *ReleaseQueryOrder + // (optional) + Top *int + // (optional) + ContinuationToken *int + // (optional) + CreatedFor *string + // (optional) + MinStartedTime *azuredevops.Time + // (optional) + MaxStartedTime *azuredevops.Time + // (optional) + SourceBranch *string +} + +// Return type for the GetDeployments function +type GetDeploymentsResponseValue struct { + Value []Deployment + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Gets folders. +func (client *ClientImpl) GetFolders(ctx context.Context, args GetFoldersArgs) (*[]Folder, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Path != nil && *args.Path != "" { + routeValues["path"] = *args.Path + } + + queryParams := url.Values{} + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []Folder + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetFolders function +type GetFoldersArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Path of the folder. + Path *string + // (optional) Gets the results in the defined order. Default is 'None'. + QueryOrder *FolderPathQueryOrder +} + +// [Preview API] Get logs for a release Id. +func (client *ClientImpl) GetLogs(ctx context.Context, args GetLogsArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + + locationId, _ := uuid.Parse("c37fbab5-214b-48e4-a55b-cb6b4f6e4038") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, nil, nil, "", "application/zip", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetLogs function +type GetLogsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int +} + +// Get manual intervention for a given release and manual intervention id. +func (client *ClientImpl) GetManualIntervention(ctx context.Context, args GetManualInterventionArgs) (*ManualIntervention, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.ManualInterventionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ManualInterventionId"} + } + routeValues["manualInterventionId"] = strconv.Itoa(*args.ManualInterventionId) + + locationId, _ := uuid.Parse("616c46e4-f370-4456-adaa-fbaf79c7b79e") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ManualIntervention + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetManualIntervention function +type GetManualInterventionArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of the manual intervention. + ManualInterventionId *int +} + +// List all manual interventions for a given release. +func (client *ClientImpl) GetManualInterventions(ctx context.Context, args GetManualInterventionsArgs) (*[]ManualIntervention, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + + locationId, _ := uuid.Parse("616c46e4-f370-4456-adaa-fbaf79c7b79e") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []ManualIntervention + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetManualInterventions function +type GetManualInterventionsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int +} + +// Get a Release +func (client *ClientImpl) GetRelease(ctx context.Context, args GetReleaseArgs) (*Release, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + + queryParams := url.Values{} + if args.ApprovalFilters != nil { + queryParams.Add("approvalFilters", string(*args.ApprovalFilters)) + } + if args.PropertyFilters != nil { + listAsString := strings.Join((*args.PropertyFilters)[:], ",") + queryParams.Add("propertyFilters", listAsString) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.TopGateRecords != nil { + queryParams.Add("$topGateRecords", strconv.Itoa(*args.TopGateRecords)) + } + locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Release + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetRelease function +type GetReleaseArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (optional) A filter which would allow fetching approval steps selectively based on whether it is automated, or manual. This would also decide whether we should fetch pre and post approval snapshots. Assumes All by default + ApprovalFilters *ApprovalFilters + // (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Release will contain values for the specified property Ids (if they exist). If not set, properties will not be included. + PropertyFilters *[]string + // (optional) A property that should be expanded in the release. + Expand *SingleReleaseExpands + // (optional) Number of release gate records to get. Default is 5. + TopGateRecords *int +} + +// Get a release definition. +func (client *ClientImpl) GetReleaseDefinition(ctx context.Context, args GetReleaseDefinitionArgs) (*ReleaseDefinition, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + queryParams := url.Values{} + if args.PropertyFilters != nil { + listAsString := strings.Join((*args.PropertyFilters)[:], ",") + queryParams.Add("propertyFilters", listAsString) + } + locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ReleaseDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetReleaseDefinition function +type GetReleaseDefinitionArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release definition. + DefinitionId *int + // (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Release Definition will contain values for the specified property Ids (if they exist). If not set, properties will not be included. + PropertyFilters *[]string +} + +// [Preview API] Get revision history for a release definition +func (client *ClientImpl) GetReleaseDefinitionHistory(ctx context.Context, args GetReleaseDefinitionHistoryArgs) (*[]ReleaseDefinitionRevision, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.DefinitionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} + } + routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) + + locationId, _ := uuid.Parse("258b82e0-9d41-43f3-86d6-fef14ddd44bc") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []ReleaseDefinitionRevision + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetReleaseDefinitionHistory function +type GetReleaseDefinitionHistoryArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the definition. + DefinitionId *int +} + +// Get a list of release definitions. +func (client *ClientImpl) GetReleaseDefinitions(ctx context.Context, args GetReleaseDefinitionsArgs) (*GetReleaseDefinitionsResponseValue, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + queryParams := url.Values{} + if args.SearchText != nil { + queryParams.Add("searchText", *args.SearchText) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.ArtifactType != nil { + queryParams.Add("artifactType", *args.ArtifactType) + } + if args.ArtifactSourceId != nil { + queryParams.Add("artifactSourceId", *args.ArtifactSourceId) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", *args.ContinuationToken) + } + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + if args.Path != nil { + queryParams.Add("path", *args.Path) + } + if args.IsExactNameMatch != nil { + queryParams.Add("isExactNameMatch", strconv.FormatBool(*args.IsExactNameMatch)) + } + if args.TagFilter != nil { + listAsString := strings.Join((*args.TagFilter)[:], ",") + queryParams.Add("tagFilter", listAsString) + } + if args.PropertyFilters != nil { + listAsString := strings.Join((*args.PropertyFilters)[:], ",") + queryParams.Add("propertyFilters", listAsString) + } + if args.DefinitionIdFilter != nil { + listAsString := strings.Join((*args.DefinitionIdFilter)[:], ",") + queryParams.Add("definitionIdFilter", listAsString) + } + if args.IsDeleted != nil { + queryParams.Add("isDeleted", strconv.FormatBool(*args.IsDeleted)) + } + if args.SearchTextContainsFolderName != nil { + queryParams.Add("searchTextContainsFolderName", strconv.FormatBool(*args.SearchTextContainsFolderName)) + } + locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GetReleaseDefinitionsResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetReleaseDefinitions function +type GetReleaseDefinitionsArgs struct { + // (required) Project ID or project name + Project *string + // (optional) Get release definitions with names containing searchText. + SearchText *string + // (optional) The properties that should be expanded in the list of Release definitions. + Expand *ReleaseDefinitionExpands + // (optional) Release definitions with given artifactType will be returned. Values can be Build, Jenkins, GitHub, Nuget, Team Build (external), ExternalTFSBuild, Git, TFVC, ExternalTfsXamlBuild. + ArtifactType *string + // (optional) Release definitions with given artifactSourceId will be returned. e.g. For build it would be {projectGuid}:{BuildDefinitionId}, for Jenkins it would be {JenkinsConnectionId}:{JenkinsDefinitionId}, for TfsOnPrem it would be {TfsOnPremConnectionId}:{ProjectName}:{TfsOnPremDefinitionId}. For third-party artifacts e.g. TeamCity, BitBucket you may refer 'uniqueSourceIdentifier' inside vss-extension.json at https://github.com/Microsoft/vsts-rm-extensions/blob/master/Extensions. + ArtifactSourceId *string + // (optional) Number of release definitions to get. + Top *int + // (optional) Gets the release definitions after the continuation token provided. + ContinuationToken *string + // (optional) Gets the results in the defined order. Default is 'IdAscending'. + QueryOrder *ReleaseDefinitionQueryOrder + // (optional) Gets the release definitions under the specified path. + Path *string + // (optional) 'true'to gets the release definitions with exact match as specified in searchText. Default is 'false'. + IsExactNameMatch *bool + // (optional) A comma-delimited list of tags. Only release definitions with these tags will be returned. + TagFilter *[]string + // (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Release Definitions will contain values for the specified property Ids (if they exist). If not set, properties will not be included. Note that this will not filter out any Release Definition from results irrespective of whether it has property set or not. + PropertyFilters *[]string + // (optional) A comma-delimited list of release definitions to retrieve. + DefinitionIdFilter *[]string + // (optional) 'true' to get release definitions that has been deleted. Default is 'false' + IsDeleted *bool + // (optional) 'true' to get the release definitions under the folder with name as specified in searchText. Default is 'false'. + SearchTextContainsFolderName *bool +} + +// Return type for the GetReleaseDefinitions function +type GetReleaseDefinitionsResponseValue struct { + Value []ReleaseDefinition + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Get a release environment. +func (client *ClientImpl) GetReleaseEnvironment(ctx context.Context, args GetReleaseEnvironmentArgs) (*ReleaseEnvironment, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.EnvironmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} + } + routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) + + locationId, _ := uuid.Parse("a7e426b1-03dc-48af-9dfe-c98bac612dcb") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.6", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ReleaseEnvironment + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetReleaseEnvironment function +type GetReleaseEnvironmentArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of the release environment. + EnvironmentId *int +} + +// Get release for a given revision number. +func (client *ClientImpl) GetReleaseRevision(ctx context.Context, args GetReleaseRevisionArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + + queryParams := url.Values{} + if args.DefinitionSnapshotRevision == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "definitionSnapshotRevision"} + } + queryParams.Add("definitionSnapshotRevision", strconv.Itoa(*args.DefinitionSnapshotRevision)) + locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "text/plain", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetReleaseRevision function +type GetReleaseRevisionArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Definition snapshot revision number. + DefinitionSnapshotRevision *int +} + +// Get a list of releases +func (client *ClientImpl) GetReleases(ctx context.Context, args GetReleasesArgs) (*GetReleasesResponseValue, error) { + routeValues := make(map[string]string) + if args.Project != nil && *args.Project != "" { + routeValues["project"] = *args.Project + } + + queryParams := url.Values{} + if args.DefinitionId != nil { + queryParams.Add("definitionId", strconv.Itoa(*args.DefinitionId)) + } + if args.DefinitionEnvironmentId != nil { + queryParams.Add("definitionEnvironmentId", strconv.Itoa(*args.DefinitionEnvironmentId)) + } + if args.SearchText != nil { + queryParams.Add("searchText", *args.SearchText) + } + if args.CreatedBy != nil { + queryParams.Add("createdBy", *args.CreatedBy) + } + if args.StatusFilter != nil { + queryParams.Add("statusFilter", string(*args.StatusFilter)) + } + if args.EnvironmentStatusFilter != nil { + queryParams.Add("environmentStatusFilter", strconv.Itoa(*args.EnvironmentStatusFilter)) + } + if args.MinCreatedTime != nil { + queryParams.Add("minCreatedTime", (*args.MinCreatedTime).AsQueryParameter()) + } + if args.MaxCreatedTime != nil { + queryParams.Add("maxCreatedTime", (*args.MaxCreatedTime).AsQueryParameter()) + } + if args.QueryOrder != nil { + queryParams.Add("queryOrder", string(*args.QueryOrder)) + } + if args.Top != nil { + queryParams.Add("$top", strconv.Itoa(*args.Top)) + } + if args.ContinuationToken != nil { + queryParams.Add("continuationToken", strconv.Itoa(*args.ContinuationToken)) + } + if args.Expand != nil { + queryParams.Add("$expand", string(*args.Expand)) + } + if args.ArtifactTypeId != nil { + queryParams.Add("artifactTypeId", *args.ArtifactTypeId) + } + if args.SourceId != nil { + queryParams.Add("sourceId", *args.SourceId) + } + if args.ArtifactVersionId != nil { + queryParams.Add("artifactVersionId", *args.ArtifactVersionId) + } + if args.SourceBranchFilter != nil { + queryParams.Add("sourceBranchFilter", *args.SourceBranchFilter) + } + if args.IsDeleted != nil { + queryParams.Add("isDeleted", strconv.FormatBool(*args.IsDeleted)) + } + if args.TagFilter != nil { + listAsString := strings.Join((*args.TagFilter)[:], ",") + queryParams.Add("tagFilter", listAsString) + } + if args.PropertyFilters != nil { + listAsString := strings.Join((*args.PropertyFilters)[:], ",") + queryParams.Add("propertyFilters", listAsString) + } + if args.ReleaseIdFilter != nil { + var stringList []string + for _, item := range *args.ReleaseIdFilter { + stringList = append(stringList, strconv.Itoa(item)) + } + listAsString := strings.Join((stringList)[:], ",") + queryParams.Add("releaseIdFilter", listAsString) + } + if args.Path != nil { + queryParams.Add("path", *args.Path) + } + locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue GetReleasesResponseValue + responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) + err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) + return &responseValue, err +} + +// Arguments for the GetReleases function +type GetReleasesArgs struct { + // (optional) Project ID or project name + Project *string + // (optional) Releases from this release definition Id. + DefinitionId *int + // (optional) + DefinitionEnvironmentId *int + // (optional) Releases with names containing searchText. + SearchText *string + // (optional) Releases created by this user. + CreatedBy *string + // (optional) Releases that have this status. + StatusFilter *ReleaseStatus + // (optional) + EnvironmentStatusFilter *int + // (optional) Releases that were created after this time. + MinCreatedTime *azuredevops.Time + // (optional) Releases that were created before this time. + MaxCreatedTime *azuredevops.Time + // (optional) Gets the results in the defined order of created date for releases. Default is descending. + QueryOrder *ReleaseQueryOrder + // (optional) Number of releases to get. Default is 50. + Top *int + // (optional) Gets the releases after the continuation token provided. + ContinuationToken *int + // (optional) The property that should be expanded in the list of releases. + Expand *ReleaseExpands + // (optional) Releases with given artifactTypeId will be returned. Values can be Build, Jenkins, GitHub, Nuget, Team Build (external), ExternalTFSBuild, Git, TFVC, ExternalTfsXamlBuild. + ArtifactTypeId *string + // (optional) Unique identifier of the artifact used. e.g. For build it would be {projectGuid}:{BuildDefinitionId}, for Jenkins it would be {JenkinsConnectionId}:{JenkinsDefinitionId}, for TfsOnPrem it would be {TfsOnPremConnectionId}:{ProjectName}:{TfsOnPremDefinitionId}. For third-party artifacts e.g. TeamCity, BitBucket you may refer 'uniqueSourceIdentifier' inside vss-extension.json https://github.com/Microsoft/vsts-rm-extensions/blob/master/Extensions. + SourceId *string + // (optional) Releases with given artifactVersionId will be returned. E.g. in case of Build artifactType, it is buildId. + ArtifactVersionId *string + // (optional) Releases with given sourceBranchFilter will be returned. + SourceBranchFilter *string + // (optional) Gets the soft deleted releases, if true. + IsDeleted *bool + // (optional) A comma-delimited list of tags. Only releases with these tags will be returned. + TagFilter *[]string + // (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Releases will contain values for the specified property Ids (if they exist). If not set, properties will not be included. Note that this will not filter out any Release from results irrespective of whether it has property set or not. + PropertyFilters *[]string + // (optional) A comma-delimited list of releases Ids. Only releases with these Ids will be returned. + ReleaseIdFilter *[]int + // (optional) Releases under this folder path will be returned + Path *string +} + +// Return type for the GetReleases function +type GetReleasesResponseValue struct { + Value []Release + // The continuation token to be used to get the next page of results. + ContinuationToken string +} + +// [Preview API] Get a release task attachment. +func (client *ClientImpl) GetReleaseTaskAttachmentContent(ctx context.Context, args GetReleaseTaskAttachmentContentArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.EnvironmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} + } + routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) + if args.AttemptId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttemptId"} + } + routeValues["attemptId"] = strconv.Itoa(*args.AttemptId) + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.TimelineId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TimelineId"} + } + routeValues["timelineId"] = (*args.TimelineId).String() + if args.RecordId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RecordId"} + } + routeValues["recordId"] = (*args.RecordId).String() + if args.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + if args.Name == nil || *args.Name == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} + } + routeValues["name"] = *args.Name + + locationId, _ := uuid.Parse("60b86efb-7b8c-4853-8f9f-aa142b77b479") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/octet-stream", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetReleaseTaskAttachmentContent function +type GetReleaseTaskAttachmentContentArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of the release environment. + EnvironmentId *int + // (required) Attempt number of deployment. + AttemptId *int + // (required) Plan Id of the deploy phase. + PlanId *uuid.UUID + // (required) Timeline Id of the task. + TimelineId *uuid.UUID + // (required) Record Id of attachment. + RecordId *uuid.UUID + // (required) Type of the attachment. + Type *string + // (required) Name of the attachment. + Name *string +} + +// [Preview API] Get the release task attachments. +func (client *ClientImpl) GetReleaseTaskAttachments(ctx context.Context, args GetReleaseTaskAttachmentsArgs) (*[]ReleaseTaskAttachment, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.EnvironmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} + } + routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) + if args.AttemptId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttemptId"} + } + routeValues["attemptId"] = strconv.Itoa(*args.AttemptId) + if args.PlanId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} + } + routeValues["planId"] = (*args.PlanId).String() + if args.Type == nil || *args.Type == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} + } + routeValues["type"] = *args.Type + + locationId, _ := uuid.Parse("a4d06688-0dfa-4895-82a5-f43ec9452306") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue []ReleaseTaskAttachment + err = client.Client.UnmarshalCollectionBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the GetReleaseTaskAttachments function +type GetReleaseTaskAttachmentsArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of the release environment. + EnvironmentId *int + // (required) Attempt number of deployment. + AttemptId *int + // (required) Plan Id of the deploy phase. + PlanId *uuid.UUID + // (required) Type of the attachment. + Type *string +} + +// [Preview API] Gets the task log of a release as a plain text file. +func (client *ClientImpl) GetTaskLog(ctx context.Context, args GetTaskLogArgs) (io.ReadCloser, error) { + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.EnvironmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} + } + routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) + if args.ReleaseDeployPhaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseDeployPhaseId"} + } + routeValues["releaseDeployPhaseId"] = strconv.Itoa(*args.ReleaseDeployPhaseId) + if args.TaskId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TaskId"} + } + routeValues["taskId"] = strconv.Itoa(*args.TaskId) + + queryParams := url.Values{} + if args.StartLine != nil { + queryParams.Add("startLine", strconv.FormatUint(*args.StartLine, 10)) + } + if args.EndLine != nil { + queryParams.Add("endLine", strconv.FormatUint(*args.EndLine, 10)) + } + locationId, _ := uuid.Parse("17c91af7-09fd-4256-bff1-c24ee4f73bc0") + resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "text/plain", nil) + if err != nil { + return nil, err + } + + return resp.Body, err +} + +// Arguments for the GetTaskLog function +type GetTaskLogArgs struct { + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of release environment. + EnvironmentId *int + // (required) Release deploy phase Id. + ReleaseDeployPhaseId *int + // (required) ReleaseTask Id for the log. + TaskId *int + // (optional) Starting line number for logs + StartLine *uint64 + // (optional) Ending line number for logs + EndLine *uint64 +} + +// [Preview API] Updates an existing folder at given existing path. +func (client *ClientImpl) UpdateFolder(ctx context.Context, args UpdateFolderArgs) (*Folder, error) { + if args.Folder == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Folder"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.Path == nil || *args.Path == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Path"} + } + routeValues["path"] = *args.Path + + body, marshalErr := json.Marshal(*args.Folder) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Folder + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateFolder function +type UpdateFolderArgs struct { + // (required) folder. + Folder *Folder + // (required) Project ID or project name + Project *string + // (required) Path of the folder to update. + Path *string +} + +// [Preview API] Updates the gate for a deployment. +func (client *ClientImpl) UpdateGates(ctx context.Context, args UpdateGatesArgs) (*ReleaseGates, error) { + if args.GateUpdateMetadata == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GateUpdateMetadata"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.GateStepId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GateStepId"} + } + routeValues["gateStepId"] = strconv.Itoa(*args.GateStepId) + + body, marshalErr := json.Marshal(*args.GateUpdateMetadata) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("2666a539-2001-4f80-bcc7-0379956749d4") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ReleaseGates + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateGates function +type UpdateGatesArgs struct { + // (required) Metadata to patch the Release Gates. + GateUpdateMetadata *GateUpdateMetadata + // (required) Project ID or project name + Project *string + // (required) Gate step Id. + GateStepId *int +} + +// Update manual intervention. +func (client *ClientImpl) UpdateManualIntervention(ctx context.Context, args UpdateManualInterventionArgs) (*ManualIntervention, error) { + if args.ManualInterventionUpdateMetadata == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ManualInterventionUpdateMetadata"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.ManualInterventionId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ManualInterventionId"} + } + routeValues["manualInterventionId"] = strconv.Itoa(*args.ManualInterventionId) + + body, marshalErr := json.Marshal(*args.ManualInterventionUpdateMetadata) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("616c46e4-f370-4456-adaa-fbaf79c7b79e") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ManualIntervention + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateManualIntervention function +type UpdateManualInterventionArgs struct { + // (required) Meta data to update manual intervention. + ManualInterventionUpdateMetadata *ManualInterventionUpdateMetadata + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of the manual intervention. + ManualInterventionId *int +} + +// Update a complete release object. +func (client *ClientImpl) UpdateRelease(ctx context.Context, args UpdateReleaseArgs) (*Release, error) { + if args.Release == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Release"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + + body, marshalErr := json.Marshal(*args.Release) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Release + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateRelease function +type UpdateReleaseArgs struct { + // (required) Release object for update. + Release *Release + // (required) Project ID or project name + Project *string + // (required) Id of the release to update. + ReleaseId *int +} + +// Update status of an approval +func (client *ClientImpl) UpdateReleaseApproval(ctx context.Context, args UpdateReleaseApprovalArgs) (*ReleaseApproval, error) { + if args.Approval == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Approval"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ApprovalId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ApprovalId"} + } + routeValues["approvalId"] = strconv.Itoa(*args.ApprovalId) + + body, marshalErr := json.Marshal(*args.Approval) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("9328e074-59fb-465a-89d9-b09c82ee5109") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ReleaseApproval + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateReleaseApproval function +type UpdateReleaseApprovalArgs struct { + // (required) ReleaseApproval object having status, approver and comments. + Approval *ReleaseApproval + // (required) Project ID or project name + Project *string + // (required) Id of the approval. + ApprovalId *int +} + +// Update a release definition. +func (client *ClientImpl) UpdateReleaseDefinition(ctx context.Context, args UpdateReleaseDefinitionArgs) (*ReleaseDefinition, error) { + if args.ReleaseDefinition == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseDefinition"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + + body, marshalErr := json.Marshal(*args.ReleaseDefinition) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") + resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ReleaseDefinition + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateReleaseDefinition function +type UpdateReleaseDefinitionArgs struct { + // (required) Release definition object to update. + ReleaseDefinition *ReleaseDefinition + // (required) Project ID or project name + Project *string +} + +// [Preview API] Update the status of a release environment +func (client *ClientImpl) UpdateReleaseEnvironment(ctx context.Context, args UpdateReleaseEnvironmentArgs) (*ReleaseEnvironment, error) { + if args.EnvironmentUpdateData == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentUpdateData"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + if args.EnvironmentId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} + } + routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) + + body, marshalErr := json.Marshal(*args.EnvironmentUpdateData) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a7e426b1-03dc-48af-9dfe-c98bac612dcb") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.6", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue ReleaseEnvironment + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateReleaseEnvironment function +type UpdateReleaseEnvironmentArgs struct { + // (required) Environment update meta data. + EnvironmentUpdateData *ReleaseEnvironmentUpdateMetadata + // (required) Project ID or project name + Project *string + // (required) Id of the release. + ReleaseId *int + // (required) Id of release environment. + EnvironmentId *int +} + +// Update few properties of a release. +func (client *ClientImpl) UpdateReleaseResource(ctx context.Context, args UpdateReleaseResourceArgs) (*Release, error) { + if args.ReleaseUpdateMetadata == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseUpdateMetadata"} + } + routeValues := make(map[string]string) + if args.Project == nil || *args.Project == "" { + return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} + } + routeValues["project"] = *args.Project + if args.ReleaseId == nil { + return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} + } + routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) + + body, marshalErr := json.Marshal(*args.ReleaseUpdateMetadata) + if marshalErr != nil { + return nil, marshalErr + } + locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") + resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) + if err != nil { + return nil, err + } + + var responseValue Release + err = client.Client.UnmarshalBody(resp, &responseValue) + return &responseValue, err +} + +// Arguments for the UpdateReleaseResource function +type UpdateReleaseResourceArgs struct { + // (required) Properties of release to update. + ReleaseUpdateMetadata *ReleaseUpdateMetadata + // (required) Project ID or project name + Project *string + // (required) Id of the release to update. + ReleaseId *int +} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/models.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/models.go new file mode 100644 index 000000000..f505e8c92 --- /dev/null +++ b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/models.go @@ -0,0 +1,3064 @@ +// -------------------------------------------------------------------------------------------- +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// -------------------------------------------------------------------------------------------- +// Generated file, DO NOT EDIT +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// -------------------------------------------------------------------------------------------- + +package release + +import ( + "github.com/google/uuid" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/microsoft/azure-devops-go-api/azuredevops/distributedtaskcommon" + "github.com/microsoft/azure-devops-go-api/azuredevops/forminput" + "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" +) + +type AgentArtifactDefinition struct { + // Gets or sets the artifact definition alias. + Alias *string `json:"alias,omitempty"` + // Gets or sets the artifact type. + ArtifactType *AgentArtifactType `json:"artifactType,omitempty"` + // Gets or sets the artifact definition details. + Details *string `json:"details,omitempty"` + // Gets or sets the name of artifact definition. + Name *string `json:"name,omitempty"` + // Gets or sets the version of artifact definition. + Version *string `json:"version,omitempty"` +} + +type AgentArtifactType string + +type agentArtifactTypeValuesType struct { + XamlBuild AgentArtifactType + Build AgentArtifactType + Jenkins AgentArtifactType + FileShare AgentArtifactType + Nuget AgentArtifactType + TfsOnPrem AgentArtifactType + GitHub AgentArtifactType + TfGit AgentArtifactType + ExternalTfsBuild AgentArtifactType + Custom AgentArtifactType + Tfvc AgentArtifactType +} + +var AgentArtifactTypeValues = agentArtifactTypeValuesType{ + // Indicates XamlBuild artifact + XamlBuild: "xamlBuild", + // Indicates Build artifact + Build: "build", + // Indicates Jenkins artifact + Jenkins: "jenkins", + // Indicates FileShare artifact + FileShare: "fileShare", + // Indicates Nuget artifact + Nuget: "nuget", + // Indicates TfsOnPrem artifact + TfsOnPrem: "tfsOnPrem", + // Indicates GitHub artifact + GitHub: "gitHub", + // Indicates TFGit artifact + TfGit: "tfGit", + // Indicates ExternalTfsBuild artifact + ExternalTfsBuild: "externalTfsBuild", + // Indicates Custom artifact + Custom: "custom", + // Indicates Tfvc artifact + Tfvc: "tfvc", +} + +type AgentBasedDeployPhase struct { + // Gets and sets the name of deploy phase. + Name *string `json:"name,omitempty"` + // Indicates the deploy phase type. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Gets and sets the rank of deploy phase. + Rank *int `json:"rank,omitempty"` + // Gets and sets the reference name of deploy phase. + RefName *string `json:"refName,omitempty"` + // Gets and sets the workflow tasks for the deploy phase. + WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` + // Gets and sets the agent job deployment input + DeploymentInput *AgentDeploymentInput `json:"deploymentInput,omitempty"` +} + +type AgentDeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Artifacts that downloaded during job execution. + ArtifactsDownloadInput *ArtifactsDownloadInput `json:"artifactsDownloadInput,omitempty"` + // List demands that needs to meet to execute the job. + Demands *[]interface{} `json:"demands,omitempty"` + // Indicates whether to include access token in deployment job or not. + EnableAccessToken *bool `json:"enableAccessToken,omitempty"` + // Id of the pool on which job get executed. + QueueId *int `json:"queueId,omitempty"` + // Indicates whether artifacts downloaded while job execution or not. + SkipArtifactsDownload *bool `json:"skipArtifactsDownload,omitempty"` + // Specification for an agent on which a job gets executed. + AgentSpecification *AgentSpecification `json:"agentSpecification,omitempty"` + // Gets or sets the image ID. + ImageId *int `json:"imageId,omitempty"` + // Gets or sets the parallel execution input. + ParallelExecution *ExecutionInput `json:"parallelExecution,omitempty"` +} + +// Specification of the agent defined by the pool provider. +type AgentSpecification struct { + // Agent specification unique identifier. + Identifier *string `json:"identifier,omitempty"` +} + +// [Flags] +type ApprovalExecutionOrder string + +type approvalExecutionOrderValuesType struct { + BeforeGates ApprovalExecutionOrder + AfterSuccessfulGates ApprovalExecutionOrder + AfterGatesAlways ApprovalExecutionOrder +} + +var ApprovalExecutionOrderValues = approvalExecutionOrderValuesType{ + // Approvals shown before gates. + BeforeGates: "beforeGates", + // Approvals shown after successful execution of gates. + AfterSuccessfulGates: "afterSuccessfulGates", + // Approvals shown always after execution of gates. + AfterGatesAlways: "afterGatesAlways", +} + +// [Flags] +type ApprovalFilters string + +type approvalFiltersValuesType struct { + None ApprovalFilters + ManualApprovals ApprovalFilters + AutomatedApprovals ApprovalFilters + ApprovalSnapshots ApprovalFilters + All ApprovalFilters +} + +var ApprovalFiltersValues = approvalFiltersValuesType{ + // No approvals or approval snapshots. + None: "none", + // Manual approval steps but no approval snapshots (Use with ApprovalSnapshots for snapshots). + ManualApprovals: "manualApprovals", + // Automated approval steps but no approval snapshots (Use with ApprovalSnapshots for snapshots). + AutomatedApprovals: "automatedApprovals", + // No approval steps, but approval snapshots (Use with either ManualApprovals or AutomatedApprovals for approval steps). + ApprovalSnapshots: "approvalSnapshots", + // All approval steps and approval snapshots. + All: "all", +} + +type ApprovalOptions struct { + // Specify whether the approval can be skipped if the same approver approved the previous stage. + AutoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped *bool `json:"autoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped,omitempty"` + // Specify whether revalidate identity of approver before completing the approval. + EnforceIdentityRevalidation *bool `json:"enforceIdentityRevalidation,omitempty"` + // Approvals execution order. + ExecutionOrder *ApprovalExecutionOrder `json:"executionOrder,omitempty"` + // Specify whether the user requesting a release or deployment should allow to approver. + ReleaseCreatorCanBeApprover *bool `json:"releaseCreatorCanBeApprover,omitempty"` + // The number of approvals required to move release forward. '0' means all approvals required. + RequiredApproverCount *int `json:"requiredApproverCount,omitempty"` + // Approval timeout. Approval default timeout is 30 days. Maximum allowed timeout is 365 days. '0' means default timeout i.e 30 days. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` +} + +type ApprovalStatus string + +type approvalStatusValuesType struct { + Undefined ApprovalStatus + Pending ApprovalStatus + Approved ApprovalStatus + Rejected ApprovalStatus + Reassigned ApprovalStatus + Canceled ApprovalStatus + Skipped ApprovalStatus +} + +var ApprovalStatusValues = approvalStatusValuesType{ + // Indicates the approval does not have the status set. + Undefined: "undefined", + // Indicates the approval is pending. + Pending: "pending", + // Indicates the approval is approved. + Approved: "approved", + // Indicates the approval is rejected. + Rejected: "rejected", + // Indicates the approval is reassigned. + Reassigned: "reassigned", + // Indicates the approval is canceled. + Canceled: "canceled", + // Indicates the approval is skipped. + Skipped: "skipped", +} + +type ApprovalType string + +type approvalTypeValuesType struct { + Undefined ApprovalType + PreDeploy ApprovalType + PostDeploy ApprovalType + All ApprovalType +} + +var ApprovalTypeValues = approvalTypeValuesType{ + // Indicates the approval type does not set. + Undefined: "undefined", + // Indicates the approvals which executed before deployment. + PreDeploy: "preDeploy", + // Indicates the approvals which executed after deployment. + PostDeploy: "postDeploy", + // Indicates all approvals. + All: "all", +} + +type Artifact struct { + // Gets or sets alias. + Alias *string `json:"alias,omitempty"` + // Gets or sets definition reference. e.g. {"project":{"id":"fed755ea-49c5-4399-acea-fd5b5aa90a6c","name":"myProject"},"definition":{"id":"1","name":"mybuildDefinition"},"connection":{"id":"1","name":"myConnection"}}. + DefinitionReference *map[string]ArtifactSourceReference `json:"definitionReference,omitempty"` + // Indicates whether artifact is primary or not. + IsPrimary *bool `json:"isPrimary,omitempty"` + // Indicates whether artifact is retained by release or not. + IsRetained *bool `json:"isRetained,omitempty"` + // Deprecated: This property is deprecated use Alias instead and remove all its references + SourceId *string `json:"sourceId,omitempty"` + // Gets or sets type. It can have value as 'Build', 'Jenkins', 'GitHub', 'Nuget', 'Team Build (external)', 'ExternalTFSBuild', 'Git', 'TFVC', 'ExternalTfsXamlBuild'. + Type *string `json:"type,omitempty"` +} + +type ArtifactContributionDefinition struct { + ArtifactTriggerConfiguration *ArtifactTriggerConfiguration `json:"artifactTriggerConfiguration,omitempty"` + ArtifactType *string `json:"artifactType,omitempty"` + ArtifactTypeStreamMapping *map[string]string `json:"artifactTypeStreamMapping,omitempty"` + BrowsableArtifactTypeMapping *map[string]string `json:"browsableArtifactTypeMapping,omitempty"` + DataSourceBindings *[]DataSourceBinding `json:"dataSourceBindings,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + DownloadTaskId *string `json:"downloadTaskId,omitempty"` + EndpointTypeId *string `json:"endpointTypeId,omitempty"` + InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` + IsCommitsTraceabilitySupported *bool `json:"isCommitsTraceabilitySupported,omitempty"` + IsWorkitemsTraceabilitySupported *bool `json:"isWorkitemsTraceabilitySupported,omitempty"` + Name *string `json:"name,omitempty"` + TaskInputMapping *map[string]string `json:"taskInputMapping,omitempty"` + UniqueSourceIdentifier *string `json:"uniqueSourceIdentifier,omitempty"` +} + +type ArtifactDownloadInputBase struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type ArtifactFilter struct { + // Gets or sets whether a release should be created on build tagging. + CreateReleaseOnBuildTagging *bool `json:"createReleaseOnBuildTagging,omitempty"` + // Gets or sets the branch for the filter. + SourceBranch *string `json:"sourceBranch,omitempty"` + // Gets or sets the list of tags for the filter. + Tags *[]string `json:"tags,omitempty"` + // Gets or sets whether filter should default to build definition branch. + UseBuildDefinitionBranch *bool `json:"useBuildDefinitionBranch,omitempty"` +} + +type ArtifactInstanceData struct { + AccountName *string `json:"accountName,omitempty"` + AuthenticationToken *string `json:"authenticationToken,omitempty"` + TfsUrl *string `json:"tfsUrl,omitempty"` + Version *string `json:"version,omitempty"` +} + +type ArtifactMetadata struct { + // Sets alias of artifact. + Alias *string `json:"alias,omitempty"` + // Sets instance reference of artifact. e.g. for build artifact it is build number. + InstanceReference *BuildVersion `json:"instanceReference,omitempty"` +} + +type ArtifactProvider struct { + // Gets or sets the id of artifact provider. + Id *int `json:"id,omitempty"` + // Gets or sets the name of artifact provider. + Name *string `json:"name,omitempty"` + // Gets or sets the link of artifact provider. + SourceUri *string `json:"sourceUri,omitempty"` + // Gets or sets the version of artifact provider. + Version *string `json:"version,omitempty"` +} + +type ArtifactsDownloadInput struct { + DownloadInputs *[]ArtifactDownloadInputBase `json:"downloadInputs,omitempty"` +} + +type ArtifactSourceId struct { + // Gets or sets the artifact type of artifact source. + ArtifactTypeId *string `json:"artifactTypeId,omitempty"` + // Gets or sets the list of sourceIdInput of artifact source. + SourceIdInputs *[]SourceIdInput `json:"sourceIdInputs,omitempty"` +} + +type ArtifactSourceIdsQueryResult struct { + // Gets or sets the list of artifactsourceIds. + ArtifactSourceIds *[]ArtifactSourceId `json:"artifactSourceIds,omitempty"` +} + +type ArtifactSourceReference struct { + // ID of the artifact source. + Id *string `json:"id,omitempty"` + // Name of the artifact source. + Name *string `json:"name,omitempty"` +} + +type ArtifactSourceTrigger struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` + // Artifact source alias for Artifact Source trigger type + ArtifactAlias *string `json:"artifactAlias,omitempty"` + TriggerConditions *[]ArtifactFilter `json:"triggerConditions,omitempty"` +} + +type ArtifactTriggerConfiguration struct { + // Gets or sets the whether trigger is supported or not. + IsTriggerSupported *bool `json:"isTriggerSupported,omitempty"` + // Gets or sets the whether trigger is supported only on hosted environment. + IsTriggerSupportedOnlyInHosted *bool `json:"isTriggerSupportedOnlyInHosted,omitempty"` + // Gets or sets the whether webhook is supported at server level. + IsWebhookSupportedAtServerLevel *bool `json:"isWebhookSupportedAtServerLevel,omitempty"` + // Gets or sets the payload hash header name for the artifact trigger configuration. + PayloadHashHeaderName *string `json:"payloadHashHeaderName,omitempty"` + // Gets or sets the resources for artifact trigger configuration. + Resources *map[string]string `json:"resources,omitempty"` + // Gets or sets the webhook payload mapping for artifact trigger configuration. + WebhookPayloadMapping *map[string]string `json:"webhookPayloadMapping,omitempty"` +} + +type ArtifactTypeDefinition struct { + // Gets or sets the artifact trigger configuration of artifact type definition. + ArtifactTriggerConfiguration *ArtifactTriggerConfiguration `json:"artifactTriggerConfiguration,omitempty"` + // Gets or sets the artifact type of artifact type definition. Valid values are 'Build', 'Package', 'Source' or 'ContainerImage'. + ArtifactType *string `json:"artifactType,omitempty"` + // Gets or sets the display name of artifact type definition. + DisplayName *string `json:"displayName,omitempty"` + // Gets or sets the endpoint type id of artifact type definition. + EndpointTypeId *string `json:"endpointTypeId,omitempty"` + // Gets or sets the input descriptors of artifact type definition. + InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` + // Gets or sets the name of artifact type definition. + Name *string `json:"name,omitempty"` + // Gets or sets the unique source identifier of artifact type definition. + UniqueSourceIdentifier *string `json:"uniqueSourceIdentifier,omitempty"` +} + +type ArtifactVersion struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the default version of artifact. + DefaultVersion *BuildVersion `json:"defaultVersion,omitempty"` + // Gets or sets the error message encountered during querying of versions for artifact. + ErrorMessage *string `json:"errorMessage,omitempty"` + // Deprecated: This property is deprecated use Alias instead and remove all its references + SourceId *string `json:"sourceId,omitempty"` + // Gets or sets the list of build versions of artifact. + Versions *[]BuildVersion `json:"versions,omitempty"` +} + +type ArtifactVersionQueryResult struct { + // Gets or sets the list for artifact versions of artifact version query result. + ArtifactVersions *[]ArtifactVersion `json:"artifactVersions,omitempty"` +} + +type AuditAction string + +type auditActionValuesType struct { + Add AuditAction + Update AuditAction + Delete AuditAction + Undelete AuditAction +} + +var AuditActionValues = auditActionValuesType{ + // Indicates the audit add. + Add: "add", + // Indicates the audit update. + Update: "update", + // Indicates the audit delete. + Delete: "delete", + // Indicates the audit undelete. + Undelete: "undelete", +} + +type AuthorizationHeaderFor string + +type authorizationHeaderForValuesType struct { + RevalidateApproverIdentity AuthorizationHeaderFor + OnBehalfOf AuthorizationHeaderFor +} + +var AuthorizationHeaderForValues = authorizationHeaderForValuesType{ + RevalidateApproverIdentity: "revalidateApproverIdentity", + OnBehalfOf: "onBehalfOf", +} + +type AutoTriggerIssue struct { + Issue *Issue `json:"issue,omitempty"` + IssueSource *IssueSource `json:"issueSource,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + ReleaseDefinitionReference *ReleaseDefinitionShallowReference `json:"releaseDefinitionReference,omitempty"` + ReleaseTriggerType *ReleaseTriggerType `json:"releaseTriggerType,omitempty"` +} + +type AzureKeyVaultVariableGroupProviderData struct { + // Gets or sets last refreshed time. + LastRefreshedOn *azuredevops.Time `json:"lastRefreshedOn,omitempty"` + // Gets or sets the service endpoint ID. + ServiceEndpointId *uuid.UUID `json:"serviceEndpointId,omitempty"` + // Gets or sets the vault name. + Vault *string `json:"vault,omitempty"` +} + +type AzureKeyVaultVariableValue struct { + // Gets or sets as the variable is secret or not. + IsSecret *bool `json:"isSecret,omitempty"` + // Gets or sets the value. + Value *string `json:"value,omitempty"` + // Gets or sets the content type of key vault variable value. + ContentType *string `json:"contentType,omitempty"` + // Indicates the vault variable value enabled or not. + Enabled *bool `json:"enabled,omitempty"` + // Gets or sets the expire time of key vault variable value. + Expires *azuredevops.Time `json:"expires,omitempty"` +} + +type BaseDeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` +} + +type BuildArtifactDownloadInput struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type BuildVersion struct { + // Gets or sets the commit message for the artifact. + CommitMessage *string `json:"commitMessage,omitempty"` + // Gets or sets the definition id. + DefinitionId *string `json:"definitionId,omitempty"` + // Gets or sets the definition name. + DefinitionName *string `json:"definitionName,omitempty"` + // Gets or sets the build id. + Id *string `json:"id,omitempty"` + // Gets or sets if the artifact supports multiple definitions. + IsMultiDefinitionType *bool `json:"isMultiDefinitionType,omitempty"` + // Gets or sets the build number. + Name *string `json:"name,omitempty"` + // Gets or sets the source branch for the artifact. + SourceBranch *string `json:"sourceBranch,omitempty"` + // Gets or sets the source pull request version for the artifact. + SourcePullRequestVersion *SourcePullRequestVersion `json:"sourcePullRequestVersion,omitempty"` + // Gets or sets the repository id for the artifact. + SourceRepositoryId *string `json:"sourceRepositoryId,omitempty"` + // Gets or sets the repository type for the artifact. + SourceRepositoryType *string `json:"sourceRepositoryType,omitempty"` + // Gets or sets the source version for the artifact. + SourceVersion *string `json:"sourceVersion,omitempty"` +} + +// Represents a change associated with a build. +type Change struct { + // The author of the change. + Author *webapi.IdentityRef `json:"author,omitempty"` + // The type of source. "TfsVersionControl", "TfsGit", etc. + ChangeType *string `json:"changeType,omitempty"` + // The location of a user-friendly representation of the resource. + DisplayUri *string `json:"displayUri,omitempty"` + // Something that identifies the change. For a commit, this would be the SHA1. For a TFVC changeset, this would be the changeset id. + Id *string `json:"id,omitempty"` + // The location of the full representation of the resource. + Location *string `json:"location,omitempty"` + // A description of the change. This might be a commit message or changeset description. + Message *string `json:"message,omitempty"` + // The person or process that pushed the change. + PushedBy *webapi.IdentityRef `json:"pushedBy,omitempty"` + // Deprecated: Use PushedBy instead + Pusher *string `json:"pusher,omitempty"` + // A timestamp for the change. + Timestamp *azuredevops.Time `json:"timestamp,omitempty"` +} + +type CodeRepositoryReference struct { + // Gets and sets the repository references. + RepositoryReference *map[string]ReleaseManagementInputValue `json:"repositoryReference,omitempty"` + // It can have value as ‘GitHub’, ‘Vsts’. + SystemType *PullRequestSystemType `json:"systemType,omitempty"` +} + +type ComplianceSettings struct { + // Scan the release definition for secrets + CheckForCredentialsAndOtherSecrets *bool `json:"checkForCredentialsAndOtherSecrets,omitempty"` +} + +type Condition struct { + // Gets or sets the condition type. + ConditionType *ConditionType `json:"conditionType,omitempty"` + // Gets or sets the name of the condition. e.g. 'ReleaseStarted'. + Name *string `json:"name,omitempty"` + // Gets or set value of the condition. + Value *string `json:"value,omitempty"` +} + +type ConditionType string + +type conditionTypeValuesType struct { + Undefined ConditionType + Event ConditionType + EnvironmentState ConditionType + Artifact ConditionType +} + +var ConditionTypeValues = conditionTypeValuesType{ + // The condition type is undefined. + Undefined: "undefined", + // The condition type is event. + Event: "event", + // The condition type is environment state. + EnvironmentState: "environmentState", + // The condition type is artifact. + Artifact: "artifact", +} + +type ConfigurationVariableValue struct { + // Gets and sets if a variable can be overridden at deployment time or not. + AllowOverride *bool `json:"allowOverride,omitempty"` + // Gets or sets as variable is secret or not. + IsSecret *bool `json:"isSecret,omitempty"` + // Gets and sets value of the configuration variable. + Value *string `json:"value,omitempty"` +} + +type Consumer struct { + // ID of the consumer. + ConsumerId *int `json:"consumerId,omitempty"` + // Name of the consumer. + ConsumerName *string `json:"consumerName,omitempty"` +} + +type ContainerImageTrigger struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` + // Alias of the trigger. + Alias *string `json:"alias,omitempty"` + // List tag filters applied while trigger. + TagFilters *[]TagFilter `json:"tagFilters,omitempty"` +} + +type ContinuousDeploymentTriggerIssue struct { + Issue *Issue `json:"issue,omitempty"` + IssueSource *IssueSource `json:"issueSource,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + ReleaseDefinitionReference *ReleaseDefinitionShallowReference `json:"releaseDefinitionReference,omitempty"` + ReleaseTriggerType *ReleaseTriggerType `json:"releaseTriggerType,omitempty"` + // Artifact type. + ArtifactType *string `json:"artifactType,omitempty"` + // ArtifactVersion ID. + ArtifactVersionId *string `json:"artifactVersionId,omitempty"` + // Artifact source ID. + SourceId *string `json:"sourceId,omitempty"` +} + +type ControlOptions struct { + // Always run the job. + AlwaysRun *bool `json:"alwaysRun,omitempty"` + // Indicates whether to continue job on error or not. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // Indicates the job enabled or not. + Enabled *bool `json:"enabled,omitempty"` +} + +type CustomArtifactDownloadInput struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type DataSourceBinding struct { + // Pagination format supported by this data source(ContinuationToken/SkipTop). + CallbackContextTemplate *string `json:"callbackContextTemplate,omitempty"` + // Subsequent calls needed? + CallBackRequiredTemplate *string `json:"callBackRequiredTemplate,omitempty"` + // Name of the datasource. + DataSourceName *string `json:"dataSourceName,omitempty"` + // Endpoint ID of the datasource. + EndpointId *string `json:"endpointId,omitempty"` + // Endpoint URL of the datasource. + EndpointUrl *string `json:"endpointUrl,omitempty"` + // Defines the initial value of the query params + InitialContextTemplate *string `json:"initialContextTemplate,omitempty"` + // Parameters of the datasource. + Parameters *map[string]string `json:"parameters,omitempty"` + // Gets or sets http request body + RequestContent *string `json:"requestContent,omitempty"` + // Gets or sets http request verb + RequestVerb *string `json:"requestVerb,omitempty"` + // Result selector applied on output of datasource result, for example jsonpath:$.value[?(@.properties.isEnabled == true)]. + ResultSelector *string `json:"resultSelector,omitempty"` + // Format of the return results, for example. { "Value" : "{{{id}}}", "DisplayValue" : "{{{name}}}" }. + ResultTemplate *string `json:"resultTemplate,omitempty"` + // Target of the datasource. + Target *string `json:"target,omitempty"` +} + +type DefinitionEnvironmentReference struct { + // Definition environment ID. + DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` + // Definition environment name. + DefinitionEnvironmentName *string `json:"definitionEnvironmentName,omitempty"` + // ReleaseDefinition ID. + ReleaseDefinitionId *int `json:"releaseDefinitionId,omitempty"` + // ReleaseDefinition name. + ReleaseDefinitionName *string `json:"releaseDefinitionName,omitempty"` +} + +type Demand struct { + // Gets and sets the name of demand. + Name *string `json:"name,omitempty"` + // Gets and sets the value of demand. + Value *string `json:"value,omitempty"` +} + +type Deployment struct { + // Deprecated: Use ReleaseReference instead. + Links interface{} `json:"_links,omitempty"` + // Gets attempt number. + Attempt *int `json:"attempt,omitempty"` + // Gets the date on which deployment is complete. + CompletedOn *azuredevops.Time `json:"completedOn,omitempty"` + // Gets the list of condition associated with deployment. + Conditions *[]Condition `json:"conditions,omitempty"` + // Gets release definition environment id. + DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` + // Gets status of the deployment. + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + // Gets the unique identifier for deployment. + Id *int `json:"id,omitempty"` + // Gets the identity who last modified the deployment. + LastModifiedBy *webapi.IdentityRef `json:"lastModifiedBy,omitempty"` + // Gets the date on which deployment is last modified. + LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` + // Gets operation status of deployment. + OperationStatus *DeploymentOperationStatus `json:"operationStatus,omitempty"` + // Gets list of PostDeployApprovals. + PostDeployApprovals *[]ReleaseApproval `json:"postDeployApprovals,omitempty"` + // Gets list of PreDeployApprovals. + PreDeployApprovals *[]ReleaseApproval `json:"preDeployApprovals,omitempty"` + // Gets or sets project reference. + ProjectReference *ProjectReference `json:"projectReference,omitempty"` + // Gets the date on which deployment is queued. + QueuedOn *azuredevops.Time `json:"queuedOn,omitempty"` + // Gets reason of deployment. + Reason *DeploymentReason `json:"reason,omitempty"` + // Gets the reference of release. + Release *ReleaseReference `json:"release,omitempty"` + // Gets releaseDefinitionReference which specifies the reference of the release definition to which the deployment is associated. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // Gets releaseEnvironmentReference which specifies the reference of the release environment to which the deployment is associated. + ReleaseEnvironment *ReleaseEnvironmentShallowReference `json:"releaseEnvironment,omitempty"` + // Gets the identity who requested. + RequestedBy *webapi.IdentityRef `json:"requestedBy,omitempty"` + // Gets the identity for whom deployment is requested. + RequestedFor *webapi.IdentityRef `json:"requestedFor,omitempty"` + // Gets the date on which deployment is scheduled. + ScheduledDeploymentTime *azuredevops.Time `json:"scheduledDeploymentTime,omitempty"` + // Gets the date on which deployment is started. + StartedOn *azuredevops.Time `json:"startedOn,omitempty"` +} + +type DeploymentApprovalCompletedEvent struct { + Approval *ReleaseApproval `json:"approval,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + Release *Release `json:"release,omitempty"` +} + +type DeploymentApprovalPendingEvent struct { + Approval *ReleaseApproval `json:"approval,omitempty"` + ApprovalOptions *ApprovalOptions `json:"approvalOptions,omitempty"` + CompletedApprovals *[]ReleaseApproval `json:"completedApprovals,omitempty"` + Data *map[string]interface{} `json:"data,omitempty"` + Deployment *Deployment `json:"deployment,omitempty"` + IsMultipleRankApproval *bool `json:"isMultipleRankApproval,omitempty"` + PendingApprovals *[]ReleaseApproval `json:"pendingApprovals,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + Release *Release `json:"release,omitempty"` +} + +type DeploymentAttempt struct { + // Deployment attempt. + Attempt *int `json:"attempt,omitempty"` + // ID of the deployment. + DeploymentId *int `json:"deploymentId,omitempty"` + // Deprecated: Instead use Issues which contains both errors and warnings related to deployment + ErrorLog *string `json:"errorLog,omitempty"` + // Specifies whether deployment has started or not. + HasStarted *bool `json:"hasStarted,omitempty"` + // ID of deployment. + Id *int `json:"id,omitempty"` + // All the issues related to the deployment. + Issues *[]Issue `json:"issues,omitempty"` + // Deprecated: Use ReleaseDeployPhase.DeploymentJobs.Job instead. + Job *ReleaseTask `json:"job,omitempty"` + // Identity who last modified this deployment. + LastModifiedBy *webapi.IdentityRef `json:"lastModifiedBy,omitempty"` + // Time when this deployment last modified. + LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` + // Deployment operation status. + OperationStatus *DeploymentOperationStatus `json:"operationStatus,omitempty"` + // Post deployment gates that executed in this deployment. + PostDeploymentGates *ReleaseGates `json:"postDeploymentGates,omitempty"` + // Pre deployment gates that executed in this deployment. + PreDeploymentGates *ReleaseGates `json:"preDeploymentGates,omitempty"` + // When this deployment queued on. + QueuedOn *azuredevops.Time `json:"queuedOn,omitempty"` + // Reason for the deployment. + Reason *DeploymentReason `json:"reason,omitempty"` + // List of release deployphases executed in this deployment. + ReleaseDeployPhases *[]ReleaseDeployPhase `json:"releaseDeployPhases,omitempty"` + // Identity who requested this deployment. + RequestedBy *webapi.IdentityRef `json:"requestedBy,omitempty"` + // Identity for this deployment requested. + RequestedFor *webapi.IdentityRef `json:"requestedFor,omitempty"` + // Deprecated: Use ReleaseDeployPhase.RunPlanId instead. + RunPlanId *uuid.UUID `json:"runPlanId,omitempty"` + // status of the deployment. + Status *DeploymentStatus `json:"status,omitempty"` + // Deprecated: Use ReleaseDeployPhase.DeploymentJobs.Tasks instead. + Tasks *[]ReleaseTask `json:"tasks,omitempty"` +} + +type DeploymentAuthorizationInfo struct { + // Authorization header type, typically either RevalidateApproverIdentity or OnBehalfOf. + AuthorizationHeaderFor *AuthorizationHeaderFor `json:"authorizationHeaderFor,omitempty"` + // List of resources. + Resources *[]string `json:"resources,omitempty"` + // ID of the tenant. + TenantId *string `json:"tenantId,omitempty"` + // Access token key. + VstsAccessTokenKey *string `json:"vstsAccessTokenKey,omitempty"` +} + +type DeploymentAuthorizationOwner string + +type deploymentAuthorizationOwnerValuesType struct { + Automatic DeploymentAuthorizationOwner + DeploymentSubmitter DeploymentAuthorizationOwner + FirstPreDeploymentApprover DeploymentAuthorizationOwner +} + +var DeploymentAuthorizationOwnerValues = deploymentAuthorizationOwnerValuesType{ + Automatic: "automatic", + DeploymentSubmitter: "deploymentSubmitter", + FirstPreDeploymentApprover: "firstPreDeploymentApprover", +} + +type DeploymentCompletedEvent struct { + Comment *string `json:"comment,omitempty"` + Data *map[string]interface{} `json:"data,omitempty"` + Deployment *Deployment `json:"deployment,omitempty"` + Environment *ReleaseEnvironment `json:"environment,omitempty"` + Project *ProjectReference `json:"project,omitempty"` +} + +// [Flags] +type DeploymentExpands string + +type deploymentExpandsValuesType struct { + All DeploymentExpands + DeploymentOnly DeploymentExpands + Approvals DeploymentExpands + Artifacts DeploymentExpands +} + +var DeploymentExpandsValues = deploymentExpandsValuesType{ + All: "all", + DeploymentOnly: "deploymentOnly", + Approvals: "approvals", + Artifacts: "artifacts", +} + +type DeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Artifacts that downloaded during job execution. + ArtifactsDownloadInput *ArtifactsDownloadInput `json:"artifactsDownloadInput,omitempty"` + // List demands that needs to meet to execute the job. + Demands *[]interface{} `json:"demands,omitempty"` + // Indicates whether to include access token in deployment job or not. + EnableAccessToken *bool `json:"enableAccessToken,omitempty"` + // Id of the pool on which job get executed. + QueueId *int `json:"queueId,omitempty"` + // Indicates whether artifacts downloaded while job execution or not. + SkipArtifactsDownload *bool `json:"skipArtifactsDownload,omitempty"` +} + +type DeploymentJob struct { + // Parent task of all executed tasks. + Job *ReleaseTask `json:"job,omitempty"` + // List of executed tasks with in job. + Tasks *[]ReleaseTask `json:"tasks,omitempty"` +} + +type DeploymentManualInterventionPendingEvent struct { + Deployment *Deployment `json:"deployment,omitempty"` + EmailRecipients *[]uuid.UUID `json:"emailRecipients,omitempty"` + EnvironmentOwner *webapi.IdentityRef `json:"environmentOwner,omitempty"` + ManualIntervention *ManualIntervention `json:"manualIntervention,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + Release *Release `json:"release,omitempty"` +} + +// [Flags] +type DeploymentOperationStatus string + +type deploymentOperationStatusValuesType struct { + Undefined DeploymentOperationStatus + Queued DeploymentOperationStatus + Scheduled DeploymentOperationStatus + Pending DeploymentOperationStatus + Approved DeploymentOperationStatus + Rejected DeploymentOperationStatus + Deferred DeploymentOperationStatus + QueuedForAgent DeploymentOperationStatus + PhaseInProgress DeploymentOperationStatus + PhaseSucceeded DeploymentOperationStatus + PhasePartiallySucceeded DeploymentOperationStatus + PhaseFailed DeploymentOperationStatus + Canceled DeploymentOperationStatus + PhaseCanceled DeploymentOperationStatus + ManualInterventionPending DeploymentOperationStatus + QueuedForPipeline DeploymentOperationStatus + Cancelling DeploymentOperationStatus + EvaluatingGates DeploymentOperationStatus + GateFailed DeploymentOperationStatus + All DeploymentOperationStatus +} + +var DeploymentOperationStatusValues = deploymentOperationStatusValuesType{ + // The deployment operation status is undefined. + Undefined: "undefined", + // The deployment operation status is queued. + Queued: "queued", + // The deployment operation status is scheduled. + Scheduled: "scheduled", + // The deployment operation status is pending. + Pending: "pending", + // The deployment operation status is approved. + Approved: "approved", + // The deployment operation status is rejected. + Rejected: "rejected", + // The deployment operation status is deferred. + Deferred: "deferred", + // The deployment operation status is queued for agent. + QueuedForAgent: "queuedForAgent", + // The deployment operation status is phase in progress. + PhaseInProgress: "phaseInProgress", + // The deployment operation status is phase succeeded. + PhaseSucceeded: "phaseSucceeded", + // The deployment operation status is phase partially succeeded. + PhasePartiallySucceeded: "phasePartiallySucceeded", + // The deployment operation status is phase failed. + PhaseFailed: "phaseFailed", + // The deployment operation status is canceled. + Canceled: "canceled", + // The deployment operation status is phase canceled. + PhaseCanceled: "phaseCanceled", + // The deployment operation status is manualintervention pending. + ManualInterventionPending: "manualInterventionPending", + // The deployment operation status is queued for pipeline. + QueuedForPipeline: "queuedForPipeline", + // The deployment operation status is cancelling. + Cancelling: "cancelling", + // The deployment operation status is EvaluatingGates. + EvaluatingGates: "evaluatingGates", + // The deployment operation status is GateFailed. + GateFailed: "gateFailed", + // The deployment operation status is all. + All: "all", +} + +type DeploymentQueryParameters struct { + // Query deployments based specified artifact source id. + ArtifactSourceId *string `json:"artifactSourceId,omitempty"` + // Query deployments based specified artifact type id. + ArtifactTypeId *string `json:"artifactTypeId,omitempty"` + // Query deployments based specified artifact versions. + ArtifactVersions *[]string `json:"artifactVersions,omitempty"` + // Query deployments number of deployments per environment. + DeploymentsPerEnvironment *int `json:"deploymentsPerEnvironment,omitempty"` + // Query deployment based on deployment status. + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + // Query deployments of specified environments. + Environments *[]DefinitionEnvironmentReference `json:"environments,omitempty"` + // Query deployments based specified expands. + Expands *DeploymentExpands `json:"expands,omitempty"` + // Specify deleted deployments should return or not. + IsDeleted *bool `json:"isDeleted,omitempty"` + // Deprecated: + LatestDeploymentsOnly *bool `json:"latestDeploymentsOnly,omitempty"` + // Deprecated: + MaxDeploymentsPerEnvironment *int `json:"maxDeploymentsPerEnvironment,omitempty"` + // Deprecated: + MaxModifiedTime *azuredevops.Time `json:"maxModifiedTime,omitempty"` + // Deprecated: + MinModifiedTime *azuredevops.Time `json:"minModifiedTime,omitempty"` + // Query deployment based on deployment operation status. + OperationStatus *DeploymentOperationStatus `json:"operationStatus,omitempty"` + // Deprecated: + QueryOrder *ReleaseQueryOrder `json:"queryOrder,omitempty"` + // Query deployments based query type. + QueryType *DeploymentsQueryType `json:"queryType,omitempty"` + // Query deployments based specified source branch. + SourceBranch *string `json:"sourceBranch,omitempty"` +} + +// [Flags] +type DeploymentReason string + +type deploymentReasonValuesType struct { + None DeploymentReason + Manual DeploymentReason + Automated DeploymentReason + Scheduled DeploymentReason + RedeployTrigger DeploymentReason +} + +var DeploymentReasonValues = deploymentReasonValuesType{ + // The deployment reason is none. + None: "none", + // The deployment reason is manual. + Manual: "manual", + // The deployment reason is automated. + Automated: "automated", + // The deployment reason is scheduled. + Scheduled: "scheduled", + // The deployment reason is RedeployTrigger. + RedeployTrigger: "redeployTrigger", +} + +type DeploymentsQueryType string + +type deploymentsQueryTypeValuesType struct { + Regular DeploymentsQueryType + FailingSince DeploymentsQueryType +} + +var DeploymentsQueryTypeValues = deploymentsQueryTypeValuesType{ + Regular: "regular", + FailingSince: "failingSince", +} + +type DeploymentStartedEvent struct { + Environment *ReleaseEnvironment `json:"environment,omitempty"` + Project *ProjectReference `json:"project,omitempty"` + Release *Release `json:"release,omitempty"` +} + +// [Flags] +type DeploymentStatus string + +type deploymentStatusValuesType struct { + Undefined DeploymentStatus + NotDeployed DeploymentStatus + InProgress DeploymentStatus + Succeeded DeploymentStatus + PartiallySucceeded DeploymentStatus + Failed DeploymentStatus + All DeploymentStatus +} + +var DeploymentStatusValues = deploymentStatusValuesType{ + // The deployment status is undefined. + Undefined: "undefined", + // The deployment status is not deployed. + NotDeployed: "notDeployed", + // The deployment status is in progress. + InProgress: "inProgress", + // The deployment status is succeeded. + Succeeded: "succeeded", + // The deployment status is partiallysucceeded. + PartiallySucceeded: "partiallySucceeded", + // The deployment status is failed. + Failed: "failed", + // The deployment status is all. + All: "all", +} + +type DeployPhase struct { + // Gets and sets the name of deploy phase. + Name *string `json:"name,omitempty"` + // Indicates the deploy phase type. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Gets and sets the rank of deploy phase. + Rank *int `json:"rank,omitempty"` + // Gets and sets the reference name of deploy phase. + RefName *string `json:"refName,omitempty"` + // Gets and sets the workflow tasks for the deploy phase. + WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` +} + +// [Flags] +type DeployPhaseStatus string + +type deployPhaseStatusValuesType struct { + Undefined DeployPhaseStatus + NotStarted DeployPhaseStatus + InProgress DeployPhaseStatus + PartiallySucceeded DeployPhaseStatus + Succeeded DeployPhaseStatus + Failed DeployPhaseStatus + Canceled DeployPhaseStatus + Skipped DeployPhaseStatus + Cancelling DeployPhaseStatus +} + +var DeployPhaseStatusValues = deployPhaseStatusValuesType{ + // Phase status not set. + Undefined: "undefined", + // Phase execution not started. + NotStarted: "notStarted", + // Phase execution in progress. + InProgress: "inProgress", + // Phase execution partially succeeded. + PartiallySucceeded: "partiallySucceeded", + // Phase execution succeeded. + Succeeded: "succeeded", + // Phase execution failed. + Failed: "failed", + // Phase execution canceled. + Canceled: "canceled", + // Phase execution skipped. + Skipped: "skipped", + // Phase is in cancelling state. + Cancelling: "cancelling", +} + +// [Flags] +type DeployPhaseTypes string + +type deployPhaseTypesValuesType struct { + Undefined DeployPhaseTypes + AgentBasedDeployment DeployPhaseTypes + RunOnServer DeployPhaseTypes + MachineGroupBasedDeployment DeployPhaseTypes + DeploymentGates DeployPhaseTypes +} + +var DeployPhaseTypesValues = deployPhaseTypesValuesType{ + // Phase type not defined. Don't use this. + Undefined: "undefined", + // Phase type which contains tasks executed on agent. + AgentBasedDeployment: "agentBasedDeployment", + // Phase type which contains tasks executed by server. + RunOnServer: "runOnServer", + // Phase type which contains tasks executed on deployment group machines. + MachineGroupBasedDeployment: "machineGroupBasedDeployment", + // Phase type which contains tasks which acts as Gates for the deployment to go forward. + DeploymentGates: "deploymentGates", +} + +type EmailRecipients struct { + // List of email addresses. + EmailAddresses *[]string `json:"emailAddresses,omitempty"` + // List of TFS IDs guids. + TfsIds *[]uuid.UUID `json:"tfsIds,omitempty"` +} + +// Defines policy on environment queuing at Release Management side queue. We will send to Environment Runner [creating pre-deploy and other steps] only when the policies mentioned are satisfied. +type EnvironmentExecutionPolicy struct { + // This policy decides, how many environments would be with Environment Runner. + ConcurrencyCount *int `json:"concurrencyCount,omitempty"` + // Queue depth in the EnvironmentQueue table, this table keeps the environment entries till Environment Runner is free [as per it's policy] to take another environment for running. + QueueDepthCount *int `json:"queueDepthCount,omitempty"` +} + +type EnvironmentOptions struct { + // Gets and sets as the auto link workitems or not. + AutoLinkWorkItems *bool `json:"autoLinkWorkItems,omitempty"` + // Gets and sets as the badge enabled or not. + BadgeEnabled *bool `json:"badgeEnabled,omitempty"` + // Deprecated: Use Notifications instead. + EmailNotificationType *string `json:"emailNotificationType,omitempty"` + // Deprecated: Use Notifications instead. + EmailRecipients *string `json:"emailRecipients,omitempty"` + // Deprecated: Use DeploymentInput.EnableAccessToken instead. + EnableAccessToken *bool `json:"enableAccessToken,omitempty"` + // Gets and sets as the publish deployment status or not. + PublishDeploymentStatus *bool `json:"publishDeploymentStatus,omitempty"` + // Gets and sets as the.pull request deployment enabled or not. + PullRequestDeploymentEnabled *bool `json:"pullRequestDeploymentEnabled,omitempty"` + // Deprecated: Use DeploymentInput.SkipArtifactsDownload instead. + SkipArtifactsDownload *bool `json:"skipArtifactsDownload,omitempty"` + // Deprecated: Use DeploymentInput.TimeoutInMinutes instead. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` +} + +type EnvironmentRetentionPolicy struct { + // Gets and sets the number of days to keep environment. + DaysToKeep *int `json:"daysToKeep,omitempty"` + // Gets and sets the number of releases to keep. + ReleasesToKeep *int `json:"releasesToKeep,omitempty"` + // Gets and sets as the build to be retained or not. + RetainBuild *bool `json:"retainBuild,omitempty"` +} + +// [Flags] +type EnvironmentStatus string + +type environmentStatusValuesType struct { + Undefined EnvironmentStatus + NotStarted EnvironmentStatus + InProgress EnvironmentStatus + Succeeded EnvironmentStatus + Canceled EnvironmentStatus + Rejected EnvironmentStatus + Queued EnvironmentStatus + Scheduled EnvironmentStatus + PartiallySucceeded EnvironmentStatus +} + +var EnvironmentStatusValues = environmentStatusValuesType{ + // Environment status not set. + Undefined: "undefined", + // Environment is in not started state. + NotStarted: "notStarted", + // Environment is in progress state. + InProgress: "inProgress", + // Environment is in succeeded state. + Succeeded: "succeeded", + // Environment is in canceled state. + Canceled: "canceled", + // Environment is in rejected state. + Rejected: "rejected", + // Environment is in queued state. + Queued: "queued", + // Environment is in scheduled state. + Scheduled: "scheduled", + // Environment is in partially succeeded state. + PartiallySucceeded: "partiallySucceeded", +} + +type EnvironmentTrigger struct { + // Definition environment ID on which this trigger applicable. + DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` + // ReleaseDefinition ID on which this trigger applicable. + ReleaseDefinitionId *int `json:"releaseDefinitionId,omitempty"` + // Gets or sets the trigger content. + TriggerContent *string `json:"triggerContent,omitempty"` + // Gets or sets the trigger type. + TriggerType *EnvironmentTriggerType `json:"triggerType,omitempty"` +} + +type EnvironmentTriggerContent struct { + // Gets or sets action. + Action *string `json:"action,omitempty"` + // Gets or sets list of event types. + EventTypes *[]string `json:"eventTypes,omitempty"` +} + +type EnvironmentTriggerType string + +type environmentTriggerTypeValuesType struct { + Undefined EnvironmentTriggerType + DeploymentGroupRedeploy EnvironmentTriggerType + RollbackRedeploy EnvironmentTriggerType +} + +var EnvironmentTriggerTypeValues = environmentTriggerTypeValuesType{ + // Environment trigger type undefined. + Undefined: "undefined", + // Environment trigger type is deployment group redeploy. + DeploymentGroupRedeploy: "deploymentGroupRedeploy", + // Environment trigger type is Rollback. + RollbackRedeploy: "rollbackRedeploy", +} + +type ExecutionInput struct { + // Parallel execution type, for example MultiConfiguration or MultiMachine. + ParallelExecutionType *ParallelExecutionTypes `json:"parallelExecutionType,omitempty"` +} + +// Class to represent favorite entry. +type FavoriteItem struct { + // Application specific data for the entry. + Data *string `json:"data,omitempty"` + // Unique Id of the the entry. + Id *uuid.UUID `json:"id,omitempty"` + // Display text for favorite entry. + Name *string `json:"name,omitempty"` + // Application specific favorite entry type. Empty or Null represents that Favorite item is a Folder. + Type *string `json:"type,omitempty"` +} + +type Folder struct { + // Identity who created this folder. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Time when this folder created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Description of the folder. + Description *string `json:"description,omitempty"` + // Identity who last changed this folder. + LastChangedBy *webapi.IdentityRef `json:"lastChangedBy,omitempty"` + // Time when this folder last changed. + LastChangedDate *azuredevops.Time `json:"lastChangedDate,omitempty"` + // path of the folder. + Path *string `json:"path,omitempty"` +} + +type FolderPathQueryOrder string + +type folderPathQueryOrderValuesType struct { + None FolderPathQueryOrder + Ascending FolderPathQueryOrder + Descending FolderPathQueryOrder +} + +var FolderPathQueryOrderValues = folderPathQueryOrderValuesType{ + // No order. + None: "none", + // Order by folder name and path ascending. + Ascending: "ascending", + // Order by folder name and path descending. + Descending: "descending", +} + +type GatesDeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Gates minimum success duration. + MinimumSuccessDuration *int `json:"minimumSuccessDuration,omitempty"` + // Gates sampling interval. + SamplingInterval *int `json:"samplingInterval,omitempty"` + // Gates stabilization time. + StabilizationTime *int `json:"stabilizationTime,omitempty"` +} + +type GatesDeployPhase struct { + // Gets and sets the name of deploy phase. + Name *string `json:"name,omitempty"` + // Indicates the deploy phase type. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Gets and sets the rank of deploy phase. + Rank *int `json:"rank,omitempty"` + // Gets and sets the reference name of deploy phase. + RefName *string `json:"refName,omitempty"` + // Gets and sets the workflow tasks for the deploy phase. + WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` + // Gets and sets the gate job input. + DeploymentInput *GatesDeploymentInput `json:"deploymentInput,omitempty"` +} + +// [Flags] +type GateStatus string + +type gateStatusValuesType struct { + None GateStatus + Pending GateStatus + InProgress GateStatus + Succeeded GateStatus + Failed GateStatus + Canceled GateStatus +} + +var GateStatusValues = gateStatusValuesType{ + // The gate does not have the status set. + None: "none", + // The gate is in pending state. + Pending: "pending", + // The gate is currently in progress. + InProgress: "inProgress", + // The gate completed successfully. + Succeeded: "succeeded", + // The gate execution failed. + Failed: "failed", + // The gate execution cancelled. + Canceled: "canceled", +} + +type GateUpdateMetadata struct { + // Comment. + Comment *string `json:"comment,omitempty"` + // Name of gate to be ignored. + GatesToIgnore *[]string `json:"gatesToIgnore,omitempty"` +} + +type GitArtifactDownloadInput struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type GitHubArtifactDownloadInput struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type IgnoredGate struct { + // Gets the date on which gate is last ignored. + LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` + // Name of gate ignored. + Name *string `json:"name,omitempty"` +} + +type Issue struct { + // Issue data. + Data *map[string]string `json:"data,omitempty"` + // Issue type, for example error, warning or info. + IssueType *string `json:"issueType,omitempty"` + // Issue message. + Message *string `json:"message,omitempty"` +} + +type IssueSource string + +type issueSourceValuesType struct { + None IssueSource + User IssueSource + System IssueSource +} + +var IssueSourceValues = issueSourceValuesType{ + None: "none", + User: "user", + System: "system", +} + +type JenkinsArtifactDownloadInput struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type MachineGroupBasedDeployPhase struct { + // Gets and sets the name of deploy phase. + Name *string `json:"name,omitempty"` + // Indicates the deploy phase type. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Gets and sets the rank of deploy phase. + Rank *int `json:"rank,omitempty"` + // Gets and sets the reference name of deploy phase. + RefName *string `json:"refName,omitempty"` + // Gets and sets the workflow tasks for the deploy phase. + WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` + // Gets and sets the deployment group job input + DeploymentInput *MachineGroupDeploymentInput `json:"deploymentInput,omitempty"` +} + +type MachineGroupDeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Artifacts that downloaded during job execution. + ArtifactsDownloadInput *ArtifactsDownloadInput `json:"artifactsDownloadInput,omitempty"` + // List demands that needs to meet to execute the job. + Demands *[]interface{} `json:"demands,omitempty"` + // Indicates whether to include access token in deployment job or not. + EnableAccessToken *bool `json:"enableAccessToken,omitempty"` + // Id of the pool on which job get executed. + QueueId *int `json:"queueId,omitempty"` + // Indicates whether artifacts downloaded while job execution or not. + SkipArtifactsDownload *bool `json:"skipArtifactsDownload,omitempty"` + // Deployment group health option. + DeploymentHealthOption *string `json:"deploymentHealthOption,omitempty"` + // Minimum percentage of the targets guaranteed to be healthy. + HealthPercent *int `json:"healthPercent,omitempty"` + // Deployment target tag filter. + Tags *[]string `json:"tags,omitempty"` +} + +type MailMessage struct { + // Body of mail. + Body *string `json:"body,omitempty"` + // Mail CC recipients. + Cc *EmailRecipients `json:"cc,omitempty"` + // Reply to. + InReplyTo *string `json:"inReplyTo,omitempty"` + // Message ID of the mail. + MessageId *string `json:"messageId,omitempty"` + // Data when should be replied to mail. + ReplyBy *azuredevops.Time `json:"replyBy,omitempty"` + // Reply to Email recipients. + ReplyTo *EmailRecipients `json:"replyTo,omitempty"` + // List of mail section types. + Sections *[]MailSectionType `json:"sections,omitempty"` + // Mail sender type. + SenderType *SenderType `json:"senderType,omitempty"` + // Subject of the mail. + Subject *string `json:"subject,omitempty"` + // Mail To recipients. + To *EmailRecipients `json:"to,omitempty"` +} + +type MailSectionType string + +type mailSectionTypeValuesType struct { + Details MailSectionType + Environments MailSectionType + Issues MailSectionType + TestResults MailSectionType + WorkItems MailSectionType + ReleaseInfo MailSectionType +} + +var MailSectionTypeValues = mailSectionTypeValuesType{ + Details: "details", + Environments: "environments", + Issues: "issues", + TestResults: "testResults", + WorkItems: "workItems", + ReleaseInfo: "releaseInfo", +} + +type ManualIntervention struct { + // Gets or sets the identity who should approve. + Approver *webapi.IdentityRef `json:"approver,omitempty"` + // Gets or sets comments for approval. + Comments *string `json:"comments,omitempty"` + // Gets date on which it got created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets the unique identifier for manual intervention. + Id *int `json:"id,omitempty"` + // Gets or sets instructions for approval. + Instructions *string `json:"instructions,omitempty"` + // Gets date on which it got modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets or sets the name. + Name *string `json:"name,omitempty"` + // Gets releaseReference for manual intervention. + Release *ReleaseShallowReference `json:"release,omitempty"` + // Gets releaseDefinitionReference for manual intervention. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // Gets releaseEnvironmentReference for manual intervention. + ReleaseEnvironment *ReleaseEnvironmentShallowReference `json:"releaseEnvironment,omitempty"` + // Gets or sets the status of the manual intervention. + Status *ManualInterventionStatus `json:"status,omitempty"` + // Get task instance identifier. + TaskInstanceId *uuid.UUID `json:"taskInstanceId,omitempty"` + // Gets url to access the manual intervention. + Url *string `json:"url,omitempty"` +} + +// [Flags] Describes manual intervention status +type ManualInterventionStatus string + +type manualInterventionStatusValuesType struct { + Unknown ManualInterventionStatus + Pending ManualInterventionStatus + Rejected ManualInterventionStatus + Approved ManualInterventionStatus + Canceled ManualInterventionStatus +} + +var ManualInterventionStatusValues = manualInterventionStatusValuesType{ + // The manual intervention does not have the status set. + Unknown: "unknown", + // The manual intervention is pending. + Pending: "pending", + // The manual intervention is rejected. + Rejected: "rejected", + // The manual intervention is approved. + Approved: "approved", + // The manual intervention is canceled. + Canceled: "canceled", +} + +type ManualInterventionUpdateMetadata struct { + // Sets the comment for manual intervention update. + Comment *string `json:"comment,omitempty"` + // Sets the status of the manual intervention. + Status *ManualInterventionStatus `json:"status,omitempty"` +} + +type MappingDetails struct { + Mappings *map[string]forminput.InputValue `json:"mappings,omitempty"` +} + +type Metric struct { + // Name of the Metric. + Name *string `json:"name,omitempty"` + // Value of the Metric. + Value *int `json:"value,omitempty"` +} + +type MultiConfigInput struct { + // Parallel execution type, for example MultiConfiguration or MultiMachine. + ParallelExecutionType *ParallelExecutionTypes `json:"parallelExecutionType,omitempty"` + // Indicate whether continue execution of deployment on error or not. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // Maximum number of agents used while parallel execution. + MaxNumberOfAgents *int `json:"maxNumberOfAgents,omitempty"` + // Multipliers for parallel execution of deployment, for example x86,x64. + Multipliers *string `json:"multipliers,omitempty"` +} + +type MultiMachineInput struct { + // Parallel execution type, for example MultiConfiguration or MultiMachine. + ParallelExecutionType *ParallelExecutionTypes `json:"parallelExecutionType,omitempty"` + // Indicate whether continue execution of deployment on error or not. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // Maximum number of agents used while parallel execution. + MaxNumberOfAgents *int `json:"maxNumberOfAgents,omitempty"` +} + +type PackageTrigger struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` + // Package trigger alias. + Alias *string `json:"alias,omitempty"` +} + +type ParallelExecutionInputBase struct { + // Parallel execution type, for example MultiConfiguration or MultiMachine. + ParallelExecutionType *ParallelExecutionTypes `json:"parallelExecutionType,omitempty"` + // Indicate whether continue execution of deployment on error or not. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // Maximum number of agents used while parallel execution. + MaxNumberOfAgents *int `json:"maxNumberOfAgents,omitempty"` +} + +// [Flags] +type ParallelExecutionTypes string + +type parallelExecutionTypesValuesType struct { + None ParallelExecutionTypes + MultiConfiguration ParallelExecutionTypes + MultiMachine ParallelExecutionTypes +} + +var ParallelExecutionTypesValues = parallelExecutionTypesValuesType{ + None: "none", + MultiConfiguration: "multiConfiguration", + MultiMachine: "multiMachine", +} + +// [Flags] +type PipelineProcessTypes string + +type pipelineProcessTypesValuesType struct { + Designer PipelineProcessTypes + Yaml PipelineProcessTypes +} + +var PipelineProcessTypesValues = pipelineProcessTypesValuesType{ + Designer: "designer", + Yaml: "yaml", +} + +type ProjectReference struct { + // Gets the unique identifier of this field. + Id *uuid.UUID `json:"id,omitempty"` + // Gets name of project. + Name *string `json:"name,omitempty"` +} + +type PropertySelector struct { + // List of properties. + Properties *[]string `json:"properties,omitempty"` + // Property selector type. + SelectorType *PropertySelectorType `json:"selectorType,omitempty"` +} + +type PropertySelectorType string + +type propertySelectorTypeValuesType struct { + Inclusion PropertySelectorType + Exclusion PropertySelectorType +} + +var PropertySelectorTypeValues = propertySelectorTypeValuesType{ + // Include in property selector. + Inclusion: "inclusion", + // Exclude in property selector. + Exclusion: "exclusion", +} + +type PullRequestConfiguration struct { + // Code repository reference. + CodeRepositoryReference *CodeRepositoryReference `json:"codeRepositoryReference,omitempty"` + // In case of Source based artifacts, Code reference will be present in Artifact details. + UseArtifactReference *bool `json:"useArtifactReference,omitempty"` +} + +type PullRequestFilter struct { + // List of tags. + Tags *[]string `json:"tags,omitempty"` + // Target branch of pull request. + TargetBranch *string `json:"targetBranch,omitempty"` +} + +type PullRequestSystemType string + +type pullRequestSystemTypeValuesType struct { + None PullRequestSystemType + TfsGit PullRequestSystemType + GitHub PullRequestSystemType +} + +var PullRequestSystemTypeValues = pullRequestSystemTypeValuesType{ + None: "none", + TfsGit: "tfsGit", + GitHub: "gitHub", +} + +type PullRequestTrigger struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` + // Artifact alias trigger is linked to. + ArtifactAlias *string `json:"artifactAlias,omitempty"` + // Code reference details of pull request. + PullRequestConfiguration *PullRequestConfiguration `json:"pullRequestConfiguration,omitempty"` + // Policy name using which status will be published to pull request. + StatusPolicyName *string `json:"statusPolicyName,omitempty"` + // List of filters applied while trigger. + TriggerConditions *[]PullRequestFilter `json:"triggerConditions,omitempty"` +} + +type QueuedReleaseData struct { + // Project ID of the release. + ProjectId *uuid.UUID `json:"projectId,omitempty"` + // Release queue position. + QueuePosition *int `json:"queuePosition,omitempty"` + // Queued release ID. + ReleaseId *int `json:"releaseId,omitempty"` +} + +type RealtimeReleaseDefinitionEvent struct { + DefinitionId *int `json:"definitionId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` +} + +type RealtimeReleaseEvent struct { + EnvironmentId *int `json:"environmentId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + ReleaseId *int `json:"releaseId,omitempty"` +} + +type Release struct { + // Gets links to access the release. + Links interface{} `json:"_links,omitempty"` + // Gets or sets the list of artifacts. + Artifacts *[]Artifact `json:"artifacts,omitempty"` + // Gets or sets comment. + Comment *string `json:"comment,omitempty"` + // Gets or sets the identity who created. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets date on which it got created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets revision number of definition snapshot. + DefinitionSnapshotRevision *int `json:"definitionSnapshotRevision,omitempty"` + // Gets or sets description of release. + Description *string `json:"description,omitempty"` + // Gets list of environments. + Environments *[]ReleaseEnvironment `json:"environments,omitempty"` + // Gets the unique identifier of this field. + Id *int `json:"id,omitempty"` + // Whether to exclude the release from retention policies. + KeepForever *bool `json:"keepForever,omitempty"` + // Gets logs container url. + LogsContainerUrl *string `json:"logsContainerUrl,omitempty"` + // Gets or sets the identity who modified. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Gets date on which it got modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets name. + Name *string `json:"name,omitempty"` + // Gets pool name. + PoolName *string `json:"poolName,omitempty"` + // Gets or sets project reference. + ProjectReference *ProjectReference `json:"projectReference,omitempty"` + Properties interface{} `json:"properties,omitempty"` + // Gets reason of release. + Reason *ReleaseReason `json:"reason,omitempty"` + // Gets releaseDefinitionReference which specifies the reference of the release definition to which this release is associated. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // Gets or sets the release definition revision. + ReleaseDefinitionRevision *int `json:"releaseDefinitionRevision,omitempty"` + // Gets release name format. + ReleaseNameFormat *string `json:"releaseNameFormat,omitempty"` + // Gets status. + Status *ReleaseStatus `json:"status,omitempty"` + // Gets or sets list of tags. + Tags *[]string `json:"tags,omitempty"` + TriggeringArtifactAlias *string `json:"triggeringArtifactAlias,omitempty"` + // Deprecated: Use Links instead. + Url *string `json:"url,omitempty"` + // Gets the list of variable groups. + VariableGroups *[]VariableGroup `json:"variableGroups,omitempty"` + // Gets or sets the dictionary of variables. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` +} + +type ReleaseAbandonedEvent struct { + Project *ProjectReference `json:"project,omitempty"` + Release *Release `json:"release,omitempty"` +} + +type ReleaseApproval struct { + // Gets or sets the type of approval. + ApprovalType *ApprovalType `json:"approvalType,omitempty"` + // Gets the identity who approved. + ApprovedBy *webapi.IdentityRef `json:"approvedBy,omitempty"` + // Gets or sets the identity who should approve. + Approver *webapi.IdentityRef `json:"approver,omitempty"` + // Gets or sets attempt which specifies as which deployment attempt it belongs. + Attempt *int `json:"attempt,omitempty"` + // Gets or sets comments for approval. + Comments *string `json:"comments,omitempty"` + // Gets date on which it got created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets history which specifies all approvals associated with this approval. + History *[]ReleaseApprovalHistory `json:"history,omitempty"` + // Gets the unique identifier of this field. + Id *int `json:"id,omitempty"` + // Gets or sets as approval is automated or not. + IsAutomated *bool `json:"isAutomated,omitempty"` + // Deprecated: Use Notifications instead. + IsNotificationOn *bool `json:"isNotificationOn,omitempty"` + // Gets date on which it got modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets or sets rank which specifies the order of the approval. e.g. Same rank denotes parallel approval. + Rank *int `json:"rank,omitempty"` + // Gets releaseReference which specifies the reference of the release to which this approval is associated. + Release *ReleaseShallowReference `json:"release,omitempty"` + // Gets releaseDefinitionReference which specifies the reference of the release definition to which this approval is associated. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // Gets releaseEnvironmentReference which specifies the reference of the release environment to which this approval is associated. + ReleaseEnvironment *ReleaseEnvironmentShallowReference `json:"releaseEnvironment,omitempty"` + // Gets the revision number. + Revision *int `json:"revision,omitempty"` + // Gets or sets the status of the approval. + Status *ApprovalStatus `json:"status,omitempty"` + // Deprecated: Use Attempt instead. + TrialNumber *int `json:"trialNumber,omitempty"` + // Gets url to access the approval. + Url *string `json:"url,omitempty"` +} + +type ReleaseApprovalHistory struct { + // Identity of the approver. + Approver *webapi.IdentityRef `json:"approver,omitempty"` + // Identity of the object who changed approval. + ChangedBy *webapi.IdentityRef `json:"changedBy,omitempty"` + // Approval history comments. + Comments *string `json:"comments,omitempty"` + // Time when this approval created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Time when this approval modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Approval history revision. + Revision *int `json:"revision,omitempty"` +} + +type ReleaseApprovalPendingEvent struct { + Approval *ReleaseApproval `json:"approval,omitempty"` + ApprovalOptions *ApprovalOptions `json:"approvalOptions,omitempty"` + CompletedApprovals *[]ReleaseApproval `json:"completedApprovals,omitempty"` + DefinitionName *string `json:"definitionName,omitempty"` + Deployment *Deployment `json:"deployment,omitempty"` + EnvironmentId *int `json:"environmentId,omitempty"` + EnvironmentName *string `json:"environmentName,omitempty"` + Environments *[]ReleaseEnvironment `json:"environments,omitempty"` + IsMultipleRankApproval *bool `json:"isMultipleRankApproval,omitempty"` + PendingApprovals *[]ReleaseApproval `json:"pendingApprovals,omitempty"` + ReleaseCreator *string `json:"releaseCreator,omitempty"` + ReleaseName *string `json:"releaseName,omitempty"` + Title *string `json:"title,omitempty"` + WebAccessUri *string `json:"webAccessUri,omitempty"` +} + +type ReleaseArtifact struct { + // Gets or sets the artifact provider of ReleaseArtifact. + ArtifactProvider *ArtifactProvider `json:"artifactProvider,omitempty"` + // Gets or sets the artifact type of ReleaseArtifact. + ArtifactType *string `json:"artifactType,omitempty"` + // Gets or sets the definition json of ReleaseArtifact. + DefinitionData *string `json:"definitionData,omitempty"` + // Gets or sets the definition id of ReleaseArtifact. + DefinitionId *int `json:"definitionId,omitempty"` + // Gets or sets the description of ReleaseArtifact. + Description *string `json:"description,omitempty"` + // Gets or sets the id of ReleaseArtifact. + Id *int `json:"id,omitempty"` + // Gets or sets the name of ReleaseArtifact. + Name *string `json:"name,omitempty"` + // Gets or sets the release id. + ReleaseId *int `json:"releaseId,omitempty"` +} + +type ReleaseCondition struct { + // Gets or sets the condition type. + ConditionType *ConditionType `json:"conditionType,omitempty"` + // Gets or sets the name of the condition. e.g. 'ReleaseStarted'. + Name *string `json:"name,omitempty"` + // Gets or set value of the condition. + Value *string `json:"value,omitempty"` + // The release condition result. + Result *bool `json:"result,omitempty"` +} + +type ReleaseCreatedEvent struct { + Project *ProjectReference `json:"project,omitempty"` + Release *Release `json:"release,omitempty"` +} + +type ReleaseDefinition struct { + // Gets the links to related resources, APIs, and views for the release definition. + Links interface{} `json:"_links,omitempty"` + // Gets the unique identifier of release definition. + Id *int `json:"id,omitempty"` + // Gets or sets the name of the release definition. + Name *string `json:"name,omitempty"` + // Gets or sets the path of the release definition. + Path *string `json:"path,omitempty"` + // Gets or sets project reference. + ProjectReference *ProjectReference `json:"projectReference,omitempty"` + // Gets the REST API url to access the release definition. + Url *string `json:"url,omitempty"` + // Gets or sets the list of artifacts. + Artifacts *[]Artifact `json:"artifacts,omitempty"` + // Gets or sets comment. + Comment *string `json:"comment,omitempty"` + // Gets or sets the identity who created. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets date on which it got created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets or sets the description. + Description *string `json:"description,omitempty"` + // Gets or sets the list of environments. + Environments *[]ReleaseDefinitionEnvironment `json:"environments,omitempty"` + // Whether release definition is deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` + // Gets the reference of last release. + LastRelease *ReleaseReference `json:"lastRelease,omitempty"` + // Gets or sets the identity who modified. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Gets date on which it got modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets or sets properties. + Properties interface{} `json:"properties,omitempty"` + // Gets or sets the release name format. + ReleaseNameFormat *string `json:"releaseNameFormat,omitempty"` + // Deprecated: Retention policy at Release Definition level is deprecated. Use the Retention Policy at environment and API version 3.0-preview.2 or later + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` + // Gets the revision number. + Revision *int `json:"revision,omitempty"` + // Gets or sets source of release definition. + Source *ReleaseDefinitionSource `json:"source,omitempty"` + // Gets or sets list of tags. + Tags *[]string `json:"tags,omitempty"` + // Gets or sets the list of triggers. + Triggers *[]interface{} `json:"triggers,omitempty"` + // Gets or sets the list of variable groups. + VariableGroups *[]int `json:"variableGroups,omitempty"` + // Gets or sets the dictionary of variables. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` +} + +type ReleaseDefinitionApprovals struct { + // Gets or sets the approval options. + ApprovalOptions *ApprovalOptions `json:"approvalOptions,omitempty"` + // Gets or sets the approvals. + Approvals *[]ReleaseDefinitionApprovalStep `json:"approvals,omitempty"` +} + +type ReleaseDefinitionApprovalStep struct { + // ID of the approval or deploy step. + Id *int `json:"id,omitempty"` + // Gets and sets the approver. + Approver *webapi.IdentityRef `json:"approver,omitempty"` + // Indicates whether the approval automated. + IsAutomated *bool `json:"isAutomated,omitempty"` + // Indicates whether the approval notification set. + IsNotificationOn *bool `json:"isNotificationOn,omitempty"` + // Gets or sets the rank of approval step. + Rank *int `json:"rank,omitempty"` +} + +type ReleaseDefinitionDeployStep struct { + // ID of the approval or deploy step. + Id *int `json:"id,omitempty"` + // The list of steps for this definition. + Tasks *[]WorkflowTask `json:"tasks,omitempty"` +} + +type ReleaseDefinitionEnvironment struct { + // Gets or sets the BadgeUrl. BadgeUrl will be used when Badge will be enabled in Release Definition Environment. + BadgeUrl *string `json:"badgeUrl,omitempty"` + // Gets or sets the environment conditions. + Conditions *[]Condition `json:"conditions,omitempty"` + // Gets or sets the current release reference. + CurrentRelease *ReleaseShallowReference `json:"currentRelease,omitempty"` + // Gets or sets the demands. + Demands *[]interface{} `json:"demands,omitempty"` + // Gets or sets the deploy phases of environment. + DeployPhases *[]interface{} `json:"deployPhases,omitempty"` + // Gets or sets the deploystep. + DeployStep *ReleaseDefinitionDeployStep `json:"deployStep,omitempty"` + // Gets or sets the environment options. + EnvironmentOptions *EnvironmentOptions `json:"environmentOptions,omitempty"` + // Gets or sets the triggers on environment. + EnvironmentTriggers *[]EnvironmentTrigger `json:"environmentTriggers,omitempty"` + // Gets or sets the environment execution policy. + ExecutionPolicy *EnvironmentExecutionPolicy `json:"executionPolicy,omitempty"` + // Gets and sets the ID of the ReleaseDefinitionEnvironment. + Id *int `json:"id,omitempty"` + // Gets and sets the name of the ReleaseDefinitionEnvironment. + Name *string `json:"name,omitempty"` + // Gets and sets the Owner of the ReleaseDefinitionEnvironment. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // Gets or sets the post deployment approvals. + PostDeployApprovals *ReleaseDefinitionApprovals `json:"postDeployApprovals,omitempty"` + // Gets or sets the post deployment gates. + PostDeploymentGates *ReleaseDefinitionGatesStep `json:"postDeploymentGates,omitempty"` + // Gets or sets the pre deployment approvals. + PreDeployApprovals *ReleaseDefinitionApprovals `json:"preDeployApprovals,omitempty"` + // Gets or sets the pre deployment gates. + PreDeploymentGates *ReleaseDefinitionGatesStep `json:"preDeploymentGates,omitempty"` + // Gets or sets the environment process parameters. + ProcessParameters *distributedtaskcommon.ProcessParameters `json:"processParameters,omitempty"` + // Gets or sets the properties on environment. + Properties interface{} `json:"properties,omitempty"` + // Gets or sets the queue ID. + QueueId *int `json:"queueId,omitempty"` + // Gets and sets the rank of the ReleaseDefinitionEnvironment. + Rank *int `json:"rank,omitempty"` + // Gets or sets the environment retention policy. + RetentionPolicy *EnvironmentRetentionPolicy `json:"retentionPolicy,omitempty"` + // Deprecated: This property is deprecated, use EnvironmentOptions instead. + RunOptions *map[string]string `json:"runOptions,omitempty"` + // Gets or sets the schedules + Schedules *[]ReleaseSchedule `json:"schedules,omitempty"` + // Gets or sets the variable groups. + VariableGroups *[]int `json:"variableGroups,omitempty"` + // Gets and sets the variables. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` +} + +type ReleaseDefinitionEnvironmentStep struct { + // ID of the approval or deploy step. + Id *int `json:"id,omitempty"` +} + +type ReleaseDefinitionEnvironmentSummary struct { + // ID of ReleaseDefinition environment summary. + Id *int `json:"id,omitempty"` + // List of release shallow reference deployed using this ReleaseDefinition. + LastReleases *[]ReleaseShallowReference `json:"lastReleases,omitempty"` + // Name of ReleaseDefinition environment summary. + Name *string `json:"name,omitempty"` +} + +type ReleaseDefinitionEnvironmentTemplate struct { + // Indicates whether template can be deleted or not. + CanDelete *bool `json:"canDelete,omitempty"` + // Category of the ReleaseDefinition environment template. + Category *string `json:"category,omitempty"` + // Description of the ReleaseDefinition environment template. + Description *string `json:"description,omitempty"` + // ReleaseDefinition environment data which used to create this template. + Environment *ReleaseDefinitionEnvironment `json:"environment,omitempty"` + // ID of the task which used to display icon used for this template. + IconTaskId *uuid.UUID `json:"iconTaskId,omitempty"` + // Icon uri of the template. + IconUri *string `json:"iconUri,omitempty"` + // ID of the ReleaseDefinition environment template. + Id *uuid.UUID `json:"id,omitempty"` + // Indicates whether template deleted or not. + IsDeleted *bool `json:"isDeleted,omitempty"` + // Name of the ReleaseDefinition environment template. + Name *string `json:"name,omitempty"` +} + +// [Flags] +type ReleaseDefinitionExpands string + +type releaseDefinitionExpandsValuesType struct { + None ReleaseDefinitionExpands + Environments ReleaseDefinitionExpands + Artifacts ReleaseDefinitionExpands + Triggers ReleaseDefinitionExpands + Variables ReleaseDefinitionExpands + Tags ReleaseDefinitionExpands + LastRelease ReleaseDefinitionExpands +} + +var ReleaseDefinitionExpandsValues = releaseDefinitionExpandsValuesType{ + // Returns top level properties of object. + None: "none", + // Include environments in return object. + Environments: "environments", + // Include artifacts in return object. + Artifacts: "artifacts", + // Include triggers in return object. + Triggers: "triggers", + // Include variables in return object. + Variables: "variables", + // Include tags in return object. + Tags: "tags", + // Include last release in return object. + LastRelease: "lastRelease", +} + +type ReleaseDefinitionGate struct { + // Gets or sets the gates workflow. + Tasks *[]WorkflowTask `json:"tasks,omitempty"` +} + +type ReleaseDefinitionGatesOptions struct { + // Gets or sets as the gates enabled or not. + IsEnabled *bool `json:"isEnabled,omitempty"` + // Gets or sets the minimum duration for steady results after a successful gates evaluation. + MinimumSuccessDuration *int `json:"minimumSuccessDuration,omitempty"` + // Gets or sets the time between re-evaluation of gates. + SamplingInterval *int `json:"samplingInterval,omitempty"` + // Gets or sets the delay before evaluation. + StabilizationTime *int `json:"stabilizationTime,omitempty"` + // Gets or sets the timeout after which gates fail. + Timeout *int `json:"timeout,omitempty"` +} + +type ReleaseDefinitionGatesStep struct { + // Gets or sets the gates. + Gates *[]ReleaseDefinitionGate `json:"gates,omitempty"` + // Gets or sets the gate options. + GatesOptions *ReleaseDefinitionGatesOptions `json:"gatesOptions,omitempty"` + // ID of the ReleaseDefinitionGateStep. + Id *int `json:"id,omitempty"` +} + +type ReleaseDefinitionQueryOrder string + +type releaseDefinitionQueryOrderValuesType struct { + IdAscending ReleaseDefinitionQueryOrder + IdDescending ReleaseDefinitionQueryOrder + NameAscending ReleaseDefinitionQueryOrder + NameDescending ReleaseDefinitionQueryOrder +} + +var ReleaseDefinitionQueryOrderValues = releaseDefinitionQueryOrderValuesType{ + // Return results based on release definition Id ascending order. + IdAscending: "idAscending", + // Return results based on release definition Id descending order. + IdDescending: "idDescending", + // Return results based on release definition name ascending order. + NameAscending: "nameAscending", + // Return results based on release definition name descending order. + NameDescending: "nameDescending", +} + +type ReleaseDefinitionRevision struct { + // Gets api-version for revision object. + ApiVersion *string `json:"apiVersion,omitempty"` + // Gets the identity who did change. + ChangedBy *webapi.IdentityRef `json:"changedBy,omitempty"` + // Gets date on which ReleaseDefinition changed. + ChangedDate *azuredevops.Time `json:"changedDate,omitempty"` + // Gets type of change. + ChangeType *AuditAction `json:"changeType,omitempty"` + // Gets comments for revision. + Comment *string `json:"comment,omitempty"` + // Get id of the definition. + DefinitionId *int `json:"definitionId,omitempty"` + // Gets definition URL. + DefinitionUrl *string `json:"definitionUrl,omitempty"` + // Get revision number of the definition. + Revision *int `json:"revision,omitempty"` +} + +type ReleaseDefinitionShallowReference struct { + // Gets the links to related resources, APIs, and views for the release definition. + Links interface{} `json:"_links,omitempty"` + // Gets the unique identifier of release definition. + Id *int `json:"id,omitempty"` + // Gets or sets the name of the release definition. + Name *string `json:"name,omitempty"` + // Gets or sets the path of the release definition. + Path *string `json:"path,omitempty"` + // Gets or sets project reference. + ProjectReference *ProjectReference `json:"projectReference,omitempty"` + // Gets the REST API url to access the release definition. + Url *string `json:"url,omitempty"` +} + +// [Flags] +type ReleaseDefinitionSource string + +type releaseDefinitionSourceValuesType struct { + Undefined ReleaseDefinitionSource + RestApi ReleaseDefinitionSource + UserInterface ReleaseDefinitionSource + Ibiza ReleaseDefinitionSource + PortalExtensionApi ReleaseDefinitionSource +} + +var ReleaseDefinitionSourceValues = releaseDefinitionSourceValuesType{ + // Indicates ReleaseDefinition source not defined. + Undefined: "undefined", + // Indicates ReleaseDefinition created using REST API. + RestApi: "restApi", + // Indicates ReleaseDefinition created using UI. + UserInterface: "userInterface", + // Indicates ReleaseDefinition created from Ibiza. + Ibiza: "ibiza", + // Indicates ReleaseDefinition created from PortalExtension API. + PortalExtensionApi: "portalExtensionApi", +} + +type ReleaseDefinitionSummary struct { + // List of Release Definition environment summary. + Environments *[]ReleaseDefinitionEnvironmentSummary `json:"environments,omitempty"` + // Release Definition reference. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // List of releases deployed using this Release Definition. + Releases *[]Release `json:"releases,omitempty"` +} + +type ReleaseDefinitionUndeleteParameter struct { + // Gets or sets comment. + Comment *string `json:"comment,omitempty"` +} + +type ReleaseDeployPhase struct { + // Deployment jobs of the phase. + DeploymentJobs *[]DeploymentJob `json:"deploymentJobs,omitempty"` + // Phase execution error logs. + ErrorLog *string `json:"errorLog,omitempty"` + // Deprecated: + Id *int `json:"id,omitempty"` + // List of manual intervention tasks execution information in phase. + ManualInterventions *[]ManualIntervention `json:"manualInterventions,omitempty"` + // Name of the phase. + Name *string `json:"name,omitempty"` + // ID of the phase. + PhaseId *string `json:"phaseId,omitempty"` + // Type of the phase. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Rank of the phase. + Rank *int `json:"rank,omitempty"` + // Run Plan ID of the phase. + RunPlanId *uuid.UUID `json:"runPlanId,omitempty"` + // Phase start time. + StartedOn *azuredevops.Time `json:"startedOn,omitempty"` + // Status of the phase. + Status *DeployPhaseStatus `json:"status,omitempty"` +} + +type ReleaseEnvironment struct { + // Gets list of conditions. + Conditions *[]ReleaseCondition `json:"conditions,omitempty"` + // Gets date on which it got created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets definition environment id. + DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` + // Deprecated: Use DeploymentInput.Demands instead. + Demands *[]interface{} `json:"demands,omitempty"` + // Gets list of deploy phases snapshot. + DeployPhasesSnapshot *[]interface{} `json:"deployPhasesSnapshot,omitempty"` + // Gets deploy steps. + DeploySteps *[]DeploymentAttempt `json:"deploySteps,omitempty"` + // Gets environment options. + EnvironmentOptions *EnvironmentOptions `json:"environmentOptions,omitempty"` + // Gets the unique identifier of this field. + Id *int `json:"id,omitempty"` + // Gets date on which it got modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets name. + Name *string `json:"name,omitempty"` + // Gets next scheduled UTC time. + NextScheduledUtcTime *azuredevops.Time `json:"nextScheduledUtcTime,omitempty"` + // Gets the identity who is owner for release environment. + Owner *webapi.IdentityRef `json:"owner,omitempty"` + // Gets list of post deploy approvals snapshot. + PostApprovalsSnapshot *ReleaseDefinitionApprovals `json:"postApprovalsSnapshot,omitempty"` + // Gets list of post deploy approvals. + PostDeployApprovals *[]ReleaseApproval `json:"postDeployApprovals,omitempty"` + // Post deployment gates snapshot data. + PostDeploymentGatesSnapshot *ReleaseDefinitionGatesStep `json:"postDeploymentGatesSnapshot,omitempty"` + // Gets list of pre deploy approvals snapshot. + PreApprovalsSnapshot *ReleaseDefinitionApprovals `json:"preApprovalsSnapshot,omitempty"` + // Gets list of pre deploy approvals. + PreDeployApprovals *[]ReleaseApproval `json:"preDeployApprovals,omitempty"` + // Pre deployment gates snapshot data. + PreDeploymentGatesSnapshot *ReleaseDefinitionGatesStep `json:"preDeploymentGatesSnapshot,omitempty"` + // Gets process parameters. + ProcessParameters *distributedtaskcommon.ProcessParameters `json:"processParameters,omitempty"` + // Deprecated: Use DeploymentInput.QueueId instead. + QueueId *int `json:"queueId,omitempty"` + // Gets rank. + Rank *int `json:"rank,omitempty"` + // Gets release reference which specifies the reference of the release to which this release environment is associated. + Release *ReleaseShallowReference `json:"release,omitempty"` + // Gets the identity who created release. + ReleaseCreatedBy *webapi.IdentityRef `json:"releaseCreatedBy,omitempty"` + // Gets releaseDefinitionReference which specifies the reference of the release definition to which this release environment is associated. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // Deprecated: Use Release object Description instead. + ReleaseDescription *string `json:"releaseDescription,omitempty"` + // Gets release id. + ReleaseId *int `json:"releaseId,omitempty"` + // Gets schedule deployment time of release environment. + ScheduledDeploymentTime *azuredevops.Time `json:"scheduledDeploymentTime,omitempty"` + // Gets list of schedules. + Schedules *[]ReleaseSchedule `json:"schedules,omitempty"` + // Gets environment status. + Status *EnvironmentStatus `json:"status,omitempty"` + // Gets time to deploy. + TimeToDeploy *float64 `json:"timeToDeploy,omitempty"` + // Gets trigger reason. + TriggerReason *string `json:"triggerReason,omitempty"` + // Gets the list of variable groups. + VariableGroups *[]VariableGroup `json:"variableGroups,omitempty"` + // Gets the dictionary of variables. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` + // Deprecated: Use DeployPhase.WorkflowTasks instead. + WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` +} + +type ReleaseEnvironmentCompletedEvent struct { + CreatedByName *string `json:"createdByName,omitempty"` + DefinitionId *int `json:"definitionId,omitempty"` + DefinitionName *string `json:"definitionName,omitempty"` + Environment *ReleaseEnvironment `json:"environment,omitempty"` + EnvironmentId *int `json:"environmentId,omitempty"` + ProjectName *string `json:"projectName,omitempty"` + Reason *DeploymentReason `json:"reason,omitempty"` + ReleaseCreatedBy *webapi.IdentityRef `json:"releaseCreatedBy,omitempty"` + ReleaseLogsUri *string `json:"releaseLogsUri,omitempty"` + ReleaseName *string `json:"releaseName,omitempty"` + Status *string `json:"status,omitempty"` + Title *string `json:"title,omitempty"` + WebAccessUri *string `json:"webAccessUri,omitempty"` +} + +type ReleaseEnvironmentShallowReference struct { + // Gets the links to related resources, APIs, and views for the release environment. + Links interface{} `json:"_links,omitempty"` + // Gets the unique identifier of release environment. + Id *int `json:"id,omitempty"` + // Gets or sets the name of the release environment. + Name *string `json:"name,omitempty"` + // Gets the REST API url to access the release environment. + Url *string `json:"url,omitempty"` +} + +type ReleaseEnvironmentStatusUpdatedEvent struct { + DefinitionId *int `json:"definitionId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + EnvironmentId *int `json:"environmentId,omitempty"` + EnvironmentStatus *EnvironmentStatus `json:"environmentStatus,omitempty"` + LatestDeploymentOperationStatus *DeploymentOperationStatus `json:"latestDeploymentOperationStatus,omitempty"` + LatestDeploymentStatus *DeploymentStatus `json:"latestDeploymentStatus,omitempty"` + ReleaseId *int `json:"releaseId,omitempty"` +} + +type ReleaseEnvironmentUpdateMetadata struct { + // Gets or sets comment. + Comment *string `json:"comment,omitempty"` + // Gets or sets scheduled deployment time. + ScheduledDeploymentTime *azuredevops.Time `json:"scheduledDeploymentTime,omitempty"` + // Gets or sets status of environment. + Status *EnvironmentStatus `json:"status,omitempty"` + // Sets list of environment variables to be overridden at deployment time. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` +} + +// [Flags] +type ReleaseExpands string + +type releaseExpandsValuesType struct { + None ReleaseExpands + Environments ReleaseExpands + Artifacts ReleaseExpands + Approvals ReleaseExpands + ManualInterventions ReleaseExpands + Variables ReleaseExpands + Tags ReleaseExpands +} + +var ReleaseExpandsValues = releaseExpandsValuesType{ + None: "none", + Environments: "environments", + Artifacts: "artifacts", + Approvals: "approvals", + ManualInterventions: "manualInterventions", + Variables: "variables", + Tags: "tags", +} + +type ReleaseGates struct { + // Contains the gates job details of each evaluation. + DeploymentJobs *[]DeploymentJob `json:"deploymentJobs,omitempty"` + // ID of release gates. + Id *int `json:"id,omitempty"` + // List of ignored gates. + IgnoredGates *[]IgnoredGate `json:"ignoredGates,omitempty"` + // Gates last modified time. + LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` + // Run plan ID of the gates. + RunPlanId *uuid.UUID `json:"runPlanId,omitempty"` + // Gates stabilization completed date and time. + StabilizationCompletedOn *azuredevops.Time `json:"stabilizationCompletedOn,omitempty"` + // Gates evaluation started time. + StartedOn *azuredevops.Time `json:"startedOn,omitempty"` + // Status of release gates. + Status *GateStatus `json:"status,omitempty"` + // Date and time at which all gates executed successfully. + SucceedingSince *azuredevops.Time `json:"succeedingSince,omitempty"` +} + +type ReleaseGatesPhase struct { + // Deployment jobs of the phase. + DeploymentJobs *[]DeploymentJob `json:"deploymentJobs,omitempty"` + // Phase execution error logs. + ErrorLog *string `json:"errorLog,omitempty"` + // ID of the phase. + Id *int `json:"id,omitempty"` + // List of manual intervention tasks execution information in phase. + ManualInterventions *[]ManualIntervention `json:"manualInterventions,omitempty"` + // Name of the phase. + Name *string `json:"name,omitempty"` + // ID of the phase. + PhaseId *string `json:"phaseId,omitempty"` + // Type of the phase. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Rank of the phase. + Rank *int `json:"rank,omitempty"` + // Run Plan ID of the phase. + RunPlanId *uuid.UUID `json:"runPlanId,omitempty"` + // Phase start time. + StartedOn *azuredevops.Time `json:"startedOn,omitempty"` + // Status of the phase. + Status *DeployPhaseStatus `json:"status,omitempty"` + // List of ignored gates. + IgnoredGates *[]IgnoredGate `json:"ignoredGates,omitempty"` + // Date and time at which stabilization of gates completed. + StabilizationCompletedOn *azuredevops.Time `json:"stabilizationCompletedOn,omitempty"` + // Date and time at which all gates executed successfully. + SucceedingSince *azuredevops.Time `json:"succeedingSince,omitempty"` +} + +type ReleaseManagementInputValue struct { + // The text to show for the display of this value. + DisplayValue *string `json:"displayValue,omitempty"` + // The value to store for this input. + Value *string `json:"value,omitempty"` +} + +type ReleaseNotCreatedEvent struct { + DefinitionReference *ReleaseDefinitionShallowReference `json:"definitionReference,omitempty"` + Message *string `json:"message,omitempty"` + ReleaseReason *ReleaseReason `json:"releaseReason,omitempty"` + RequestedBy *webapi.IdentityRef `json:"requestedBy,omitempty"` +} + +type ReleaseQueryOrder string + +type releaseQueryOrderValuesType struct { + Descending ReleaseQueryOrder + Ascending ReleaseQueryOrder +} + +var ReleaseQueryOrderValues = releaseQueryOrderValuesType{ + // Return results in descending order. + Descending: "descending", + // Return results in ascending order. + Ascending: "ascending", +} + +type ReleaseReason string + +type releaseReasonValuesType struct { + None ReleaseReason + Manual ReleaseReason + ContinuousIntegration ReleaseReason + Schedule ReleaseReason + PullRequest ReleaseReason +} + +var ReleaseReasonValues = releaseReasonValuesType{ + // Indicates the release triggered reason not set. + None: "none", + // Indicates the release triggered manually. + Manual: "manual", + // Indicates the release triggered by continuous integration. + ContinuousIntegration: "continuousIntegration", + // Indicates the release triggered by schedule. + Schedule: "schedule", + // Indicates the release triggered by PullRequest. + PullRequest: "pullRequest", +} + +type ReleaseReference struct { + // Gets links to access the release. + Links interface{} `json:"_links,omitempty"` + // Gets list of artifacts. + Artifacts *[]Artifact `json:"artifacts,omitempty"` + // Gets the identity who created release. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets date on when this release created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets description. + Description *string `json:"description,omitempty"` + // ID of the Release. + Id *int `json:"id,omitempty"` + // Gets the identity who modified release. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Gets name of release. + Name *string `json:"name,omitempty"` + // Gets reason for release. + Reason *ReleaseReason `json:"reason,omitempty"` + // Gets release definition shallow reference. + ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` + // Deprecated: Use Links instead + Url *string `json:"url,omitempty"` + // Deprecated: Use Links instead + WebAccessUri *string `json:"webAccessUri,omitempty"` +} + +type ReleaseRevision struct { + // Gets or sets the identity who changed. + ChangedBy *webapi.IdentityRef `json:"changedBy,omitempty"` + // Change date of the revision. + ChangedDate *azuredevops.Time `json:"changedDate,omitempty"` + // Change details of the revision. + ChangeDetails *string `json:"changeDetails,omitempty"` + // Change details of the revision. Typically ChangeDetails values are Add and Update. + ChangeType *string `json:"changeType,omitempty"` + // Comment of the revision. + Comment *string `json:"comment,omitempty"` + // Release ID of which this revision belongs. + DefinitionSnapshotRevision *int `json:"definitionSnapshotRevision,omitempty"` + // Gets or sets the release ID of which this revision belongs. + ReleaseId *int `json:"releaseId,omitempty"` +} + +type ReleaseSchedule struct { + // Days of the week to release. + DaysToRelease *ScheduleDays `json:"daysToRelease,omitempty"` + // Team Foundation Job Definition Job Id. + JobId *uuid.UUID `json:"jobId,omitempty"` + // Flag to determine if this schedule should only release if the associated artifact has been changed or release definition changed. + ScheduleOnlyWithChanges *bool `json:"scheduleOnlyWithChanges,omitempty"` + // Local time zone hour to start. + StartHours *int `json:"startHours,omitempty"` + // Local time zone minute to start. + StartMinutes *int `json:"startMinutes,omitempty"` + // Time zone Id of release schedule, such as 'UTC'. + TimeZoneId *string `json:"timeZoneId,omitempty"` +} + +type ReleaseSettings struct { + // Release Compliance settings. + ComplianceSettings *ComplianceSettings `json:"complianceSettings,omitempty"` + // Release retention settings. + RetentionSettings *RetentionSettings `json:"retentionSettings,omitempty"` +} + +type ReleaseShallowReference struct { + // Gets the links to related resources, APIs, and views for the release. + Links interface{} `json:"_links,omitempty"` + // Gets the unique identifier of release. + Id *int `json:"id,omitempty"` + // Gets or sets the name of the release. + Name *string `json:"name,omitempty"` + // Gets the REST API url to access the release. + Url *string `json:"url,omitempty"` +} + +type ReleaseStartEnvironmentMetadata struct { + // Sets release definition environment id. + DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` + // Sets list of environments variables to be overridden at deployment time. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` +} + +type ReleaseStartMetadata struct { + // Sets list of artifact to create a release. + Artifacts *[]ArtifactMetadata `json:"artifacts,omitempty"` + // Sets definition Id to create a release. + DefinitionId *int `json:"definitionId,omitempty"` + // Sets description to create a release. + Description *string `json:"description,omitempty"` + // Sets list of environments meta data. + EnvironmentsMetadata *[]ReleaseStartEnvironmentMetadata `json:"environmentsMetadata,omitempty"` + // Sets 'true' to create release in draft mode, 'false' otherwise. + IsDraft *bool `json:"isDraft,omitempty"` + // Sets list of environments to manual as condition. + ManualEnvironments *[]string `json:"manualEnvironments,omitempty"` + Properties interface{} `json:"properties,omitempty"` + // Sets reason to create a release. + Reason *ReleaseReason `json:"reason,omitempty"` + // Sets list of release variables to be overridden at deployment time. + Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` +} + +// [Flags] +type ReleaseStatus string + +type releaseStatusValuesType struct { + Undefined ReleaseStatus + Draft ReleaseStatus + Active ReleaseStatus + Abandoned ReleaseStatus +} + +var ReleaseStatusValues = releaseStatusValuesType{ + // Release status not set. + Undefined: "undefined", + // Release is in draft state. + Draft: "draft", + // Release status is in active. + Active: "active", + // Release status is in abandoned. + Abandoned: "abandoned", +} + +type ReleaseTask struct { + // Agent name on which task executed. + AgentName *string `json:"agentName,omitempty"` + // Deprecated: Use FinishTime instead + DateEnded *azuredevops.Time `json:"dateEnded,omitempty"` + // Deprecated: Use StartTime instead. + DateStarted *azuredevops.Time `json:"dateStarted,omitempty"` + // Finish time of the release task. + FinishTime *azuredevops.Time `json:"finishTime,omitempty"` + // ID of the release task. + Id *int `json:"id,omitempty"` + // List of issues occurred while execution of task. + Issues *[]Issue `json:"issues,omitempty"` + // Number of lines log release task has. + LineCount *uint64 `json:"lineCount,omitempty"` + // Log URL of the task. + LogUrl *string `json:"logUrl,omitempty"` + // Name of the task. + Name *string `json:"name,omitempty"` + // Task execution complete precent. + PercentComplete *int `json:"percentComplete,omitempty"` + // Rank of the release task. + Rank *int `json:"rank,omitempty"` + // Result code of the task. + ResultCode *string `json:"resultCode,omitempty"` + // ID of the release task. + StartTime *azuredevops.Time `json:"startTime,omitempty"` + // Status of release task. + Status *TaskStatus `json:"status,omitempty"` + // Workflow task reference. + Task *WorkflowTaskReference `json:"task,omitempty"` + // Timeline record ID of the release task. + TimelineRecordId *uuid.UUID `json:"timelineRecordId,omitempty"` +} + +type ReleaseTaskAttachment struct { + // Reference links of task. + Links interface{} `json:"_links,omitempty"` + // Data and time when it created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Identity who modified. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Data and time when modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Name of the task attachment. + Name *string `json:"name,omitempty"` + // Record ID of the task. + RecordId *uuid.UUID `json:"recordId,omitempty"` + // Timeline ID of the task. + TimelineId *uuid.UUID `json:"timelineId,omitempty"` + // Type of task attachment. + Type *string `json:"type,omitempty"` +} + +type ReleaseTaskLogUpdatedEvent struct { + EnvironmentId *int `json:"environmentId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + ReleaseId *int `json:"releaseId,omitempty"` + Lines *[]string `json:"lines,omitempty"` + StepRecordId *uuid.UUID `json:"stepRecordId,omitempty"` + TimelineRecordId *uuid.UUID `json:"timelineRecordId,omitempty"` +} + +type ReleaseTasksUpdatedEvent struct { + EnvironmentId *int `json:"environmentId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + ReleaseId *int `json:"releaseId,omitempty"` + Job *ReleaseTask `json:"job,omitempty"` + PlanId *uuid.UUID `json:"planId,omitempty"` + // Deprecated: + ReleaseDeployPhaseId *int `json:"releaseDeployPhaseId,omitempty"` + ReleaseStepId *int `json:"releaseStepId,omitempty"` + Tasks *[]ReleaseTask `json:"tasks,omitempty"` +} + +type ReleaseTriggerBase struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` +} + +type ReleaseTriggerType string + +type releaseTriggerTypeValuesType struct { + Undefined ReleaseTriggerType + ArtifactSource ReleaseTriggerType + Schedule ReleaseTriggerType + SourceRepo ReleaseTriggerType + ContainerImage ReleaseTriggerType + Package ReleaseTriggerType + PullRequest ReleaseTriggerType +} + +var ReleaseTriggerTypeValues = releaseTriggerTypeValuesType{ + // Release trigger type not set. + Undefined: "undefined", + // Artifact based release trigger. + ArtifactSource: "artifactSource", + // Schedule based release trigger. + Schedule: "schedule", + // Source repository based release trigger. + SourceRepo: "sourceRepo", + // Container image based release trigger. + ContainerImage: "containerImage", + // Package based release trigger. + Package: "package", + // Pull request based release trigger. + PullRequest: "pullRequest", +} + +type ReleaseUpdatedEvent struct { + EnvironmentId *int `json:"environmentId,omitempty"` + ProjectId *uuid.UUID `json:"projectId,omitempty"` + ReleaseId *int `json:"releaseId,omitempty"` + Release *Release `json:"release,omitempty"` +} + +type ReleaseUpdateMetadata struct { + // Sets comment for release. + Comment *string `json:"comment,omitempty"` + // Set 'true' to exclude the release from retention policies. + KeepForever *bool `json:"keepForever,omitempty"` + // Sets list of manual environments. + ManualEnvironments *[]string `json:"manualEnvironments,omitempty"` + // Sets name of the release. + Name *string `json:"name,omitempty"` + // Sets status of the release. + Status *ReleaseStatus `json:"status,omitempty"` +} + +type ReleaseWorkItemRef struct { + // Deprecated: + Assignee *string `json:"assignee,omitempty"` + // Gets or sets the ID. + Id *string `json:"id,omitempty"` + // Gets or sets the state. + State *string `json:"state,omitempty"` + // Gets or sets the title. + Title *string `json:"title,omitempty"` + // Gets or sets the type. + Type *string `json:"type,omitempty"` + // Gets or sets the workitem url. + Url *string `json:"url,omitempty"` +} + +type RetentionPolicy struct { + // Indicates the number of days to keep deployment. + DaysToKeep *int `json:"daysToKeep,omitempty"` +} + +type RetentionSettings struct { + // Number of days to keep deleted releases. + DaysToKeepDeletedReleases *int `json:"daysToKeepDeletedReleases,omitempty"` + // Specifies the default environment retention policy. + DefaultEnvironmentRetentionPolicy *EnvironmentRetentionPolicy `json:"defaultEnvironmentRetentionPolicy,omitempty"` + // Specifies the maximum environment retention policy. + MaximumEnvironmentRetentionPolicy *EnvironmentRetentionPolicy `json:"maximumEnvironmentRetentionPolicy,omitempty"` +} + +type RunOnServerDeployPhase struct { + // Gets and sets the name of deploy phase. + Name *string `json:"name,omitempty"` + // Indicates the deploy phase type. + PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` + // Gets and sets the rank of deploy phase. + Rank *int `json:"rank,omitempty"` + // Gets and sets the reference name of deploy phase. + RefName *string `json:"refName,omitempty"` + // Gets and sets the workflow tasks for the deploy phase. + WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` + // Gets and sets the agentless job input. + DeploymentInput *ServerDeploymentInput `json:"deploymentInput,omitempty"` +} + +type ScheduleDays string + +type scheduleDaysValuesType struct { + None ScheduleDays + Monday ScheduleDays + Tuesday ScheduleDays + Wednesday ScheduleDays + Thursday ScheduleDays + Friday ScheduleDays + Saturday ScheduleDays + Sunday ScheduleDays + All ScheduleDays +} + +var ScheduleDaysValues = scheduleDaysValuesType{ + // Scheduled day not set. + None: "none", + // Scheduled on Monday. + Monday: "monday", + // Scheduled on Tuesday. + Tuesday: "tuesday", + // Scheduled on Wednesday. + Wednesday: "wednesday", + // Scheduled on Thursday. + Thursday: "thursday", + // Scheduled on Friday. + Friday: "friday", + // Scheduled on Saturday. + Saturday: "saturday", + // Scheduled on Sunday. + Sunday: "sunday", + // Scheduled on all the days in week. + All: "all", +} + +type ScheduledReleaseTrigger struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` + // Release schedule for Scheduled Release trigger type. + Schedule *ReleaseSchedule `json:"schedule,omitempty"` +} + +type SenderType string + +type senderTypeValuesType struct { + ServiceAccount SenderType + RequestingUser SenderType +} + +var SenderTypeValues = senderTypeValuesType{ + ServiceAccount: "serviceAccount", + RequestingUser: "requestingUser", +} + +type ServerDeploymentInput struct { + // Gets or sets the job condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. + JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` + // Gets or sets the override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Gets or sets the parallel execution input. + ParallelExecution *ExecutionInput `json:"parallelExecution,omitempty"` +} + +// [Flags] +type SingleReleaseExpands string + +type singleReleaseExpandsValuesType struct { + None SingleReleaseExpands + Tasks SingleReleaseExpands +} + +var SingleReleaseExpandsValues = singleReleaseExpandsValuesType{ + // Return top level properties of object. + None: "none", + // Expand release with tasks. + Tasks: "tasks", +} + +type SourceIdInput struct { + // ID of source. + Id *string `json:"id,omitempty"` + // Name of the source. + Name *string `json:"name,omitempty"` +} + +type SourcePullRequestVersion struct { + // Pull Request Iteration Id for which the release will publish status. + IterationId *string `json:"iterationId,omitempty"` + // Pull Request Id for which the release will publish status. + PullRequestId *string `json:"pullRequestId,omitempty"` + // Date and time of the pull request merge creation. It is required to keep timeline record of Releases created by pull request. + PullRequestMergedAt *azuredevops.Time `json:"pullRequestMergedAt,omitempty"` + // Source branch of the Pull Request. + SourceBranch *string `json:"sourceBranch,omitempty"` + // Source branch commit Id of the Pull Request for which the release will publish status. + SourceBranchCommitId *string `json:"sourceBranchCommitId,omitempty"` + // Target branch of the Pull Request. + TargetBranch *string `json:"targetBranch,omitempty"` +} + +type SourceRepoTrigger struct { + // Type of release trigger. + TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` + // Alias of the source repo trigger. + Alias *string `json:"alias,omitempty"` + BranchFilters *[]string `json:"branchFilters,omitempty"` +} + +type SummaryMailSection struct { + // Html content of summary mail. + HtmlContent *string `json:"htmlContent,omitempty"` + // Rank of the summary mail. + Rank *int `json:"rank,omitempty"` + // Summary mail section type. MailSectionType has section types. + SectionType *MailSectionType `json:"sectionType,omitempty"` + // Title of the summary mail. + Title *string `json:"title,omitempty"` +} + +type TagFilter struct { + // Gets or sets the tag filter pattern. + Pattern *string `json:"pattern,omitempty"` +} + +type TaskOrchestrationPlanGroupReference struct { + // Gets or sets the plan group. + PlanGroup *string `json:"planGroup,omitempty"` + // ID of the Project. + ProjectId *uuid.UUID `json:"projectId,omitempty"` +} + +type TaskOrchestrationPlanGroupsStartedEvent struct { + PlanGroups *[]TaskOrchestrationPlanGroupReference `json:"planGroups,omitempty"` +} + +type TaskStatus string + +type taskStatusValuesType struct { + Unknown TaskStatus + Pending TaskStatus + InProgress TaskStatus + Success TaskStatus + Failure TaskStatus + Canceled TaskStatus + Skipped TaskStatus + Succeeded TaskStatus + Failed TaskStatus + PartiallySucceeded TaskStatus +} + +var TaskStatusValues = taskStatusValuesType{ + // The task does not have the status set. + Unknown: "unknown", + // The task is in pending status. + Pending: "pending", + // The task is currently in progress. + InProgress: "inProgress", + // The task completed successfully. + Success: "success", + // The task execution failed. + Failure: "failure", + // The task execution canceled. + Canceled: "canceled", + // The task execution skipped. + Skipped: "skipped", + // The task completed successfully. + Succeeded: "succeeded", + // The task execution failed. + Failed: "failed", + // The task execution partially succeeded. + PartiallySucceeded: "partiallySucceeded", +} + +type TfvcArtifactDownloadInput struct { + // Gets or sets the alias of artifact. + Alias *string `json:"alias,omitempty"` + // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. + ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` + // Gets or sets the artifact items of the input. + ArtifactItems *[]string `json:"artifactItems,omitempty"` + // Gets or sets the type of artifact. + ArtifactType *string `json:"artifactType,omitempty"` +} + +type TimeZone struct { + // Display name of the time zone. + DisplayName *string `json:"displayName,omitempty"` + // Id of the time zone. + Id *string `json:"id,omitempty"` +} + +type TimeZoneList struct { + // UTC timezone. + UtcTimeZone *TimeZone `json:"utcTimeZone,omitempty"` + // List of valid timezones. + ValidTimeZones *[]TimeZone `json:"validTimeZones,omitempty"` +} + +type VariableGroup struct { + // Gets or sets the identity who created. + CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` + // Gets date on which it got created. + CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` + // Gets or sets description. + Description *string `json:"description,omitempty"` + // Gets the unique identifier of this field. + Id *int `json:"id,omitempty"` + // Denotes if a variable group is shared with other project or not. + IsShared *bool `json:"isShared,omitempty"` + // Gets or sets the identity who modified. + ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` + // Gets date on which it got modified. + ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` + // Gets or sets name. + Name *string `json:"name,omitempty"` + // Gets or sets provider data. + ProviderData interface{} `json:"providerData,omitempty"` + // Gets or sets type. + Type *string `json:"type,omitempty"` + // Gets and sets the dictionary of variables. + Variables *map[string]interface{} `json:"variables,omitempty"` +} + +// [Flags] +type VariableGroupActionFilter string + +type variableGroupActionFilterValuesType struct { + None VariableGroupActionFilter + Manage VariableGroupActionFilter + Use VariableGroupActionFilter +} + +var VariableGroupActionFilterValues = variableGroupActionFilterValuesType{ + None: "none", + Manage: "manage", + Use: "use", +} + +type VariableGroupProviderData struct { +} + +type VariableValue struct { + // Gets or sets as the variable is secret or not. + IsSecret *bool `json:"isSecret,omitempty"` + // Gets or sets the value. + Value *string `json:"value,omitempty"` +} + +type WorkflowTask struct { + // Gets or sets as the task always run or not. + AlwaysRun *bool `json:"alwaysRun,omitempty"` + // Gets or sets the task condition. + Condition *string `json:"condition,omitempty"` + // Gets or sets as the task continue run on error or not. + ContinueOnError *bool `json:"continueOnError,omitempty"` + // Gets or sets the task definition type. Example:- 'Agent', DeploymentGroup', 'Server' or 'ServerGate'. + DefinitionType *string `json:"definitionType,omitempty"` + // Gets or sets as the task enabled or not. + Enabled *bool `json:"enabled,omitempty"` + // Gets or sets the task environment variables. + Environment *map[string]string `json:"environment,omitempty"` + // Gets or sets the task inputs. + Inputs *map[string]string `json:"inputs,omitempty"` + // Gets or sets the name of the task. + Name *string `json:"name,omitempty"` + // Gets or sets the task override inputs. + OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` + // Gets or sets the reference name of the task. + RefName *string `json:"refName,omitempty"` + // Gets or sets the ID of the task. + TaskId *uuid.UUID `json:"taskId,omitempty"` + // Gets or sets the task timeout. + TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` + // Gets or sets the version of the task. + Version *string `json:"version,omitempty"` +} + +type WorkflowTaskReference struct { + // Task identifier. + Id *uuid.UUID `json:"id,omitempty"` + // Name of the task. + Name *string `json:"name,omitempty"` + // Version of the task. + Version *string `json:"version,omitempty"` +} + +// [Flags] +type YamlFileSourceTypes string + +type yamlFileSourceTypesValuesType struct { + None YamlFileSourceTypes + TfsGit YamlFileSourceTypes +} + +var YamlFileSourceTypesValues = yamlFileSourceTypesValuesType{ + None: "none", + TfsGit: "tfsGit", +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 6ed7eeff3..39daf9502 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -166,6 +166,7 @@ github.com/microsoft/azure-devops-go-api/azuredevops/forminput github.com/microsoft/azure-devops-go-api/azuredevops/graph github.com/microsoft/azure-devops-go-api/azuredevops/identity github.com/microsoft/azure-devops-go-api/azuredevops/profile +github.com/microsoft/azure-devops-go-api/azuredevops/release github.com/microsoft/azure-devops-go-api/azuredevops/system github.com/microsoft/azure-devops-go-api/azuredevops/taskagent github.com/microsoft/azure-devops-go-api/azuredevops/webapi From 71cb2228229bd30262ffad3e8efea27cfe54727b Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Thu, 2 Jun 2022 06:23:52 -0700 Subject: [PATCH 23/41] add generic function --- .../release/resource_release_definition.go | 66 +++++++++---------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 8f6b0a43c..cd74f082c 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1230,7 +1230,7 @@ func expandReleaseDefinition(d *schema.ResourceData) (*release.ReleaseDefinition variableGroups := expandIntList(d.Get("variable_groups").([]interface{})) environments := expandReleaseDefinitionEnvironmentList(d.Get("stage").([]interface{})) variables := expandReleaseConfigurationVariableValueList(d.Get("variable").([]interface{})) - properties := expandReleaseDefinitionPropertiesListFirstOrNil(d.Get("properties").([]interface{})) + properties := expandStringMapStringFirstOrNil(d.Get("properties").([]interface{}), expandReleaseDefinitionProperties) triggers := expandReleaseDefinitionTriggersList(d.Get("triggers").([]interface{})) buildArtifacts := expandReleaseArtifactList(d.Get("build_artifact").([]interface{}), release.AgentArtifactTypeValues.Build) @@ -1444,6 +1444,28 @@ var DeploymentTypeValues = deploymentTypeValuesType{ Unmapped: "unmapped", } +type Release interface { + release.ParallelExecutionInputBase +} + +func expandList[T Release | map[string]interface{}](d []interface{}, f func(map[string]interface{}) T) []T { + vs := make([]T, 0, 0) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, f(val)) + } + } + return vs +} + +func expandFirstOrNil[T Release](d []interface{}, f func(map[string]interface{}) T) *T { + d2 := expandList(d, f) + if len(d2) != 1 { + return nil + } + return &d2[0] +} + func expandStringMapString(d map[string]interface{}) map[string]string { vs := make(map[string]string) for k, v := range d { @@ -1492,6 +1514,14 @@ func expandReleaseStringProperty(d string) interface{} { } } +func expandStringMapStringFirstOrNil[T map[string]interface{}](d []interface{}, f func(map[string]interface{}) T) T { + d2 := expandList(d, f) + if len(d2) != 1 { + return nil + } + return d2[0] +} + func expandReleaseEnvironmentProperties(d map[string]interface{}) map[string]interface{} { return map[string]interface{}{ "BoardsEnvironmentType": expandReleaseStringProperty(d["boards_environment_type"].(string)), @@ -1525,22 +1555,6 @@ func expandReleaseDefinitionProperties(d map[string]interface{}) map[string]inte "JiraServiceEndpointId": expandReleaseStringProperty(d["jira_service_endpoint_id"].(string)), } } -func expandReleaseDefinitionPropertiesList(d []interface{}) []map[string]interface{} { - vs := make([]map[string]interface{}, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseDefinitionProperties(val)) - } - } - return vs -} -func expandReleaseDefinitionPropertiesListFirstOrNil(d []interface{}) interface{} { - d2 := expandReleaseDefinitionPropertiesList(d) - if len(d2) != 1 { - return nil - } - return d2[0] -} func expandReleaseDefinitionTriggers(d map[string]interface{}) map[string]interface{} { return map[string]interface{}{} @@ -1952,22 +1966,6 @@ func expandReleaseParallelExecutionInputBase(d map[string]interface{}) release.P ContinueOnError: converter.Bool(d["continue_on_error"].(bool)), } } -func expandReleaseParallelExecutionInputBaseList(d []interface{}) []release.ParallelExecutionInputBase { - vs := make([]release.ParallelExecutionInputBase, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseParallelExecutionInputBase(val)) - } - } - return vs -} -func expandReleaseParallelExecutionInputBaseListFirstOrNil(d []interface{}) *release.ParallelExecutionInputBase { - d2 := expandReleaseParallelExecutionInputBaseList(d) - if len(d2) != 1 { - return nil - } - return &d2[0] -} func expandReleaseAgentSpecification(d map[string]interface{}) release.AgentSpecification { return release.AgentSpecification{ @@ -2064,7 +2062,7 @@ func expandReleaseAgentDeploymentInput(d map[string]interface{}) AgentDeployment ParallelExecutionType: &release.ParallelExecutionTypesValues.None, } multiConfiguration := expandReleaseMultiConfigInputListFirstOrNil(d["multi_configuration"].([]interface{})) - multiAgent := expandReleaseParallelExecutionInputBaseListFirstOrNil(d["multi_agent"].([]interface{})) + multiAgent := expandFirstOrNil(d["multi_agent"].([]interface{}), expandReleaseParallelExecutionInputBase) //if multiConfiguration != nil && multiAgent != nil { // TODO : how to solve // return nil, fmt.Errorf("conflit %s and %s specify only one", "multi_configuration", "multi_agent") //} From 6863fd9aac46d6539b8a299b0190b9a1d3c5bb03 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Thu, 2 Jun 2022 06:39:29 -0700 Subject: [PATCH 24/41] add generic function for interface --- .../release/resource_release_definition.go | 78 +++++++++---------- 1 file changed, 35 insertions(+), 43 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index cd74f082c..78891e18c 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1448,24 +1448,6 @@ type Release interface { release.ParallelExecutionInputBase } -func expandList[T Release | map[string]interface{}](d []interface{}, f func(map[string]interface{}) T) []T { - vs := make([]T, 0, 0) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, f(val)) - } - } - return vs -} - -func expandFirstOrNil[T Release](d []interface{}, f func(map[string]interface{}) T) *T { - d2 := expandList(d, f) - if len(d2) != 1 { - return nil - } - return &d2[0] -} - func expandStringMapString(d map[string]interface{}) map[string]string { vs := make(map[string]string) for k, v := range d { @@ -1482,6 +1464,16 @@ func expandStringMapString(d map[string]interface{}) map[string]string { return vs } +func expandList[T Release | map[string]interface{} | interface{}](d []interface{}, f func(map[string]interface{}) T) []T { + vs := make([]T, 0, 0) + for _, v := range d { + if val, ok := v.(map[string]interface{}); ok { + vs = append(vs, f(val)) + } + } + return vs +} + func expandIntList(d []interface{}) []int { vs := make([]int, 0, len(d)) for _, v := range d { @@ -1493,6 +1485,30 @@ func expandIntList(d []interface{}) []int { return vs } +func expandFirstOrNil[T Release](d []interface{}, f func(map[string]interface{}) T) *T { + d2 := expandList(d, f) + if len(d2) != 1 { + return nil + } + return &d2[0] +} + +func expandStringMapStringFirstOrNil[T map[string]interface{}](d []interface{}, f func(map[string]interface{}) T) T { + d2 := expandList(d, f) + if len(d2) != 1 { + return nil + } + return d2[0] +} + +func expandInterfaceFirstOrNil(d []interface{}, f func(map[string]interface{}) map[string]interface{}) interface{} { + d2 := expandList(d, f) + if len(d2) != 1 { + return nil + } + return d2[0] +} + func expandReleaseDefinitionSource(d string) release.ReleaseDefinitionSource { switch d { case string(release.ReleaseDefinitionSourceValues.RestApi): @@ -1514,14 +1530,6 @@ func expandReleaseStringProperty(d string) interface{} { } } -func expandStringMapStringFirstOrNil[T map[string]interface{}](d []interface{}, f func(map[string]interface{}) T) T { - d2 := expandList(d, f) - if len(d2) != 1 { - return nil - } - return d2[0] -} - func expandReleaseEnvironmentProperties(d map[string]interface{}) map[string]interface{} { return map[string]interface{}{ "BoardsEnvironmentType": expandReleaseStringProperty(d["boards_environment_type"].(string)), @@ -1530,22 +1538,6 @@ func expandReleaseEnvironmentProperties(d map[string]interface{}) map[string]int "LinkJiraWorkItems": expandReleaseStringProperty(strconv.FormatBool(d["link_jira_work_items"].(bool))), } } -func expandReleaseEnvironmentList(d []interface{}) []map[string]interface{} { - vs := make([]map[string]interface{}, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseEnvironmentProperties(val)) - } - } - return vs -} -func expandReleaseEnvironmentPropertiesListFirstOrNil(d []interface{}) interface{} { - d2 := expandReleaseEnvironmentList(d) - if len(d2) != 1 { - return nil - } - return d2[0] -} func expandReleaseDefinitionProperties(d map[string]interface{}) map[string]interface{} { return map[string]interface{}{ @@ -1683,7 +1675,7 @@ func expandReleaseDefinitionEnvironment(d map[string]interface{}, rank int) rele postApprovalOptions := expandReleaseApprovalOptionsListFirstOrNil(d["approval_options"].([]interface{}), release.ApprovalExecutionOrderValues.AfterSuccessfulGates) preDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["pre_deploy_approval"].([]interface{}), preApprovalOptions) postDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["post_deploy_approval"].([]interface{}), postApprovalOptions) - properties := expandReleaseEnvironmentPropertiesListFirstOrNil(d["properties"].([]interface{})) + properties := expandInterfaceFirstOrNil(d["properties"].([]interface{}), expandReleaseEnvironmentProperties) deployPhases := expandJobsList(d["job"].([]interface{})) preDeploymentGates := expandReleaseDefinitionGatesStepListFirstOrNil(d["pre_deploy_gate"].([]interface{})) postDeploymentGates := expandReleaseDefinitionGatesStepListFirstOrNil(d["post_deploy_gate"].([]interface{})) From 1be91cc6683c252ab4a60d6665807da0b30d8e9d Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Thu, 2 Jun 2022 06:45:36 -0700 Subject: [PATCH 25/41] use generic func --- .../service/release/resource_release_definition.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 78891e18c..b6301427f 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1231,7 +1231,7 @@ func expandReleaseDefinition(d *schema.ResourceData) (*release.ReleaseDefinition environments := expandReleaseDefinitionEnvironmentList(d.Get("stage").([]interface{})) variables := expandReleaseConfigurationVariableValueList(d.Get("variable").([]interface{})) properties := expandStringMapStringFirstOrNil(d.Get("properties").([]interface{}), expandReleaseDefinitionProperties) - triggers := expandReleaseDefinitionTriggersList(d.Get("triggers").([]interface{})) + triggers := expandList(d.Get("triggers").([]interface{}), expandReleaseDefinitionTriggers) buildArtifacts := expandReleaseArtifactList(d.Get("build_artifact").([]interface{}), release.AgentArtifactTypeValues.Build) artifacts := buildArtifacts @@ -1548,18 +1548,9 @@ func expandReleaseDefinitionProperties(d map[string]interface{}) map[string]inte } } -func expandReleaseDefinitionTriggers(d map[string]interface{}) map[string]interface{} { +func expandReleaseDefinitionTriggers(d map[string]interface{}) interface{} { return map[string]interface{}{} } -func expandReleaseDefinitionTriggersList(d []interface{}) []interface{} { - vs := make([]interface{}, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseDefinitionTriggers(val)) - } - } - return vs -} func expandReleaseCondition(d map[string]interface{}, t release.ConditionType) release.Condition { vs := release.Condition{ConditionType: &t} From 1113a4205e38bef279963cd10554747003db9ed7 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Thu, 2 Jun 2022 06:47:11 -0700 Subject: [PATCH 26/41] use generic func --- .../release/resource_release_definition.go | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index b6301427f..2896e3dc4 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1445,7 +1445,7 @@ var DeploymentTypeValues = deploymentTypeValuesType{ } type Release interface { - release.ParallelExecutionInputBase + release.ParallelExecutionInputBase | release.ReleaseDefinitionDeployStep } func expandStringMapString(d map[string]interface{}) map[string]string { @@ -1657,7 +1657,7 @@ func expandJobsList(d []interface{}) []interface{} { func expandReleaseDefinitionEnvironment(d map[string]interface{}, rank int) release.ReleaseDefinitionEnvironment { variableGroups := expandIntList(d["variable_groups"].([]interface{})) - deployStep := expandReleaseDefinitionDeployStepListFirstOrNil(d["deploy_step"].([]interface{})) + deployStep := expandFirstOrNil(d["deploy_step"].([]interface{}), expandReleaseDefinitionDeployStep) variables := expandReleaseConfigurationVariableValueList(d["variable"].([]interface{})) demands := expandReleaseDefinitionDemandList(d["demand"].([]interface{})) environmentOptions := expandReleaseEnvironmentOptionsListFirstOrNil(d["environment_options"].([]interface{})) @@ -1818,22 +1818,6 @@ func expandReleaseDefinitionDeployStep(d map[string]interface{}) release.Release Tasks: &tasks, } } -func expandReleaseDefinitionDeployStepList(d []interface{}) []release.ReleaseDefinitionDeployStep { - vs := make([]release.ReleaseDefinitionDeployStep, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseDefinitionDeployStep(val)) - } - } - return vs -} -func expandReleaseDefinitionDeployStepListFirstOrNil(d []interface{}) *release.ReleaseDefinitionDeployStep { - d2 := expandReleaseDefinitionDeployStepList(d) - if len(d2) != 1 { - return nil - } - return &d2[0] -} func expandReleaseDeployPhase(d map[string]interface{}, t release.DeployPhaseTypes) ReleaseDeployPhase { workflowTasks := expandReleaseWorkFlowTaskList(d["task"].([]interface{})) From 87d46f6d23af98bed1017c9a956ba4ce1d09dc55 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Thu, 2 Jun 2022 06:49:15 -0700 Subject: [PATCH 27/41] use generic func --- .../release/resource_release_definition.go | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 2896e3dc4..a5293889e 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1445,7 +1445,7 @@ var DeploymentTypeValues = deploymentTypeValuesType{ } type Release interface { - release.ParallelExecutionInputBase | release.ReleaseDefinitionDeployStep + release.ParallelExecutionInputBase | release.ReleaseDefinitionDeployStep | release.EnvironmentOptions } func expandStringMapString(d map[string]interface{}) map[string]string { @@ -1660,7 +1660,7 @@ func expandReleaseDefinitionEnvironment(d map[string]interface{}, rank int) rele deployStep := expandFirstOrNil(d["deploy_step"].([]interface{}), expandReleaseDefinitionDeployStep) variables := expandReleaseConfigurationVariableValueList(d["variable"].([]interface{})) demands := expandReleaseDefinitionDemandList(d["demand"].([]interface{})) - environmentOptions := expandReleaseEnvironmentOptionsListFirstOrNil(d["environment_options"].([]interface{})) + environmentOptions := expandFirstOrNil(d["environment_options"].([]interface{}), expandReleaseEnvironmentOptions) retentionPolicy := expandReleaseEnvironmentRetentionPolicyListFirstOrNil(d["retention_policy"].([]interface{})) preApprovalOptions := expandReleaseApprovalOptionsListFirstOrNil(d["approval_options"].([]interface{}), release.ApprovalExecutionOrderValues.BeforeGates) postApprovalOptions := expandReleaseApprovalOptionsListFirstOrNil(d["approval_options"].([]interface{}), release.ApprovalExecutionOrderValues.AfterSuccessfulGates) @@ -1864,22 +1864,6 @@ func expandReleaseEnvironmentOptions(d map[string]interface{}) release.Environme PullRequestDeploymentEnabled: converter.Bool(d["pull_request_deployment_enabled"].(bool)), } } -func expandReleaseEnvironmentOptionsList(d []interface{}) []release.EnvironmentOptions { - vs := make([]release.EnvironmentOptions, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseEnvironmentOptions(val)) - } - } - return vs -} -func expandReleaseEnvironmentOptionsListFirstOrNil(d []interface{}) *release.EnvironmentOptions { - d2 := expandReleaseEnvironmentOptionsList(d) - if len(d2) != 1 { - return nil - } - return &d2[0] -} func expandReleaseMachineGroupDeploymentInputMultiple(d map[string]interface{}) MachineGroupDeploymentMultiple { return MachineGroupDeploymentMultiple{} From 637aa4b718b948091648d8b75f967100242f354f Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Thu, 2 Jun 2022 06:50:39 -0700 Subject: [PATCH 28/41] use generic func --- .../release/resource_release_definition.go | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index a5293889e..e52014b50 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1445,7 +1445,7 @@ var DeploymentTypeValues = deploymentTypeValuesType{ } type Release interface { - release.ParallelExecutionInputBase | release.ReleaseDefinitionDeployStep | release.EnvironmentOptions + release.ParallelExecutionInputBase | release.ReleaseDefinitionDeployStep | release.EnvironmentOptions | MachineGroupDeploymentMultiple } func expandStringMapString(d map[string]interface{}) map[string]string { @@ -1868,22 +1868,6 @@ func expandReleaseEnvironmentOptions(d map[string]interface{}) release.Environme func expandReleaseMachineGroupDeploymentInputMultiple(d map[string]interface{}) MachineGroupDeploymentMultiple { return MachineGroupDeploymentMultiple{} } -func expandReleaseMachineGroupDeploymentInputMultipleList(d []interface{}) []MachineGroupDeploymentMultiple { - vs := make([]MachineGroupDeploymentMultiple, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseMachineGroupDeploymentInputMultiple(val)) - } - } - return vs -} -func expandReleaseMachineGroupDeploymentInputMultipleListFirstOrNil(d []interface{}) *MachineGroupDeploymentMultiple { - d2 := expandReleaseMachineGroupDeploymentInputMultipleList(d) - if len(d2) != 1 { - return nil - } - return &d2[0] -} func expandReleaseMultiConfigInput(d map[string]interface{}) release.MultiConfigInput { return release.MultiConfigInput{ @@ -1973,7 +1957,7 @@ func expandReleaseHostedAzurePipelinesSet(d *schema.Set) (*release.AgentSpecific func expandReleaseMachineGroupDeploymentInput(d map[string]interface{}) *release.MachineGroupDeploymentInput { tags := tfhelper.ExpandStringList(d["tags"].([]interface{})) - multiple := expandReleaseMachineGroupDeploymentInputMultipleListFirstOrNil(d["multiple"].([]interface{})) + multiple := expandFirstOrNil(d["multiple"].([]interface{}), expandReleaseMachineGroupDeploymentInputMultiple) deploymentHealthOption := DeploymentHealthOptionTypeValues.OneTargetAtATime if multiple != nil { deploymentHealthOption = DeploymentHealthOptionTypeValues.Custom From 830de16c305b2317663240669c6a383332b587ec Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Thu, 2 Jun 2022 06:52:21 -0700 Subject: [PATCH 29/41] use generic func --- .../release/resource_release_definition.go | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index e52014b50..f069449b4 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1445,7 +1445,7 @@ var DeploymentTypeValues = deploymentTypeValuesType{ } type Release interface { - release.ParallelExecutionInputBase | release.ReleaseDefinitionDeployStep | release.EnvironmentOptions | MachineGroupDeploymentMultiple + release.ParallelExecutionInputBase | release.ReleaseDefinitionDeployStep | release.EnvironmentOptions | MachineGroupDeploymentMultiple | release.MultiConfigInput } func expandStringMapString(d map[string]interface{}) map[string]string { @@ -1877,22 +1877,6 @@ func expandReleaseMultiConfigInput(d map[string]interface{}) release.MultiConfig ContinueOnError: converter.Bool(d["continue_on_error"].(bool)), } } -func expandReleaseMultiConfigInputList(d []interface{}) []release.MultiConfigInput { - vs := make([]release.MultiConfigInput, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseMultiConfigInput(val)) - } - } - return vs -} -func expandReleaseMultiConfigInputListFirstOrNil(d []interface{}) *release.MultiConfigInput { - d2 := expandReleaseMultiConfigInputList(d) - if len(d2) != 1 { - return nil - } - return &d2[0] -} func expandReleaseParallelExecutionInputBase(d map[string]interface{}) release.ParallelExecutionInputBase { return release.ParallelExecutionInputBase{ @@ -1996,7 +1980,7 @@ func expandReleaseAgentDeploymentInput(d map[string]interface{}) AgentDeployment var parallelExecution interface{} = &release.ExecutionInput{ ParallelExecutionType: &release.ParallelExecutionTypesValues.None, } - multiConfiguration := expandReleaseMultiConfigInputListFirstOrNil(d["multi_configuration"].([]interface{})) + multiConfiguration := expandFirstOrNil(d["multi_configuration"].([]interface{}), expandReleaseMultiConfigInput) multiAgent := expandFirstOrNil(d["multi_agent"].([]interface{}), expandReleaseParallelExecutionInputBase) //if multiConfiguration != nil && multiAgent != nil { // TODO : how to solve // return nil, fmt.Errorf("conflit %s and %s specify only one", "multi_configuration", "multi_agent") @@ -2027,7 +2011,7 @@ func expandReleaseServerDeploymentInput(d map[string]interface{}) *ServerDeploym var parallelExecution interface{} = &release.ExecutionInput{ ParallelExecutionType: &release.ParallelExecutionTypesValues.None, } - multiConfiguration := expandReleaseMultiConfigInputListFirstOrNil(d["multi_configuration"].([]interface{})) + multiConfiguration := expandFirstOrNil(d["multi_configuration"].([]interface{}), expandReleaseMultiConfigInput) if multiConfiguration != nil { parallelExecution = multiConfiguration } From 3c3989665d86eb93b363e2f4ec51590d47492948 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Fri, 3 Jun 2022 21:43:19 -0700 Subject: [PATCH 30/41] use generic func --- .../release/resource_release_definition.go | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index f069449b4..f550875cd 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1445,7 +1445,12 @@ var DeploymentTypeValues = deploymentTypeValuesType{ } type Release interface { - release.ParallelExecutionInputBase | release.ReleaseDefinitionDeployStep | release.EnvironmentOptions | MachineGroupDeploymentMultiple | release.MultiConfigInput + release.ParallelExecutionInputBase | + release.ReleaseDefinitionDeployStep | + release.EnvironmentOptions | + MachineGroupDeploymentMultiple | + release.MultiConfigInput | + release.AgentSpecification } func expandStringMapString(d map[string]interface{}) map[string]string { @@ -1891,22 +1896,6 @@ func expandReleaseAgentSpecification(d map[string]interface{}) release.AgentSpec Identifier: converter.String(d["agent_specification"].(string)), } } -func expandReleaseAgentSpecificationList(d []interface{}) []release.AgentSpecification { - vs := make([]release.AgentSpecification, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseAgentSpecification(val)) - } - } - return vs -} -func expandReleaseAgentSpecificationListFirstOrNil(d []interface{}) *release.AgentSpecification { - d2 := expandReleaseAgentSpecificationList(d) - if len(d2) != 1 { - return nil - } - return &d2[0] -} func expandReleaseHostedAzurePipelines(d map[string]interface{}) ReleaseHostedAzurePipelines { agentSpecification := expandReleaseAgentSpecification(d) @@ -1964,7 +1953,7 @@ func expandReleaseAgentDeploymentInput(d map[string]interface{}) AgentDeployment downloadInputs := append(buildArtifactDownloads) demands := expandReleaseDeployPhaseDemandList(d["demand"].([]interface{})) - agentPoolPrivate := expandReleaseAgentSpecificationListFirstOrNil(d["agent_pool_private"].([]interface{})) + agentPoolPrivate := expandFirstOrNil(d["agent_pool_private"].([]interface{}), expandReleaseAgentSpecification) agentPoolHostedAzurePipelines, queueID := expandReleaseHostedAzurePipelinesListFirstOrNil(d["agent_pool_hosted_azure_pipelines"].([]interface{})) //if agentPoolPrivate != nil && agentPoolHostedAzurePipelines != nil { // TODO : how to solve From 5d5593f2d1eac74f5b11ecfa345243ed75498df5 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Fri, 3 Jun 2022 21:51:41 -0700 Subject: [PATCH 31/41] use generic func --- .../release/resource_release_definition.go | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index f550875cd..231e838e6 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1920,13 +1920,6 @@ func expandReleaseHostedAzurePipelinesListFirstOrNil(d []interface{}) (*release. } return d2[0].AgentSpecification, *d2[0].QueueID } -func expandReleaseHostedAzurePipelinesSet(d *schema.Set) (*release.AgentSpecification, int) { - d2 := expandReleaseHostedAzurePipelinesList(d.List()) - if len(d2) != 1 { - return nil, 0 - } - return d2[0].AgentSpecification, *d2[0].QueueID -} func expandReleaseMachineGroupDeploymentInput(d map[string]interface{}) *release.MachineGroupDeploymentInput { tags := tfhelper.ExpandStringList(d["tags"].([]interface{})) @@ -1952,7 +1945,7 @@ func expandReleaseAgentDeploymentInput(d map[string]interface{}) AgentDeployment buildArtifactDownloads := expandReleaseArtifactDownloadInputBaseList(d["build_artifact_download"].([]interface{}), release.AgentArtifactTypeValues.Build) downloadInputs := append(buildArtifactDownloads) - demands := expandReleaseDeployPhaseDemandList(d["demand"].([]interface{})) + demands := expandList(d["demand"].([]interface{}), expandReleaseDeployPhaseDemand) agentPoolPrivate := expandFirstOrNil(d["agent_pool_private"].([]interface{}), expandReleaseAgentSpecification) agentPoolHostedAzurePipelines, queueID := expandReleaseHostedAzurePipelinesListFirstOrNil(d["agent_pool_hosted_azure_pipelines"].([]interface{})) @@ -2044,7 +2037,7 @@ func expandReleaseArtifactDownloadInputBaseList(d []interface{}, t release.Agent return vs } -func expandReleaseDeployPhaseDemand(d map[string]interface{}) string { +func expandReleaseDeployPhaseDemand(d map[string]interface{}) interface{} { name := d["name"].(string) configValue := d["value"].(string) if len(configValue) > 0 { @@ -2052,15 +2045,6 @@ func expandReleaseDeployPhaseDemand(d map[string]interface{}) string { } return name } -func expandReleaseDeployPhaseDemandList(d []interface{}) []interface{} { - vs := make([]interface{}, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseDeployPhaseDemand(val)) - } - } - return vs -} func expandReleaseDefinitionDemand(d map[string]interface{}) ReleaseDefinitionDemand { name := d["name"].(string) From c6e226b430d4a356140e02b7fc02e118c3720ef0 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Fri, 3 Jun 2022 21:53:46 -0700 Subject: [PATCH 32/41] use generic func --- .../service/release/resource_release_definition.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 231e838e6..06f73a850 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1664,7 +1664,7 @@ func expandReleaseDefinitionEnvironment(d map[string]interface{}, rank int) rele variableGroups := expandIntList(d["variable_groups"].([]interface{})) deployStep := expandFirstOrNil(d["deploy_step"].([]interface{}), expandReleaseDefinitionDeployStep) variables := expandReleaseConfigurationVariableValueList(d["variable"].([]interface{})) - demands := expandReleaseDefinitionDemandList(d["demand"].([]interface{})) + demands := expandList(d["demand"].([]interface{}), expandReleaseDefinitionDemand) environmentOptions := expandFirstOrNil(d["environment_options"].([]interface{}), expandReleaseEnvironmentOptions) retentionPolicy := expandReleaseEnvironmentRetentionPolicyListFirstOrNil(d["retention_policy"].([]interface{})) preApprovalOptions := expandReleaseApprovalOptionsListFirstOrNil(d["approval_options"].([]interface{}), release.ApprovalExecutionOrderValues.BeforeGates) @@ -2046,7 +2046,7 @@ func expandReleaseDeployPhaseDemand(d map[string]interface{}) interface{} { return name } -func expandReleaseDefinitionDemand(d map[string]interface{}) ReleaseDefinitionDemand { +func expandReleaseDefinitionDemand(d map[string]interface{}) interface{} { name := d["name"].(string) configValue := d["value"].(string) if len(configValue) > 0 { @@ -2056,15 +2056,6 @@ func expandReleaseDefinitionDemand(d map[string]interface{}) ReleaseDefinitionDe Name: converter.String(name), } } -func expandReleaseDefinitionDemandList(d []interface{}) []interface{} { - vs := make([]interface{}, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseDefinitionDemand(val)) - } - } - return vs -} func expandReleaseWorkFlowTask(d map[string]interface{}) release.WorkflowTask { task := strings.Split(d["task"].(string), "@") From 5e120f7866af0d2d565e960a205eaaf5a8bda583 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Fri, 3 Jun 2022 21:58:12 -0700 Subject: [PATCH 33/41] use generic func --- .../release/resource_release_definition.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 06f73a850..0f70ab9bb 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1450,7 +1450,8 @@ type Release interface { release.EnvironmentOptions | MachineGroupDeploymentMultiple | release.MultiConfigInput | - release.AgentSpecification + release.AgentSpecification | + release.WorkflowTask } func expandStringMapString(d map[string]interface{}) map[string]string { @@ -1817,7 +1818,7 @@ func expandReleaseConfigurationVariableValueList(d []interface{}) map[string]rel } func expandReleaseDefinitionDeployStep(d map[string]interface{}) release.ReleaseDefinitionDeployStep { - tasks := expandReleaseWorkFlowTaskList(d["task"].([]interface{})) + tasks := expandList(d["task"].([]interface{}), expandReleaseWorkFlowTask) return release.ReleaseDefinitionDeployStep{ Id: converter.Int(d["id"].(int)), Tasks: &tasks, @@ -1825,7 +1826,7 @@ func expandReleaseDefinitionDeployStep(d map[string]interface{}) release.Release } func expandReleaseDeployPhase(d map[string]interface{}, t release.DeployPhaseTypes) ReleaseDeployPhase { - workflowTasks := expandReleaseWorkFlowTaskList(d["task"].([]interface{})) + workflowTasks := expandList(d["task"].([]interface{}), expandReleaseWorkFlowTask) var deploymentInput interface{} switch t { case release.DeployPhaseTypesValues.AgentBasedDeployment: @@ -2081,15 +2082,6 @@ func expandReleaseWorkFlowTask(d map[string]interface{}) release.WorkflowTask { Version: &version, } } -func expandReleaseWorkFlowTaskList(d []interface{}) []release.WorkflowTask { - vs := make([]release.WorkflowTask, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseWorkFlowTask(val)) - } - } - return vs -} func expandReleaseEnvironmentRetentionPolicy(d map[string]interface{}) release.EnvironmentRetentionPolicy { return release.EnvironmentRetentionPolicy{ @@ -2216,7 +2208,7 @@ func expandReleaseDefinitionApprovalsListFirstOrNil(d []interface{}, approvalOpt } func expandReleaseDefinitionGate(d map[string]interface{}) release.ReleaseDefinitionGate { - workflowTasks := expandReleaseWorkFlowTaskList(d["task"].([]interface{})) + workflowTasks := expandList(d["task"].([]interface{}), expandReleaseWorkFlowTask) return release.ReleaseDefinitionGate{ Tasks: &workflowTasks, } From 855a05ad150d32e4d056edf07b214e88b4e6cc3b Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Fri, 3 Jun 2022 21:59:40 -0700 Subject: [PATCH 34/41] use generic func --- .../release/resource_release_definition.go | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 0f70ab9bb..24db8c34a 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1451,7 +1451,8 @@ type Release interface { MachineGroupDeploymentMultiple | release.MultiConfigInput | release.AgentSpecification | - release.WorkflowTask + release.WorkflowTask | + release.EnvironmentRetentionPolicy } func expandStringMapString(d map[string]interface{}) map[string]string { @@ -1667,7 +1668,7 @@ func expandReleaseDefinitionEnvironment(d map[string]interface{}, rank int) rele variables := expandReleaseConfigurationVariableValueList(d["variable"].([]interface{})) demands := expandList(d["demand"].([]interface{}), expandReleaseDefinitionDemand) environmentOptions := expandFirstOrNil(d["environment_options"].([]interface{}), expandReleaseEnvironmentOptions) - retentionPolicy := expandReleaseEnvironmentRetentionPolicyListFirstOrNil(d["retention_policy"].([]interface{})) + retentionPolicy := expandFirstOrNil(d["retention_policy"].([]interface{}), expandReleaseEnvironmentRetentionPolicy) preApprovalOptions := expandReleaseApprovalOptionsListFirstOrNil(d["approval_options"].([]interface{}), release.ApprovalExecutionOrderValues.BeforeGates) postApprovalOptions := expandReleaseApprovalOptionsListFirstOrNil(d["approval_options"].([]interface{}), release.ApprovalExecutionOrderValues.AfterSuccessfulGates) preDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["pre_deploy_approval"].([]interface{}), preApprovalOptions) @@ -2090,22 +2091,6 @@ func expandReleaseEnvironmentRetentionPolicy(d map[string]interface{}) release.E ReleasesToKeep: converter.Int(d["releases_to_keep"].(int)), } } -func expandReleaseEnvironmentRetentionPolicyList(d []interface{}) []release.EnvironmentRetentionPolicy { - vs := make([]release.EnvironmentRetentionPolicy, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseEnvironmentRetentionPolicy(val)) - } - } - return vs -} -func expandReleaseEnvironmentRetentionPolicyListFirstOrNil(d []interface{}) *release.EnvironmentRetentionPolicy { - d2 := expandReleaseEnvironmentRetentionPolicyList(d) - if len(d2) != 1 { - return nil - } - return &d2[0] -} func automaticReleaseDefinitionApprovalStep() release.ReleaseDefinitionApprovalStep { return release.ReleaseDefinitionApprovalStep{ From f6c2e5eb883d34aaa3bd7ead305405d7258612a3 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Fri, 3 Jun 2022 22:01:17 -0700 Subject: [PATCH 35/41] use generic func --- .../service/release/resource_release_definition.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 24db8c34a..d12268d53 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1452,7 +1452,8 @@ type Release interface { release.MultiConfigInput | release.AgentSpecification | release.WorkflowTask | - release.EnvironmentRetentionPolicy + release.EnvironmentRetentionPolicy | + release.ReleaseDefinitionGate } func expandStringMapString(d map[string]interface{}) map[string]string { @@ -2198,18 +2199,9 @@ func expandReleaseDefinitionGate(d map[string]interface{}) release.ReleaseDefini Tasks: &workflowTasks, } } -func expandReleaseDefinitionGateList(d []interface{}) []release.ReleaseDefinitionGate { - vs := make([]release.ReleaseDefinitionGate, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseDefinitionGate(val)) - } - } - return vs -} func expandReleaseDefinitionGatesStep(d map[string]interface{}) release.ReleaseDefinitionGatesStep { - gates := expandReleaseDefinitionGateList(d["gate"].([]interface{})) + gates := expandList(d["gate"].([]interface{}), expandReleaseDefinitionGate) return release.ReleaseDefinitionGatesStep{ Id: converter.Int(d["id"].(int)), Gates: &gates, From 7b1c76524be1a3505b01427af3c740e9179aeb05 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Fri, 3 Jun 2022 22:02:29 -0700 Subject: [PATCH 36/41] use generic func --- .../release/resource_release_definition.go | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index d12268d53..116f20e08 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1453,7 +1453,8 @@ type Release interface { release.AgentSpecification | release.WorkflowTask | release.EnvironmentRetentionPolicy | - release.ReleaseDefinitionGate + release.ReleaseDefinitionGate | + release.ReleaseDefinitionGatesStep } func expandStringMapString(d map[string]interface{}) map[string]string { @@ -1676,8 +1677,8 @@ func expandReleaseDefinitionEnvironment(d map[string]interface{}, rank int) rele postDeployApprovals := expandReleaseDefinitionApprovalsListFirstOrNil(d["post_deploy_approval"].([]interface{}), postApprovalOptions) properties := expandInterfaceFirstOrNil(d["properties"].([]interface{}), expandReleaseEnvironmentProperties) deployPhases := expandJobsList(d["job"].([]interface{})) - preDeploymentGates := expandReleaseDefinitionGatesStepListFirstOrNil(d["pre_deploy_gate"].([]interface{})) - postDeploymentGates := expandReleaseDefinitionGatesStepListFirstOrNil(d["post_deploy_gate"].([]interface{})) + preDeploymentGates := expandFirstOrNil(d["pre_deploy_gate"].([]interface{}), expandReleaseDefinitionGatesStep) + postDeploymentGates := expandFirstOrNil(d["post_deploy_gate"].([]interface{}), expandReleaseDefinitionGatesStep) afterStageConditions := expandReleaseConditionList(d["after_stage"].([]interface{}), release.ConditionTypeValues.EnvironmentState, nil) afterReleaseConditions := expandReleaseConditionList(d["after_release"].([]interface{}), release.ConditionTypeValues.Event, converter.String("ReleaseStarted")) artifactFilters := expandReleaseConditionArtifactFilterList(d["artifact_filter"].([]interface{})) @@ -2207,22 +2208,6 @@ func expandReleaseDefinitionGatesStep(d map[string]interface{}) release.ReleaseD Gates: &gates, } } -func expandReleaseDefinitionGatesStepList(d []interface{}) []release.ReleaseDefinitionGatesStep { - vs := make([]release.ReleaseDefinitionGatesStep, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseDefinitionGatesStep(val)) - } - } - return vs -} -func expandReleaseDefinitionGatesStepListFirstOrNil(d []interface{}) *release.ReleaseDefinitionGatesStep { - d2 := expandReleaseDefinitionGatesStepList(d) - if len(d2) != 1 { - return nil - } - return &d2[0] -} func flattenStringList(list []*string) []interface{} { vs := make([]interface{}, 0, len(list)) From 391c5d29000829cbfaaa4ab2875aec74f040ff9a Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Fri, 3 Jun 2022 22:03:55 -0700 Subject: [PATCH 37/41] use generic func --- .../service/release/resource_release_definition.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 116f20e08..1c524b2ba 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -1454,7 +1454,8 @@ type Release interface { release.WorkflowTask | release.EnvironmentRetentionPolicy | release.ReleaseDefinitionGate | - release.ReleaseDefinitionGatesStep + release.ReleaseDefinitionGatesStep | + ReleaseHostedAzurePipelines } func expandStringMapString(d map[string]interface{}) map[string]string { @@ -1908,17 +1909,8 @@ func expandReleaseHostedAzurePipelines(d map[string]interface{}) ReleaseHostedAz QueueID: converter.Int(d["agent_pool_id"].(int)), } } -func expandReleaseHostedAzurePipelinesList(d []interface{}) []ReleaseHostedAzurePipelines { - vs := make([]ReleaseHostedAzurePipelines, 0, len(d)) - for _, v := range d { - if val, ok := v.(map[string]interface{}); ok { - vs = append(vs, expandReleaseHostedAzurePipelines(val)) - } - } - return vs -} func expandReleaseHostedAzurePipelinesListFirstOrNil(d []interface{}) (*release.AgentSpecification, int) { - d2 := expandReleaseHostedAzurePipelinesList(d) + d2 := expandList(d, expandReleaseHostedAzurePipelines) if len(d2) != 1 { return nil, 0 } From 685bbae4fa895855d2f1a1ca90f69711fc97968a Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Fri, 3 Jun 2022 22:31:38 -0700 Subject: [PATCH 38/41] lint --- .../release/resource_release_definition.go | 41 ++++--------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 1c524b2ba..6e55abd57 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -158,7 +158,7 @@ func ResourceReleaseDefinition() *schema.Resource { task := strings.Split(v, "@") taskName := task[0] if _, ok := taskagent.TaskNameToUUID[taskName]; !ok { - return nil, []error{fmt.Errorf("unkown task %q", taskName)} + return nil, []error{fmt.Errorf("unknown task %q", taskName)} } return nil, nil }, @@ -1946,7 +1946,7 @@ func expandReleaseAgentDeploymentInput(d map[string]interface{}) AgentDeployment agentPoolHostedAzurePipelines, queueID := expandReleaseHostedAzurePipelinesListFirstOrNil(d["agent_pool_hosted_azure_pipelines"].([]interface{})) //if agentPoolPrivate != nil && agentPoolHostedAzurePipelines != nil { // TODO : how to solve - // return nil, fmt.Errorf("conflit %s and %s specify only one", "agent_pool_hosted_azure_pipelines", "agent_pool_private") + // return nil, fmt.Errorf("conflict %s and %s specify only one", "agent_pool_hosted_azure_pipelines", "agent_pool_private") //} var agentSpecification *release.AgentSpecification if agentPoolHostedAzurePipelines != nil { @@ -1961,7 +1961,7 @@ func expandReleaseAgentDeploymentInput(d map[string]interface{}) AgentDeployment multiConfiguration := expandFirstOrNil(d["multi_configuration"].([]interface{}), expandReleaseMultiConfigInput) multiAgent := expandFirstOrNil(d["multi_agent"].([]interface{}), expandReleaseParallelExecutionInputBase) //if multiConfiguration != nil && multiAgent != nil { // TODO : how to solve - // return nil, fmt.Errorf("conflit %s and %s specify only one", "multi_configuration", "multi_agent") + // return nil, fmt.Errorf("conflict %s and %s specify only one", "multi_configuration", "multi_agent") //} if multiConfiguration != nil { parallelExecution = multiConfiguration @@ -2003,22 +2003,21 @@ func expandReleaseServerDeploymentInput(d map[string]interface{}) *ServerDeploym } func expandReleaseArtifactDownloadInputBase(d map[string]interface{}, t release.AgentArtifactType) release.ArtifactDownloadInputBase { - mode := ArtifactDownloadModeTypeValues.All - artifactItems := make([]string, 0, 0) - artifactItems = tfhelper.ExpandStringList(d["include"].([]interface{})) + var mode string + var artifactItems = tfhelper.ExpandStringList(d["include"].([]interface{})) if len(artifactItems) > 0 { if artifactItems[0] == "*" { artifactItems = []string{} - mode = ArtifactDownloadModeTypeValues.All + mode = string(ArtifactDownloadModeTypeValues.All) } else { - mode = ArtifactDownloadModeTypeValues.Selective + mode = string(ArtifactDownloadModeTypeValues.Selective) } } else { - mode = ArtifactDownloadModeTypeValues.Skip + mode = string(ArtifactDownloadModeTypeValues.Skip) } return release.ArtifactDownloadInputBase{ Alias: converter.String(d["artifact_alias"].(string)), - ArtifactDownloadMode: converter.String(string(mode)), + ArtifactDownloadMode: converter.String(mode), ArtifactItems: &artifactItems, ArtifactType: converter.String(strings.Title(string(t))), } @@ -2201,28 +2200,6 @@ func expandReleaseDefinitionGatesStep(d map[string]interface{}) release.ReleaseD } } -func flattenStringList(list []*string) []interface{} { - vs := make([]interface{}, 0, len(list)) - for _, v := range list { - vs = append(vs, *v) - } - return vs -} -func flattenStringSet(list []*string) *schema.Set { - return schema.NewSet(schema.HashString, flattenStringList(list)) -} - -func flattenIntList(list []*int) []interface{} { - vs := make([]interface{}, 0, len(list)) - for _, v := range list { - vs = append(vs, *v) - } - return vs -} -func flattenIntSet(list []*int) *schema.Set { - return schema.NewSet(schema.HashString, flattenIntList(list)) -} - func flattenStringMap(m *map[string]string) map[string]interface{} { if m == nil { return nil From 056f53c9e3756a3586a255838365e00a4aa9fa83 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Fri, 3 Jun 2022 22:34:44 -0700 Subject: [PATCH 39/41] lint again --- .../internal/service/release/resource_release_definition.go | 1 - 1 file changed, 1 deletion(-) diff --git a/azuredevops/internal/service/release/resource_release_definition.go b/azuredevops/internal/service/release/resource_release_definition.go index 6e55abd57..4750ef479 100644 --- a/azuredevops/internal/service/release/resource_release_definition.go +++ b/azuredevops/internal/service/release/resource_release_definition.go @@ -32,7 +32,6 @@ This fixes the behaviour of apply. Otherwise apply will sometimes result in chan */ func ResourceReleaseDefinition() *schema.Resource { - id := &schema.Schema{ Type: schema.TypeInt, Computed: true, From e2c3e579f403867cdc489b76d17e08bce4739261 Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Fri, 3 Jun 2022 22:52:20 -0700 Subject: [PATCH 40/41] fix imports for test --- .../acceptancetests/resource_release_definition_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/azuredevops/internal/acceptancetests/resource_release_definition_test.go b/azuredevops/internal/acceptancetests/resource_release_definition_test.go index 3105f13dd..950ac4406 100644 --- a/azuredevops/internal/acceptancetests/resource_release_definition_test.go +++ b/azuredevops/internal/acceptancetests/resource_release_definition_test.go @@ -6,10 +6,12 @@ package acceptancetests import ( "fmt" - "github.com/microsoft/azure-devops-go-api/azuredevops/release" "strconv" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/microsoft/azure-devops-go-api/azuredevops/v6/release" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/acceptancetests/testutils" "github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/client" ) From 847eaf7dd9541f3c25863696c08fe4edf4b6860a Mon Sep 17 00:00:00 2001 From: Kalarrs Topham Date: Fri, 3 Jun 2022 23:04:37 -0700 Subject: [PATCH 41/41] using v6 not standalone --- .../azuredevops/release/client.go | 1583 --------- .../azuredevops/release/models.go | 3064 ----------------- vendor/modules.txt | 1 - 3 files changed, 4648 deletions(-) delete mode 100644 vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/client.go delete mode 100644 vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/models.go diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/client.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/client.go deleted file mode 100644 index dc6f66b5f..000000000 --- a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/client.go +++ /dev/null @@ -1,1583 +0,0 @@ -// -------------------------------------------------------------------------------------------- -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// -------------------------------------------------------------------------------------------- -// Generated file, DO NOT EDIT -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// -------------------------------------------------------------------------------------------- - -package release - -import ( - "bytes" - "context" - "encoding/json" - "github.com/google/uuid" - "github.com/microsoft/azure-devops-go-api/azuredevops" - "io" - "net/http" - "net/url" - "strconv" - "strings" -) - -var ResourceAreaId, _ = uuid.Parse("efc2f575-36ef-48e9-b672-0c6fb4a48ac5") - -type Client interface { - // [Preview API] Creates a new folder. - CreateFolder(context.Context, CreateFolderArgs) (*Folder, error) - // Create a release. - CreateRelease(context.Context, CreateReleaseArgs) (*Release, error) - // Create a release definition - CreateReleaseDefinition(context.Context, CreateReleaseDefinitionArgs) (*ReleaseDefinition, error) - // [Preview API] Deletes a definition folder for given folder name and path and all it's existing definitions. - DeleteFolder(context.Context, DeleteFolderArgs) error - // Delete a release definition. - DeleteReleaseDefinition(context.Context, DeleteReleaseDefinitionArgs) error - // Get a list of approvals - GetApprovals(context.Context, GetApprovalsArgs) (*GetApprovalsResponseValue, error) - // [Preview API] Get release definition for a given definitionId and revision - GetDefinitionRevision(context.Context, GetDefinitionRevisionArgs) (io.ReadCloser, error) - GetDeployments(context.Context, GetDeploymentsArgs) (*GetDeploymentsResponseValue, error) - // [Preview API] Gets folders. - GetFolders(context.Context, GetFoldersArgs) (*[]Folder, error) - // [Preview API] Get logs for a release Id. - GetLogs(context.Context, GetLogsArgs) (io.ReadCloser, error) - // Get manual intervention for a given release and manual intervention id. - GetManualIntervention(context.Context, GetManualInterventionArgs) (*ManualIntervention, error) - // List all manual interventions for a given release. - GetManualInterventions(context.Context, GetManualInterventionsArgs) (*[]ManualIntervention, error) - // Get a Release - GetRelease(context.Context, GetReleaseArgs) (*Release, error) - // Get a release definition. - GetReleaseDefinition(context.Context, GetReleaseDefinitionArgs) (*ReleaseDefinition, error) - // [Preview API] Get revision history for a release definition - GetReleaseDefinitionHistory(context.Context, GetReleaseDefinitionHistoryArgs) (*[]ReleaseDefinitionRevision, error) - // Get a list of release definitions. - GetReleaseDefinitions(context.Context, GetReleaseDefinitionsArgs) (*GetReleaseDefinitionsResponseValue, error) - // [Preview API] Get a release environment. - GetReleaseEnvironment(context.Context, GetReleaseEnvironmentArgs) (*ReleaseEnvironment, error) - // Get release for a given revision number. - GetReleaseRevision(context.Context, GetReleaseRevisionArgs) (io.ReadCloser, error) - // Get a list of releases - GetReleases(context.Context, GetReleasesArgs) (*GetReleasesResponseValue, error) - // [Preview API] Get a release task attachment. - GetReleaseTaskAttachmentContent(context.Context, GetReleaseTaskAttachmentContentArgs) (io.ReadCloser, error) - // [Preview API] Get the release task attachments. - GetReleaseTaskAttachments(context.Context, GetReleaseTaskAttachmentsArgs) (*[]ReleaseTaskAttachment, error) - // [Preview API] Gets the task log of a release as a plain text file. - GetTaskLog(context.Context, GetTaskLogArgs) (io.ReadCloser, error) - // [Preview API] Updates an existing folder at given existing path. - UpdateFolder(context.Context, UpdateFolderArgs) (*Folder, error) - // [Preview API] Updates the gate for a deployment. - UpdateGates(context.Context, UpdateGatesArgs) (*ReleaseGates, error) - // Update manual intervention. - UpdateManualIntervention(context.Context, UpdateManualInterventionArgs) (*ManualIntervention, error) - // Update a complete release object. - UpdateRelease(context.Context, UpdateReleaseArgs) (*Release, error) - // Update status of an approval - UpdateReleaseApproval(context.Context, UpdateReleaseApprovalArgs) (*ReleaseApproval, error) - // Update a release definition. - UpdateReleaseDefinition(context.Context, UpdateReleaseDefinitionArgs) (*ReleaseDefinition, error) - // [Preview API] Update the status of a release environment - UpdateReleaseEnvironment(context.Context, UpdateReleaseEnvironmentArgs) (*ReleaseEnvironment, error) - // Update few properties of a release. - UpdateReleaseResource(context.Context, UpdateReleaseResourceArgs) (*Release, error) -} - -type ClientImpl struct { - Client azuredevops.Client -} - -func NewClient(ctx context.Context, connection *azuredevops.Connection) (Client, error) { - client, err := connection.GetClientByResourceAreaId(ctx, ResourceAreaId) - if err != nil { - return nil, err - } - return &ClientImpl{ - Client: *client, - }, nil -} - -// [Preview API] Creates a new folder. -func (client *ClientImpl) CreateFolder(ctx context.Context, args CreateFolderArgs) (*Folder, error) { - if args.Folder == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Folder"} - } - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - - body, marshalErr := json.Marshal(*args.Folder) - if marshalErr != nil { - return nil, marshalErr - } - locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea") - resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue Folder - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the CreateFolder function -type CreateFolderArgs struct { - // (required) Folder to create. - Folder *Folder - // (required) Project ID or project name - Project *string -} - -// Create a release. -func (client *ClientImpl) CreateRelease(ctx context.Context, args CreateReleaseArgs) (*Release, error) { - if args.ReleaseStartMetadata == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseStartMetadata"} - } - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - - body, marshalErr := json.Marshal(*args.ReleaseStartMetadata) - if marshalErr != nil { - return nil, marshalErr - } - locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") - resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue Release - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the CreateRelease function -type CreateReleaseArgs struct { - // (required) Metadata to create a release. - ReleaseStartMetadata *ReleaseStartMetadata - // (required) Project ID or project name - Project *string -} - -// Create a release definition -func (client *ClientImpl) CreateReleaseDefinition(ctx context.Context, args CreateReleaseDefinitionArgs) (*ReleaseDefinition, error) { - if args.ReleaseDefinition == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseDefinition"} - } - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - - body, marshalErr := json.Marshal(*args.ReleaseDefinition) - if marshalErr != nil { - return nil, marshalErr - } - locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") - resp, err := client.Client.Send(ctx, http.MethodPost, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue ReleaseDefinition - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the CreateReleaseDefinition function -type CreateReleaseDefinitionArgs struct { - // (required) release definition object to create. - ReleaseDefinition *ReleaseDefinition - // (required) Project ID or project name - Project *string -} - -// [Preview API] Deletes a definition folder for given folder name and path and all it's existing definitions. -func (client *ClientImpl) DeleteFolder(ctx context.Context, args DeleteFolderArgs) error { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.Path == nil || *args.Path == "" { - return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Path"} - } - routeValues["path"] = *args.Path - - locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea") - _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1-preview.2", routeValues, nil, nil, "", "application/json", nil) - if err != nil { - return err - } - - return nil -} - -// Arguments for the DeleteFolder function -type DeleteFolderArgs struct { - // (required) Project ID or project name - Project *string - // (required) Path of the folder to delete. - Path *string -} - -// Delete a release definition. -func (client *ClientImpl) DeleteReleaseDefinition(ctx context.Context, args DeleteReleaseDefinitionArgs) error { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.DefinitionId == nil { - return &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} - } - routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) - - queryParams := url.Values{} - if args.Comment != nil { - queryParams.Add("comment", *args.Comment) - } - if args.ForceDelete != nil { - queryParams.Add("forceDelete", strconv.FormatBool(*args.ForceDelete)) - } - locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") - _, err := client.Client.Send(ctx, http.MethodDelete, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) - if err != nil { - return err - } - - return nil -} - -// Arguments for the DeleteReleaseDefinition function -type DeleteReleaseDefinitionArgs struct { - // (required) Project ID or project name - Project *string - // (required) Id of the release definition. - DefinitionId *int - // (optional) Comment for deleting a release definition. - Comment *string - // (optional) 'true' to automatically cancel any in-progress release deployments and proceed with release definition deletion . Default is 'false'. - ForceDelete *bool -} - -// Get a list of approvals -func (client *ClientImpl) GetApprovals(ctx context.Context, args GetApprovalsArgs) (*GetApprovalsResponseValue, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - - queryParams := url.Values{} - if args.AssignedToFilter != nil { - queryParams.Add("assignedToFilter", *args.AssignedToFilter) - } - if args.StatusFilter != nil { - queryParams.Add("statusFilter", string(*args.StatusFilter)) - } - if args.ReleaseIdsFilter != nil { - var stringList []string - for _, item := range *args.ReleaseIdsFilter { - stringList = append(stringList, strconv.Itoa(item)) - } - listAsString := strings.Join((stringList)[:], ",") - queryParams.Add("releaseIdsFilter", listAsString) - } - if args.TypeFilter != nil { - queryParams.Add("typeFilter", string(*args.TypeFilter)) - } - if args.Top != nil { - queryParams.Add("top", strconv.Itoa(*args.Top)) - } - if args.ContinuationToken != nil { - queryParams.Add("continuationToken", strconv.Itoa(*args.ContinuationToken)) - } - if args.QueryOrder != nil { - queryParams.Add("queryOrder", string(*args.QueryOrder)) - } - if args.IncludeMyGroupApprovals != nil { - queryParams.Add("includeMyGroupApprovals", strconv.FormatBool(*args.IncludeMyGroupApprovals)) - } - locationId, _ := uuid.Parse("b47c6458-e73b-47cb-a770-4df1e8813a91") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue GetApprovalsResponseValue - responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) - err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) - return &responseValue, err -} - -// Arguments for the GetApprovals function -type GetApprovalsArgs struct { - // (required) Project ID or project name - Project *string - // (optional) Approvals assigned to this user. - AssignedToFilter *string - // (optional) Approvals with this status. Default is 'pending'. - StatusFilter *ApprovalStatus - // (optional) Approvals for release id(s) mentioned in the filter. Multiple releases can be mentioned by separating them with ',' e.g. releaseIdsFilter=1,2,3,4. - ReleaseIdsFilter *[]int - // (optional) Approval with this type. - TypeFilter *ApprovalType - // (optional) Number of approvals to get. Default is 50. - Top *int - // (optional) Gets the approvals after the continuation token provided. - ContinuationToken *int - // (optional) Gets the results in the defined order of created approvals. Default is 'descending'. - QueryOrder *ReleaseQueryOrder - // (optional) 'true' to include my group approvals. Default is 'false'. - IncludeMyGroupApprovals *bool -} - -// Return type for the GetApprovals function -type GetApprovalsResponseValue struct { - Value []ReleaseApproval - // The continuation token to be used to get the next page of results. - ContinuationToken string -} - -// [Preview API] Get release definition for a given definitionId and revision -func (client *ClientImpl) GetDefinitionRevision(ctx context.Context, args GetDefinitionRevisionArgs) (io.ReadCloser, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.DefinitionId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} - } - routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) - if args.Revision == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Revision"} - } - routeValues["revision"] = strconv.Itoa(*args.Revision) - - locationId, _ := uuid.Parse("258b82e0-9d41-43f3-86d6-fef14ddd44bc") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "text/plain", nil) - if err != nil { - return nil, err - } - - return resp.Body, err -} - -// Arguments for the GetDefinitionRevision function -type GetDefinitionRevisionArgs struct { - // (required) Project ID or project name - Project *string - // (required) Id of the definition. - DefinitionId *int - // (required) Id of the revision. - Revision *int -} - -func (client *ClientImpl) GetDeployments(ctx context.Context, args GetDeploymentsArgs) (*GetDeploymentsResponseValue, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - - queryParams := url.Values{} - if args.DefinitionId != nil { - queryParams.Add("definitionId", strconv.Itoa(*args.DefinitionId)) - } - if args.DefinitionEnvironmentId != nil { - queryParams.Add("definitionEnvironmentId", strconv.Itoa(*args.DefinitionEnvironmentId)) - } - if args.CreatedBy != nil { - queryParams.Add("createdBy", *args.CreatedBy) - } - if args.MinModifiedTime != nil { - queryParams.Add("minModifiedTime", (*args.MinModifiedTime).AsQueryParameter()) - } - if args.MaxModifiedTime != nil { - queryParams.Add("maxModifiedTime", (*args.MaxModifiedTime).AsQueryParameter()) - } - if args.DeploymentStatus != nil { - queryParams.Add("deploymentStatus", string(*args.DeploymentStatus)) - } - if args.OperationStatus != nil { - queryParams.Add("operationStatus", string(*args.OperationStatus)) - } - if args.LatestAttemptsOnly != nil { - queryParams.Add("latestAttemptsOnly", strconv.FormatBool(*args.LatestAttemptsOnly)) - } - if args.QueryOrder != nil { - queryParams.Add("queryOrder", string(*args.QueryOrder)) - } - if args.Top != nil { - queryParams.Add("$top", strconv.Itoa(*args.Top)) - } - if args.ContinuationToken != nil { - queryParams.Add("continuationToken", strconv.Itoa(*args.ContinuationToken)) - } - if args.CreatedFor != nil { - queryParams.Add("createdFor", *args.CreatedFor) - } - if args.MinStartedTime != nil { - queryParams.Add("minStartedTime", (*args.MinStartedTime).AsQueryParameter()) - } - if args.MaxStartedTime != nil { - queryParams.Add("maxStartedTime", (*args.MaxStartedTime).AsQueryParameter()) - } - if args.SourceBranch != nil { - queryParams.Add("sourceBranch", *args.SourceBranch) - } - locationId, _ := uuid.Parse("b005ef73-cddc-448e-9ba2-5193bf36b19f") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue GetDeploymentsResponseValue - responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) - err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) - return &responseValue, err -} - -// Arguments for the GetDeployments function -type GetDeploymentsArgs struct { - // (required) Project ID or project name - Project *string - // (optional) - DefinitionId *int - // (optional) - DefinitionEnvironmentId *int - // (optional) - CreatedBy *string - // (optional) - MinModifiedTime *azuredevops.Time - // (optional) - MaxModifiedTime *azuredevops.Time - // (optional) - DeploymentStatus *DeploymentStatus - // (optional) - OperationStatus *DeploymentOperationStatus - // (optional) - LatestAttemptsOnly *bool - // (optional) - QueryOrder *ReleaseQueryOrder - // (optional) - Top *int - // (optional) - ContinuationToken *int - // (optional) - CreatedFor *string - // (optional) - MinStartedTime *azuredevops.Time - // (optional) - MaxStartedTime *azuredevops.Time - // (optional) - SourceBranch *string -} - -// Return type for the GetDeployments function -type GetDeploymentsResponseValue struct { - Value []Deployment - // The continuation token to be used to get the next page of results. - ContinuationToken string -} - -// [Preview API] Gets folders. -func (client *ClientImpl) GetFolders(ctx context.Context, args GetFoldersArgs) (*[]Folder, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.Path != nil && *args.Path != "" { - routeValues["path"] = *args.Path - } - - queryParams := url.Values{} - if args.QueryOrder != nil { - queryParams.Add("queryOrder", string(*args.QueryOrder)) - } - locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue []Folder - err = client.Client.UnmarshalCollectionBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the GetFolders function -type GetFoldersArgs struct { - // (required) Project ID or project name - Project *string - // (optional) Path of the folder. - Path *string - // (optional) Gets the results in the defined order. Default is 'None'. - QueryOrder *FolderPathQueryOrder -} - -// [Preview API] Get logs for a release Id. -func (client *ClientImpl) GetLogs(ctx context.Context, args GetLogsArgs) (io.ReadCloser, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ReleaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} - } - routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) - - locationId, _ := uuid.Parse("c37fbab5-214b-48e4-a55b-cb6b4f6e4038") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, nil, nil, "", "application/zip", nil) - if err != nil { - return nil, err - } - - return resp.Body, err -} - -// Arguments for the GetLogs function -type GetLogsArgs struct { - // (required) Project ID or project name - Project *string - // (required) Id of the release. - ReleaseId *int -} - -// Get manual intervention for a given release and manual intervention id. -func (client *ClientImpl) GetManualIntervention(ctx context.Context, args GetManualInterventionArgs) (*ManualIntervention, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ReleaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} - } - routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) - if args.ManualInterventionId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ManualInterventionId"} - } - routeValues["manualInterventionId"] = strconv.Itoa(*args.ManualInterventionId) - - locationId, _ := uuid.Parse("616c46e4-f370-4456-adaa-fbaf79c7b79e") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue ManualIntervention - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the GetManualIntervention function -type GetManualInterventionArgs struct { - // (required) Project ID or project name - Project *string - // (required) Id of the release. - ReleaseId *int - // (required) Id of the manual intervention. - ManualInterventionId *int -} - -// List all manual interventions for a given release. -func (client *ClientImpl) GetManualInterventions(ctx context.Context, args GetManualInterventionsArgs) (*[]ManualIntervention, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ReleaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} - } - routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) - - locationId, _ := uuid.Parse("616c46e4-f370-4456-adaa-fbaf79c7b79e") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, nil, nil, "", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue []ManualIntervention - err = client.Client.UnmarshalCollectionBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the GetManualInterventions function -type GetManualInterventionsArgs struct { - // (required) Project ID or project name - Project *string - // (required) Id of the release. - ReleaseId *int -} - -// Get a Release -func (client *ClientImpl) GetRelease(ctx context.Context, args GetReleaseArgs) (*Release, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ReleaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} - } - routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) - - queryParams := url.Values{} - if args.ApprovalFilters != nil { - queryParams.Add("approvalFilters", string(*args.ApprovalFilters)) - } - if args.PropertyFilters != nil { - listAsString := strings.Join((*args.PropertyFilters)[:], ",") - queryParams.Add("propertyFilters", listAsString) - } - if args.Expand != nil { - queryParams.Add("$expand", string(*args.Expand)) - } - if args.TopGateRecords != nil { - queryParams.Add("$topGateRecords", strconv.Itoa(*args.TopGateRecords)) - } - locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue Release - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the GetRelease function -type GetReleaseArgs struct { - // (required) Project ID or project name - Project *string - // (required) Id of the release. - ReleaseId *int - // (optional) A filter which would allow fetching approval steps selectively based on whether it is automated, or manual. This would also decide whether we should fetch pre and post approval snapshots. Assumes All by default - ApprovalFilters *ApprovalFilters - // (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Release will contain values for the specified property Ids (if they exist). If not set, properties will not be included. - PropertyFilters *[]string - // (optional) A property that should be expanded in the release. - Expand *SingleReleaseExpands - // (optional) Number of release gate records to get. Default is 5. - TopGateRecords *int -} - -// Get a release definition. -func (client *ClientImpl) GetReleaseDefinition(ctx context.Context, args GetReleaseDefinitionArgs) (*ReleaseDefinition, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.DefinitionId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} - } - routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) - - queryParams := url.Values{} - if args.PropertyFilters != nil { - listAsString := strings.Join((*args.PropertyFilters)[:], ",") - queryParams.Add("propertyFilters", listAsString) - } - locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue ReleaseDefinition - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the GetReleaseDefinition function -type GetReleaseDefinitionArgs struct { - // (required) Project ID or project name - Project *string - // (required) Id of the release definition. - DefinitionId *int - // (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Release Definition will contain values for the specified property Ids (if they exist). If not set, properties will not be included. - PropertyFilters *[]string -} - -// [Preview API] Get revision history for a release definition -func (client *ClientImpl) GetReleaseDefinitionHistory(ctx context.Context, args GetReleaseDefinitionHistoryArgs) (*[]ReleaseDefinitionRevision, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.DefinitionId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.DefinitionId"} - } - routeValues["definitionId"] = strconv.Itoa(*args.DefinitionId) - - locationId, _ := uuid.Parse("258b82e0-9d41-43f3-86d6-fef14ddd44bc") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue []ReleaseDefinitionRevision - err = client.Client.UnmarshalCollectionBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the GetReleaseDefinitionHistory function -type GetReleaseDefinitionHistoryArgs struct { - // (required) Project ID or project name - Project *string - // (required) Id of the definition. - DefinitionId *int -} - -// Get a list of release definitions. -func (client *ClientImpl) GetReleaseDefinitions(ctx context.Context, args GetReleaseDefinitionsArgs) (*GetReleaseDefinitionsResponseValue, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - - queryParams := url.Values{} - if args.SearchText != nil { - queryParams.Add("searchText", *args.SearchText) - } - if args.Expand != nil { - queryParams.Add("$expand", string(*args.Expand)) - } - if args.ArtifactType != nil { - queryParams.Add("artifactType", *args.ArtifactType) - } - if args.ArtifactSourceId != nil { - queryParams.Add("artifactSourceId", *args.ArtifactSourceId) - } - if args.Top != nil { - queryParams.Add("$top", strconv.Itoa(*args.Top)) - } - if args.ContinuationToken != nil { - queryParams.Add("continuationToken", *args.ContinuationToken) - } - if args.QueryOrder != nil { - queryParams.Add("queryOrder", string(*args.QueryOrder)) - } - if args.Path != nil { - queryParams.Add("path", *args.Path) - } - if args.IsExactNameMatch != nil { - queryParams.Add("isExactNameMatch", strconv.FormatBool(*args.IsExactNameMatch)) - } - if args.TagFilter != nil { - listAsString := strings.Join((*args.TagFilter)[:], ",") - queryParams.Add("tagFilter", listAsString) - } - if args.PropertyFilters != nil { - listAsString := strings.Join((*args.PropertyFilters)[:], ",") - queryParams.Add("propertyFilters", listAsString) - } - if args.DefinitionIdFilter != nil { - listAsString := strings.Join((*args.DefinitionIdFilter)[:], ",") - queryParams.Add("definitionIdFilter", listAsString) - } - if args.IsDeleted != nil { - queryParams.Add("isDeleted", strconv.FormatBool(*args.IsDeleted)) - } - if args.SearchTextContainsFolderName != nil { - queryParams.Add("searchTextContainsFolderName", strconv.FormatBool(*args.SearchTextContainsFolderName)) - } - locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue GetReleaseDefinitionsResponseValue - responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) - err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) - return &responseValue, err -} - -// Arguments for the GetReleaseDefinitions function -type GetReleaseDefinitionsArgs struct { - // (required) Project ID or project name - Project *string - // (optional) Get release definitions with names containing searchText. - SearchText *string - // (optional) The properties that should be expanded in the list of Release definitions. - Expand *ReleaseDefinitionExpands - // (optional) Release definitions with given artifactType will be returned. Values can be Build, Jenkins, GitHub, Nuget, Team Build (external), ExternalTFSBuild, Git, TFVC, ExternalTfsXamlBuild. - ArtifactType *string - // (optional) Release definitions with given artifactSourceId will be returned. e.g. For build it would be {projectGuid}:{BuildDefinitionId}, for Jenkins it would be {JenkinsConnectionId}:{JenkinsDefinitionId}, for TfsOnPrem it would be {TfsOnPremConnectionId}:{ProjectName}:{TfsOnPremDefinitionId}. For third-party artifacts e.g. TeamCity, BitBucket you may refer 'uniqueSourceIdentifier' inside vss-extension.json at https://github.com/Microsoft/vsts-rm-extensions/blob/master/Extensions. - ArtifactSourceId *string - // (optional) Number of release definitions to get. - Top *int - // (optional) Gets the release definitions after the continuation token provided. - ContinuationToken *string - // (optional) Gets the results in the defined order. Default is 'IdAscending'. - QueryOrder *ReleaseDefinitionQueryOrder - // (optional) Gets the release definitions under the specified path. - Path *string - // (optional) 'true'to gets the release definitions with exact match as specified in searchText. Default is 'false'. - IsExactNameMatch *bool - // (optional) A comma-delimited list of tags. Only release definitions with these tags will be returned. - TagFilter *[]string - // (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Release Definitions will contain values for the specified property Ids (if they exist). If not set, properties will not be included. Note that this will not filter out any Release Definition from results irrespective of whether it has property set or not. - PropertyFilters *[]string - // (optional) A comma-delimited list of release definitions to retrieve. - DefinitionIdFilter *[]string - // (optional) 'true' to get release definitions that has been deleted. Default is 'false' - IsDeleted *bool - // (optional) 'true' to get the release definitions under the folder with name as specified in searchText. Default is 'false'. - SearchTextContainsFolderName *bool -} - -// Return type for the GetReleaseDefinitions function -type GetReleaseDefinitionsResponseValue struct { - Value []ReleaseDefinition - // The continuation token to be used to get the next page of results. - ContinuationToken string -} - -// [Preview API] Get a release environment. -func (client *ClientImpl) GetReleaseEnvironment(ctx context.Context, args GetReleaseEnvironmentArgs) (*ReleaseEnvironment, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ReleaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} - } - routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) - if args.EnvironmentId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} - } - routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) - - locationId, _ := uuid.Parse("a7e426b1-03dc-48af-9dfe-c98bac612dcb") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.6", routeValues, nil, nil, "", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue ReleaseEnvironment - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the GetReleaseEnvironment function -type GetReleaseEnvironmentArgs struct { - // (required) Project ID or project name - Project *string - // (required) Id of the release. - ReleaseId *int - // (required) Id of the release environment. - EnvironmentId *int -} - -// Get release for a given revision number. -func (client *ClientImpl) GetReleaseRevision(ctx context.Context, args GetReleaseRevisionArgs) (io.ReadCloser, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ReleaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} - } - routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) - - queryParams := url.Values{} - if args.DefinitionSnapshotRevision == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "definitionSnapshotRevision"} - } - queryParams.Add("definitionSnapshotRevision", strconv.Itoa(*args.DefinitionSnapshotRevision)) - locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "text/plain", nil) - if err != nil { - return nil, err - } - - return resp.Body, err -} - -// Arguments for the GetReleaseRevision function -type GetReleaseRevisionArgs struct { - // (required) Project ID or project name - Project *string - // (required) Id of the release. - ReleaseId *int - // (required) Definition snapshot revision number. - DefinitionSnapshotRevision *int -} - -// Get a list of releases -func (client *ClientImpl) GetReleases(ctx context.Context, args GetReleasesArgs) (*GetReleasesResponseValue, error) { - routeValues := make(map[string]string) - if args.Project != nil && *args.Project != "" { - routeValues["project"] = *args.Project - } - - queryParams := url.Values{} - if args.DefinitionId != nil { - queryParams.Add("definitionId", strconv.Itoa(*args.DefinitionId)) - } - if args.DefinitionEnvironmentId != nil { - queryParams.Add("definitionEnvironmentId", strconv.Itoa(*args.DefinitionEnvironmentId)) - } - if args.SearchText != nil { - queryParams.Add("searchText", *args.SearchText) - } - if args.CreatedBy != nil { - queryParams.Add("createdBy", *args.CreatedBy) - } - if args.StatusFilter != nil { - queryParams.Add("statusFilter", string(*args.StatusFilter)) - } - if args.EnvironmentStatusFilter != nil { - queryParams.Add("environmentStatusFilter", strconv.Itoa(*args.EnvironmentStatusFilter)) - } - if args.MinCreatedTime != nil { - queryParams.Add("minCreatedTime", (*args.MinCreatedTime).AsQueryParameter()) - } - if args.MaxCreatedTime != nil { - queryParams.Add("maxCreatedTime", (*args.MaxCreatedTime).AsQueryParameter()) - } - if args.QueryOrder != nil { - queryParams.Add("queryOrder", string(*args.QueryOrder)) - } - if args.Top != nil { - queryParams.Add("$top", strconv.Itoa(*args.Top)) - } - if args.ContinuationToken != nil { - queryParams.Add("continuationToken", strconv.Itoa(*args.ContinuationToken)) - } - if args.Expand != nil { - queryParams.Add("$expand", string(*args.Expand)) - } - if args.ArtifactTypeId != nil { - queryParams.Add("artifactTypeId", *args.ArtifactTypeId) - } - if args.SourceId != nil { - queryParams.Add("sourceId", *args.SourceId) - } - if args.ArtifactVersionId != nil { - queryParams.Add("artifactVersionId", *args.ArtifactVersionId) - } - if args.SourceBranchFilter != nil { - queryParams.Add("sourceBranchFilter", *args.SourceBranchFilter) - } - if args.IsDeleted != nil { - queryParams.Add("isDeleted", strconv.FormatBool(*args.IsDeleted)) - } - if args.TagFilter != nil { - listAsString := strings.Join((*args.TagFilter)[:], ",") - queryParams.Add("tagFilter", listAsString) - } - if args.PropertyFilters != nil { - listAsString := strings.Join((*args.PropertyFilters)[:], ",") - queryParams.Add("propertyFilters", listAsString) - } - if args.ReleaseIdFilter != nil { - var stringList []string - for _, item := range *args.ReleaseIdFilter { - stringList = append(stringList, strconv.Itoa(item)) - } - listAsString := strings.Join((stringList)[:], ",") - queryParams.Add("releaseIdFilter", listAsString) - } - if args.Path != nil { - queryParams.Add("path", *args.Path) - } - locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1", routeValues, queryParams, nil, "", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue GetReleasesResponseValue - responseValue.ContinuationToken = resp.Header.Get(azuredevops.HeaderKeyContinuationToken) - err = client.Client.UnmarshalCollectionBody(resp, &responseValue.Value) - return &responseValue, err -} - -// Arguments for the GetReleases function -type GetReleasesArgs struct { - // (optional) Project ID or project name - Project *string - // (optional) Releases from this release definition Id. - DefinitionId *int - // (optional) - DefinitionEnvironmentId *int - // (optional) Releases with names containing searchText. - SearchText *string - // (optional) Releases created by this user. - CreatedBy *string - // (optional) Releases that have this status. - StatusFilter *ReleaseStatus - // (optional) - EnvironmentStatusFilter *int - // (optional) Releases that were created after this time. - MinCreatedTime *azuredevops.Time - // (optional) Releases that were created before this time. - MaxCreatedTime *azuredevops.Time - // (optional) Gets the results in the defined order of created date for releases. Default is descending. - QueryOrder *ReleaseQueryOrder - // (optional) Number of releases to get. Default is 50. - Top *int - // (optional) Gets the releases after the continuation token provided. - ContinuationToken *int - // (optional) The property that should be expanded in the list of releases. - Expand *ReleaseExpands - // (optional) Releases with given artifactTypeId will be returned. Values can be Build, Jenkins, GitHub, Nuget, Team Build (external), ExternalTFSBuild, Git, TFVC, ExternalTfsXamlBuild. - ArtifactTypeId *string - // (optional) Unique identifier of the artifact used. e.g. For build it would be {projectGuid}:{BuildDefinitionId}, for Jenkins it would be {JenkinsConnectionId}:{JenkinsDefinitionId}, for TfsOnPrem it would be {TfsOnPremConnectionId}:{ProjectName}:{TfsOnPremDefinitionId}. For third-party artifacts e.g. TeamCity, BitBucket you may refer 'uniqueSourceIdentifier' inside vss-extension.json https://github.com/Microsoft/vsts-rm-extensions/blob/master/Extensions. - SourceId *string - // (optional) Releases with given artifactVersionId will be returned. E.g. in case of Build artifactType, it is buildId. - ArtifactVersionId *string - // (optional) Releases with given sourceBranchFilter will be returned. - SourceBranchFilter *string - // (optional) Gets the soft deleted releases, if true. - IsDeleted *bool - // (optional) A comma-delimited list of tags. Only releases with these tags will be returned. - TagFilter *[]string - // (optional) A comma-delimited list of extended properties to be retrieved. If set, the returned Releases will contain values for the specified property Ids (if they exist). If not set, properties will not be included. Note that this will not filter out any Release from results irrespective of whether it has property set or not. - PropertyFilters *[]string - // (optional) A comma-delimited list of releases Ids. Only releases with these Ids will be returned. - ReleaseIdFilter *[]int - // (optional) Releases under this folder path will be returned - Path *string -} - -// Return type for the GetReleases function -type GetReleasesResponseValue struct { - Value []Release - // The continuation token to be used to get the next page of results. - ContinuationToken string -} - -// [Preview API] Get a release task attachment. -func (client *ClientImpl) GetReleaseTaskAttachmentContent(ctx context.Context, args GetReleaseTaskAttachmentContentArgs) (io.ReadCloser, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ReleaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} - } - routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) - if args.EnvironmentId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} - } - routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) - if args.AttemptId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttemptId"} - } - routeValues["attemptId"] = strconv.Itoa(*args.AttemptId) - if args.PlanId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} - } - routeValues["planId"] = (*args.PlanId).String() - if args.TimelineId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TimelineId"} - } - routeValues["timelineId"] = (*args.TimelineId).String() - if args.RecordId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.RecordId"} - } - routeValues["recordId"] = (*args.RecordId).String() - if args.Type == nil || *args.Type == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} - } - routeValues["type"] = *args.Type - if args.Name == nil || *args.Name == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Name"} - } - routeValues["name"] = *args.Name - - locationId, _ := uuid.Parse("60b86efb-7b8c-4853-8f9f-aa142b77b479") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/octet-stream", nil) - if err != nil { - return nil, err - } - - return resp.Body, err -} - -// Arguments for the GetReleaseTaskAttachmentContent function -type GetReleaseTaskAttachmentContentArgs struct { - // (required) Project ID or project name - Project *string - // (required) Id of the release. - ReleaseId *int - // (required) Id of the release environment. - EnvironmentId *int - // (required) Attempt number of deployment. - AttemptId *int - // (required) Plan Id of the deploy phase. - PlanId *uuid.UUID - // (required) Timeline Id of the task. - TimelineId *uuid.UUID - // (required) Record Id of attachment. - RecordId *uuid.UUID - // (required) Type of the attachment. - Type *string - // (required) Name of the attachment. - Name *string -} - -// [Preview API] Get the release task attachments. -func (client *ClientImpl) GetReleaseTaskAttachments(ctx context.Context, args GetReleaseTaskAttachmentsArgs) (*[]ReleaseTaskAttachment, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ReleaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} - } - routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) - if args.EnvironmentId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} - } - routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) - if args.AttemptId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.AttemptId"} - } - routeValues["attemptId"] = strconv.Itoa(*args.AttemptId) - if args.PlanId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.PlanId"} - } - routeValues["planId"] = (*args.PlanId).String() - if args.Type == nil || *args.Type == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Type"} - } - routeValues["type"] = *args.Type - - locationId, _ := uuid.Parse("a4d06688-0dfa-4895-82a5-f43ec9452306") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.1", routeValues, nil, nil, "", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue []ReleaseTaskAttachment - err = client.Client.UnmarshalCollectionBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the GetReleaseTaskAttachments function -type GetReleaseTaskAttachmentsArgs struct { - // (required) Project ID or project name - Project *string - // (required) Id of the release. - ReleaseId *int - // (required) Id of the release environment. - EnvironmentId *int - // (required) Attempt number of deployment. - AttemptId *int - // (required) Plan Id of the deploy phase. - PlanId *uuid.UUID - // (required) Type of the attachment. - Type *string -} - -// [Preview API] Gets the task log of a release as a plain text file. -func (client *ClientImpl) GetTaskLog(ctx context.Context, args GetTaskLogArgs) (io.ReadCloser, error) { - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ReleaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} - } - routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) - if args.EnvironmentId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} - } - routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) - if args.ReleaseDeployPhaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseDeployPhaseId"} - } - routeValues["releaseDeployPhaseId"] = strconv.Itoa(*args.ReleaseDeployPhaseId) - if args.TaskId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.TaskId"} - } - routeValues["taskId"] = strconv.Itoa(*args.TaskId) - - queryParams := url.Values{} - if args.StartLine != nil { - queryParams.Add("startLine", strconv.FormatUint(*args.StartLine, 10)) - } - if args.EndLine != nil { - queryParams.Add("endLine", strconv.FormatUint(*args.EndLine, 10)) - } - locationId, _ := uuid.Parse("17c91af7-09fd-4256-bff1-c24ee4f73bc0") - resp, err := client.Client.Send(ctx, http.MethodGet, locationId, "5.1-preview.2", routeValues, queryParams, nil, "", "text/plain", nil) - if err != nil { - return nil, err - } - - return resp.Body, err -} - -// Arguments for the GetTaskLog function -type GetTaskLogArgs struct { - // (required) Project ID or project name - Project *string - // (required) Id of the release. - ReleaseId *int - // (required) Id of release environment. - EnvironmentId *int - // (required) Release deploy phase Id. - ReleaseDeployPhaseId *int - // (required) ReleaseTask Id for the log. - TaskId *int - // (optional) Starting line number for logs - StartLine *uint64 - // (optional) Ending line number for logs - EndLine *uint64 -} - -// [Preview API] Updates an existing folder at given existing path. -func (client *ClientImpl) UpdateFolder(ctx context.Context, args UpdateFolderArgs) (*Folder, error) { - if args.Folder == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Folder"} - } - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.Path == nil || *args.Path == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Path"} - } - routeValues["path"] = *args.Path - - body, marshalErr := json.Marshal(*args.Folder) - if marshalErr != nil { - return nil, marshalErr - } - locationId, _ := uuid.Parse("f7ddf76d-ce0c-4d68-94ff-becaec5d9dea") - resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.2", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue Folder - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the UpdateFolder function -type UpdateFolderArgs struct { - // (required) folder. - Folder *Folder - // (required) Project ID or project name - Project *string - // (required) Path of the folder to update. - Path *string -} - -// [Preview API] Updates the gate for a deployment. -func (client *ClientImpl) UpdateGates(ctx context.Context, args UpdateGatesArgs) (*ReleaseGates, error) { - if args.GateUpdateMetadata == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GateUpdateMetadata"} - } - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.GateStepId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.GateStepId"} - } - routeValues["gateStepId"] = strconv.Itoa(*args.GateStepId) - - body, marshalErr := json.Marshal(*args.GateUpdateMetadata) - if marshalErr != nil { - return nil, marshalErr - } - locationId, _ := uuid.Parse("2666a539-2001-4f80-bcc7-0379956749d4") - resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue ReleaseGates - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the UpdateGates function -type UpdateGatesArgs struct { - // (required) Metadata to patch the Release Gates. - GateUpdateMetadata *GateUpdateMetadata - // (required) Project ID or project name - Project *string - // (required) Gate step Id. - GateStepId *int -} - -// Update manual intervention. -func (client *ClientImpl) UpdateManualIntervention(ctx context.Context, args UpdateManualInterventionArgs) (*ManualIntervention, error) { - if args.ManualInterventionUpdateMetadata == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ManualInterventionUpdateMetadata"} - } - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ReleaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} - } - routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) - if args.ManualInterventionId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ManualInterventionId"} - } - routeValues["manualInterventionId"] = strconv.Itoa(*args.ManualInterventionId) - - body, marshalErr := json.Marshal(*args.ManualInterventionUpdateMetadata) - if marshalErr != nil { - return nil, marshalErr - } - locationId, _ := uuid.Parse("616c46e4-f370-4456-adaa-fbaf79c7b79e") - resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue ManualIntervention - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the UpdateManualIntervention function -type UpdateManualInterventionArgs struct { - // (required) Meta data to update manual intervention. - ManualInterventionUpdateMetadata *ManualInterventionUpdateMetadata - // (required) Project ID or project name - Project *string - // (required) Id of the release. - ReleaseId *int - // (required) Id of the manual intervention. - ManualInterventionId *int -} - -// Update a complete release object. -func (client *ClientImpl) UpdateRelease(ctx context.Context, args UpdateReleaseArgs) (*Release, error) { - if args.Release == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Release"} - } - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ReleaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} - } - routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) - - body, marshalErr := json.Marshal(*args.Release) - if marshalErr != nil { - return nil, marshalErr - } - locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") - resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue Release - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the UpdateRelease function -type UpdateReleaseArgs struct { - // (required) Release object for update. - Release *Release - // (required) Project ID or project name - Project *string - // (required) Id of the release to update. - ReleaseId *int -} - -// Update status of an approval -func (client *ClientImpl) UpdateReleaseApproval(ctx context.Context, args UpdateReleaseApprovalArgs) (*ReleaseApproval, error) { - if args.Approval == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.Approval"} - } - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ApprovalId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ApprovalId"} - } - routeValues["approvalId"] = strconv.Itoa(*args.ApprovalId) - - body, marshalErr := json.Marshal(*args.Approval) - if marshalErr != nil { - return nil, marshalErr - } - locationId, _ := uuid.Parse("9328e074-59fb-465a-89d9-b09c82ee5109") - resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue ReleaseApproval - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the UpdateReleaseApproval function -type UpdateReleaseApprovalArgs struct { - // (required) ReleaseApproval object having status, approver and comments. - Approval *ReleaseApproval - // (required) Project ID or project name - Project *string - // (required) Id of the approval. - ApprovalId *int -} - -// Update a release definition. -func (client *ClientImpl) UpdateReleaseDefinition(ctx context.Context, args UpdateReleaseDefinitionArgs) (*ReleaseDefinition, error) { - if args.ReleaseDefinition == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseDefinition"} - } - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - - body, marshalErr := json.Marshal(*args.ReleaseDefinition) - if marshalErr != nil { - return nil, marshalErr - } - locationId, _ := uuid.Parse("d8f96f24-8ea7-4cb6-baab-2df8fc515665") - resp, err := client.Client.Send(ctx, http.MethodPut, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue ReleaseDefinition - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the UpdateReleaseDefinition function -type UpdateReleaseDefinitionArgs struct { - // (required) Release definition object to update. - ReleaseDefinition *ReleaseDefinition - // (required) Project ID or project name - Project *string -} - -// [Preview API] Update the status of a release environment -func (client *ClientImpl) UpdateReleaseEnvironment(ctx context.Context, args UpdateReleaseEnvironmentArgs) (*ReleaseEnvironment, error) { - if args.EnvironmentUpdateData == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentUpdateData"} - } - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ReleaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} - } - routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) - if args.EnvironmentId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.EnvironmentId"} - } - routeValues["environmentId"] = strconv.Itoa(*args.EnvironmentId) - - body, marshalErr := json.Marshal(*args.EnvironmentUpdateData) - if marshalErr != nil { - return nil, marshalErr - } - locationId, _ := uuid.Parse("a7e426b1-03dc-48af-9dfe-c98bac612dcb") - resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1-preview.6", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue ReleaseEnvironment - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the UpdateReleaseEnvironment function -type UpdateReleaseEnvironmentArgs struct { - // (required) Environment update meta data. - EnvironmentUpdateData *ReleaseEnvironmentUpdateMetadata - // (required) Project ID or project name - Project *string - // (required) Id of the release. - ReleaseId *int - // (required) Id of release environment. - EnvironmentId *int -} - -// Update few properties of a release. -func (client *ClientImpl) UpdateReleaseResource(ctx context.Context, args UpdateReleaseResourceArgs) (*Release, error) { - if args.ReleaseUpdateMetadata == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseUpdateMetadata"} - } - routeValues := make(map[string]string) - if args.Project == nil || *args.Project == "" { - return nil, &azuredevops.ArgumentNilOrEmptyError{ArgumentName: "args.Project"} - } - routeValues["project"] = *args.Project - if args.ReleaseId == nil { - return nil, &azuredevops.ArgumentNilError{ArgumentName: "args.ReleaseId"} - } - routeValues["releaseId"] = strconv.Itoa(*args.ReleaseId) - - body, marshalErr := json.Marshal(*args.ReleaseUpdateMetadata) - if marshalErr != nil { - return nil, marshalErr - } - locationId, _ := uuid.Parse("a166fde7-27ad-408e-ba75-703c2cc9d500") - resp, err := client.Client.Send(ctx, http.MethodPatch, locationId, "5.1", routeValues, nil, bytes.NewReader(body), "application/json", "application/json", nil) - if err != nil { - return nil, err - } - - var responseValue Release - err = client.Client.UnmarshalBody(resp, &responseValue) - return &responseValue, err -} - -// Arguments for the UpdateReleaseResource function -type UpdateReleaseResourceArgs struct { - // (required) Properties of release to update. - ReleaseUpdateMetadata *ReleaseUpdateMetadata - // (required) Project ID or project name - Project *string - // (required) Id of the release to update. - ReleaseId *int -} diff --git a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/models.go b/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/models.go deleted file mode 100644 index f505e8c92..000000000 --- a/vendor/github.com/microsoft/azure-devops-go-api/azuredevops/release/models.go +++ /dev/null @@ -1,3064 +0,0 @@ -// -------------------------------------------------------------------------------------------- -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// -------------------------------------------------------------------------------------------- -// Generated file, DO NOT EDIT -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// -------------------------------------------------------------------------------------------- - -package release - -import ( - "github.com/google/uuid" - "github.com/microsoft/azure-devops-go-api/azuredevops" - "github.com/microsoft/azure-devops-go-api/azuredevops/distributedtaskcommon" - "github.com/microsoft/azure-devops-go-api/azuredevops/forminput" - "github.com/microsoft/azure-devops-go-api/azuredevops/webapi" -) - -type AgentArtifactDefinition struct { - // Gets or sets the artifact definition alias. - Alias *string `json:"alias,omitempty"` - // Gets or sets the artifact type. - ArtifactType *AgentArtifactType `json:"artifactType,omitempty"` - // Gets or sets the artifact definition details. - Details *string `json:"details,omitempty"` - // Gets or sets the name of artifact definition. - Name *string `json:"name,omitempty"` - // Gets or sets the version of artifact definition. - Version *string `json:"version,omitempty"` -} - -type AgentArtifactType string - -type agentArtifactTypeValuesType struct { - XamlBuild AgentArtifactType - Build AgentArtifactType - Jenkins AgentArtifactType - FileShare AgentArtifactType - Nuget AgentArtifactType - TfsOnPrem AgentArtifactType - GitHub AgentArtifactType - TfGit AgentArtifactType - ExternalTfsBuild AgentArtifactType - Custom AgentArtifactType - Tfvc AgentArtifactType -} - -var AgentArtifactTypeValues = agentArtifactTypeValuesType{ - // Indicates XamlBuild artifact - XamlBuild: "xamlBuild", - // Indicates Build artifact - Build: "build", - // Indicates Jenkins artifact - Jenkins: "jenkins", - // Indicates FileShare artifact - FileShare: "fileShare", - // Indicates Nuget artifact - Nuget: "nuget", - // Indicates TfsOnPrem artifact - TfsOnPrem: "tfsOnPrem", - // Indicates GitHub artifact - GitHub: "gitHub", - // Indicates TFGit artifact - TfGit: "tfGit", - // Indicates ExternalTfsBuild artifact - ExternalTfsBuild: "externalTfsBuild", - // Indicates Custom artifact - Custom: "custom", - // Indicates Tfvc artifact - Tfvc: "tfvc", -} - -type AgentBasedDeployPhase struct { - // Gets and sets the name of deploy phase. - Name *string `json:"name,omitempty"` - // Indicates the deploy phase type. - PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` - // Gets and sets the rank of deploy phase. - Rank *int `json:"rank,omitempty"` - // Gets and sets the reference name of deploy phase. - RefName *string `json:"refName,omitempty"` - // Gets and sets the workflow tasks for the deploy phase. - WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` - // Gets and sets the agent job deployment input - DeploymentInput *AgentDeploymentInput `json:"deploymentInput,omitempty"` -} - -type AgentDeploymentInput struct { - // Gets or sets the job condition. - Condition *string `json:"condition,omitempty"` - // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. - JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` - // Gets or sets the override inputs. - OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` - // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. - TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` - // Artifacts that downloaded during job execution. - ArtifactsDownloadInput *ArtifactsDownloadInput `json:"artifactsDownloadInput,omitempty"` - // List demands that needs to meet to execute the job. - Demands *[]interface{} `json:"demands,omitempty"` - // Indicates whether to include access token in deployment job or not. - EnableAccessToken *bool `json:"enableAccessToken,omitempty"` - // Id of the pool on which job get executed. - QueueId *int `json:"queueId,omitempty"` - // Indicates whether artifacts downloaded while job execution or not. - SkipArtifactsDownload *bool `json:"skipArtifactsDownload,omitempty"` - // Specification for an agent on which a job gets executed. - AgentSpecification *AgentSpecification `json:"agentSpecification,omitempty"` - // Gets or sets the image ID. - ImageId *int `json:"imageId,omitempty"` - // Gets or sets the parallel execution input. - ParallelExecution *ExecutionInput `json:"parallelExecution,omitempty"` -} - -// Specification of the agent defined by the pool provider. -type AgentSpecification struct { - // Agent specification unique identifier. - Identifier *string `json:"identifier,omitempty"` -} - -// [Flags] -type ApprovalExecutionOrder string - -type approvalExecutionOrderValuesType struct { - BeforeGates ApprovalExecutionOrder - AfterSuccessfulGates ApprovalExecutionOrder - AfterGatesAlways ApprovalExecutionOrder -} - -var ApprovalExecutionOrderValues = approvalExecutionOrderValuesType{ - // Approvals shown before gates. - BeforeGates: "beforeGates", - // Approvals shown after successful execution of gates. - AfterSuccessfulGates: "afterSuccessfulGates", - // Approvals shown always after execution of gates. - AfterGatesAlways: "afterGatesAlways", -} - -// [Flags] -type ApprovalFilters string - -type approvalFiltersValuesType struct { - None ApprovalFilters - ManualApprovals ApprovalFilters - AutomatedApprovals ApprovalFilters - ApprovalSnapshots ApprovalFilters - All ApprovalFilters -} - -var ApprovalFiltersValues = approvalFiltersValuesType{ - // No approvals or approval snapshots. - None: "none", - // Manual approval steps but no approval snapshots (Use with ApprovalSnapshots for snapshots). - ManualApprovals: "manualApprovals", - // Automated approval steps but no approval snapshots (Use with ApprovalSnapshots for snapshots). - AutomatedApprovals: "automatedApprovals", - // No approval steps, but approval snapshots (Use with either ManualApprovals or AutomatedApprovals for approval steps). - ApprovalSnapshots: "approvalSnapshots", - // All approval steps and approval snapshots. - All: "all", -} - -type ApprovalOptions struct { - // Specify whether the approval can be skipped if the same approver approved the previous stage. - AutoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped *bool `json:"autoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped,omitempty"` - // Specify whether revalidate identity of approver before completing the approval. - EnforceIdentityRevalidation *bool `json:"enforceIdentityRevalidation,omitempty"` - // Approvals execution order. - ExecutionOrder *ApprovalExecutionOrder `json:"executionOrder,omitempty"` - // Specify whether the user requesting a release or deployment should allow to approver. - ReleaseCreatorCanBeApprover *bool `json:"releaseCreatorCanBeApprover,omitempty"` - // The number of approvals required to move release forward. '0' means all approvals required. - RequiredApproverCount *int `json:"requiredApproverCount,omitempty"` - // Approval timeout. Approval default timeout is 30 days. Maximum allowed timeout is 365 days. '0' means default timeout i.e 30 days. - TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` -} - -type ApprovalStatus string - -type approvalStatusValuesType struct { - Undefined ApprovalStatus - Pending ApprovalStatus - Approved ApprovalStatus - Rejected ApprovalStatus - Reassigned ApprovalStatus - Canceled ApprovalStatus - Skipped ApprovalStatus -} - -var ApprovalStatusValues = approvalStatusValuesType{ - // Indicates the approval does not have the status set. - Undefined: "undefined", - // Indicates the approval is pending. - Pending: "pending", - // Indicates the approval is approved. - Approved: "approved", - // Indicates the approval is rejected. - Rejected: "rejected", - // Indicates the approval is reassigned. - Reassigned: "reassigned", - // Indicates the approval is canceled. - Canceled: "canceled", - // Indicates the approval is skipped. - Skipped: "skipped", -} - -type ApprovalType string - -type approvalTypeValuesType struct { - Undefined ApprovalType - PreDeploy ApprovalType - PostDeploy ApprovalType - All ApprovalType -} - -var ApprovalTypeValues = approvalTypeValuesType{ - // Indicates the approval type does not set. - Undefined: "undefined", - // Indicates the approvals which executed before deployment. - PreDeploy: "preDeploy", - // Indicates the approvals which executed after deployment. - PostDeploy: "postDeploy", - // Indicates all approvals. - All: "all", -} - -type Artifact struct { - // Gets or sets alias. - Alias *string `json:"alias,omitempty"` - // Gets or sets definition reference. e.g. {"project":{"id":"fed755ea-49c5-4399-acea-fd5b5aa90a6c","name":"myProject"},"definition":{"id":"1","name":"mybuildDefinition"},"connection":{"id":"1","name":"myConnection"}}. - DefinitionReference *map[string]ArtifactSourceReference `json:"definitionReference,omitempty"` - // Indicates whether artifact is primary or not. - IsPrimary *bool `json:"isPrimary,omitempty"` - // Indicates whether artifact is retained by release or not. - IsRetained *bool `json:"isRetained,omitempty"` - // Deprecated: This property is deprecated use Alias instead and remove all its references - SourceId *string `json:"sourceId,omitempty"` - // Gets or sets type. It can have value as 'Build', 'Jenkins', 'GitHub', 'Nuget', 'Team Build (external)', 'ExternalTFSBuild', 'Git', 'TFVC', 'ExternalTfsXamlBuild'. - Type *string `json:"type,omitempty"` -} - -type ArtifactContributionDefinition struct { - ArtifactTriggerConfiguration *ArtifactTriggerConfiguration `json:"artifactTriggerConfiguration,omitempty"` - ArtifactType *string `json:"artifactType,omitempty"` - ArtifactTypeStreamMapping *map[string]string `json:"artifactTypeStreamMapping,omitempty"` - BrowsableArtifactTypeMapping *map[string]string `json:"browsableArtifactTypeMapping,omitempty"` - DataSourceBindings *[]DataSourceBinding `json:"dataSourceBindings,omitempty"` - DisplayName *string `json:"displayName,omitempty"` - DownloadTaskId *string `json:"downloadTaskId,omitempty"` - EndpointTypeId *string `json:"endpointTypeId,omitempty"` - InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` - IsCommitsTraceabilitySupported *bool `json:"isCommitsTraceabilitySupported,omitempty"` - IsWorkitemsTraceabilitySupported *bool `json:"isWorkitemsTraceabilitySupported,omitempty"` - Name *string `json:"name,omitempty"` - TaskInputMapping *map[string]string `json:"taskInputMapping,omitempty"` - UniqueSourceIdentifier *string `json:"uniqueSourceIdentifier,omitempty"` -} - -type ArtifactDownloadInputBase struct { - // Gets or sets the alias of artifact. - Alias *string `json:"alias,omitempty"` - // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. - ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` - // Gets or sets the artifact items of the input. - ArtifactItems *[]string `json:"artifactItems,omitempty"` - // Gets or sets the type of artifact. - ArtifactType *string `json:"artifactType,omitempty"` -} - -type ArtifactFilter struct { - // Gets or sets whether a release should be created on build tagging. - CreateReleaseOnBuildTagging *bool `json:"createReleaseOnBuildTagging,omitempty"` - // Gets or sets the branch for the filter. - SourceBranch *string `json:"sourceBranch,omitempty"` - // Gets or sets the list of tags for the filter. - Tags *[]string `json:"tags,omitempty"` - // Gets or sets whether filter should default to build definition branch. - UseBuildDefinitionBranch *bool `json:"useBuildDefinitionBranch,omitempty"` -} - -type ArtifactInstanceData struct { - AccountName *string `json:"accountName,omitempty"` - AuthenticationToken *string `json:"authenticationToken,omitempty"` - TfsUrl *string `json:"tfsUrl,omitempty"` - Version *string `json:"version,omitempty"` -} - -type ArtifactMetadata struct { - // Sets alias of artifact. - Alias *string `json:"alias,omitempty"` - // Sets instance reference of artifact. e.g. for build artifact it is build number. - InstanceReference *BuildVersion `json:"instanceReference,omitempty"` -} - -type ArtifactProvider struct { - // Gets or sets the id of artifact provider. - Id *int `json:"id,omitempty"` - // Gets or sets the name of artifact provider. - Name *string `json:"name,omitempty"` - // Gets or sets the link of artifact provider. - SourceUri *string `json:"sourceUri,omitempty"` - // Gets or sets the version of artifact provider. - Version *string `json:"version,omitempty"` -} - -type ArtifactsDownloadInput struct { - DownloadInputs *[]ArtifactDownloadInputBase `json:"downloadInputs,omitempty"` -} - -type ArtifactSourceId struct { - // Gets or sets the artifact type of artifact source. - ArtifactTypeId *string `json:"artifactTypeId,omitempty"` - // Gets or sets the list of sourceIdInput of artifact source. - SourceIdInputs *[]SourceIdInput `json:"sourceIdInputs,omitempty"` -} - -type ArtifactSourceIdsQueryResult struct { - // Gets or sets the list of artifactsourceIds. - ArtifactSourceIds *[]ArtifactSourceId `json:"artifactSourceIds,omitempty"` -} - -type ArtifactSourceReference struct { - // ID of the artifact source. - Id *string `json:"id,omitempty"` - // Name of the artifact source. - Name *string `json:"name,omitempty"` -} - -type ArtifactSourceTrigger struct { - // Type of release trigger. - TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` - // Artifact source alias for Artifact Source trigger type - ArtifactAlias *string `json:"artifactAlias,omitempty"` - TriggerConditions *[]ArtifactFilter `json:"triggerConditions,omitempty"` -} - -type ArtifactTriggerConfiguration struct { - // Gets or sets the whether trigger is supported or not. - IsTriggerSupported *bool `json:"isTriggerSupported,omitempty"` - // Gets or sets the whether trigger is supported only on hosted environment. - IsTriggerSupportedOnlyInHosted *bool `json:"isTriggerSupportedOnlyInHosted,omitempty"` - // Gets or sets the whether webhook is supported at server level. - IsWebhookSupportedAtServerLevel *bool `json:"isWebhookSupportedAtServerLevel,omitempty"` - // Gets or sets the payload hash header name for the artifact trigger configuration. - PayloadHashHeaderName *string `json:"payloadHashHeaderName,omitempty"` - // Gets or sets the resources for artifact trigger configuration. - Resources *map[string]string `json:"resources,omitempty"` - // Gets or sets the webhook payload mapping for artifact trigger configuration. - WebhookPayloadMapping *map[string]string `json:"webhookPayloadMapping,omitempty"` -} - -type ArtifactTypeDefinition struct { - // Gets or sets the artifact trigger configuration of artifact type definition. - ArtifactTriggerConfiguration *ArtifactTriggerConfiguration `json:"artifactTriggerConfiguration,omitempty"` - // Gets or sets the artifact type of artifact type definition. Valid values are 'Build', 'Package', 'Source' or 'ContainerImage'. - ArtifactType *string `json:"artifactType,omitempty"` - // Gets or sets the display name of artifact type definition. - DisplayName *string `json:"displayName,omitempty"` - // Gets or sets the endpoint type id of artifact type definition. - EndpointTypeId *string `json:"endpointTypeId,omitempty"` - // Gets or sets the input descriptors of artifact type definition. - InputDescriptors *[]forminput.InputDescriptor `json:"inputDescriptors,omitempty"` - // Gets or sets the name of artifact type definition. - Name *string `json:"name,omitempty"` - // Gets or sets the unique source identifier of artifact type definition. - UniqueSourceIdentifier *string `json:"uniqueSourceIdentifier,omitempty"` -} - -type ArtifactVersion struct { - // Gets or sets the alias of artifact. - Alias *string `json:"alias,omitempty"` - // Gets or sets the default version of artifact. - DefaultVersion *BuildVersion `json:"defaultVersion,omitempty"` - // Gets or sets the error message encountered during querying of versions for artifact. - ErrorMessage *string `json:"errorMessage,omitempty"` - // Deprecated: This property is deprecated use Alias instead and remove all its references - SourceId *string `json:"sourceId,omitempty"` - // Gets or sets the list of build versions of artifact. - Versions *[]BuildVersion `json:"versions,omitempty"` -} - -type ArtifactVersionQueryResult struct { - // Gets or sets the list for artifact versions of artifact version query result. - ArtifactVersions *[]ArtifactVersion `json:"artifactVersions,omitempty"` -} - -type AuditAction string - -type auditActionValuesType struct { - Add AuditAction - Update AuditAction - Delete AuditAction - Undelete AuditAction -} - -var AuditActionValues = auditActionValuesType{ - // Indicates the audit add. - Add: "add", - // Indicates the audit update. - Update: "update", - // Indicates the audit delete. - Delete: "delete", - // Indicates the audit undelete. - Undelete: "undelete", -} - -type AuthorizationHeaderFor string - -type authorizationHeaderForValuesType struct { - RevalidateApproverIdentity AuthorizationHeaderFor - OnBehalfOf AuthorizationHeaderFor -} - -var AuthorizationHeaderForValues = authorizationHeaderForValuesType{ - RevalidateApproverIdentity: "revalidateApproverIdentity", - OnBehalfOf: "onBehalfOf", -} - -type AutoTriggerIssue struct { - Issue *Issue `json:"issue,omitempty"` - IssueSource *IssueSource `json:"issueSource,omitempty"` - Project *ProjectReference `json:"project,omitempty"` - ReleaseDefinitionReference *ReleaseDefinitionShallowReference `json:"releaseDefinitionReference,omitempty"` - ReleaseTriggerType *ReleaseTriggerType `json:"releaseTriggerType,omitempty"` -} - -type AzureKeyVaultVariableGroupProviderData struct { - // Gets or sets last refreshed time. - LastRefreshedOn *azuredevops.Time `json:"lastRefreshedOn,omitempty"` - // Gets or sets the service endpoint ID. - ServiceEndpointId *uuid.UUID `json:"serviceEndpointId,omitempty"` - // Gets or sets the vault name. - Vault *string `json:"vault,omitempty"` -} - -type AzureKeyVaultVariableValue struct { - // Gets or sets as the variable is secret or not. - IsSecret *bool `json:"isSecret,omitempty"` - // Gets or sets the value. - Value *string `json:"value,omitempty"` - // Gets or sets the content type of key vault variable value. - ContentType *string `json:"contentType,omitempty"` - // Indicates the vault variable value enabled or not. - Enabled *bool `json:"enabled,omitempty"` - // Gets or sets the expire time of key vault variable value. - Expires *azuredevops.Time `json:"expires,omitempty"` -} - -type BaseDeploymentInput struct { - // Gets or sets the job condition. - Condition *string `json:"condition,omitempty"` - // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. - JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` - // Gets or sets the override inputs. - OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` - // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. - TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` -} - -type BuildArtifactDownloadInput struct { - // Gets or sets the alias of artifact. - Alias *string `json:"alias,omitempty"` - // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. - ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` - // Gets or sets the artifact items of the input. - ArtifactItems *[]string `json:"artifactItems,omitempty"` - // Gets or sets the type of artifact. - ArtifactType *string `json:"artifactType,omitempty"` -} - -type BuildVersion struct { - // Gets or sets the commit message for the artifact. - CommitMessage *string `json:"commitMessage,omitempty"` - // Gets or sets the definition id. - DefinitionId *string `json:"definitionId,omitempty"` - // Gets or sets the definition name. - DefinitionName *string `json:"definitionName,omitempty"` - // Gets or sets the build id. - Id *string `json:"id,omitempty"` - // Gets or sets if the artifact supports multiple definitions. - IsMultiDefinitionType *bool `json:"isMultiDefinitionType,omitempty"` - // Gets or sets the build number. - Name *string `json:"name,omitempty"` - // Gets or sets the source branch for the artifact. - SourceBranch *string `json:"sourceBranch,omitempty"` - // Gets or sets the source pull request version for the artifact. - SourcePullRequestVersion *SourcePullRequestVersion `json:"sourcePullRequestVersion,omitempty"` - // Gets or sets the repository id for the artifact. - SourceRepositoryId *string `json:"sourceRepositoryId,omitempty"` - // Gets or sets the repository type for the artifact. - SourceRepositoryType *string `json:"sourceRepositoryType,omitempty"` - // Gets or sets the source version for the artifact. - SourceVersion *string `json:"sourceVersion,omitempty"` -} - -// Represents a change associated with a build. -type Change struct { - // The author of the change. - Author *webapi.IdentityRef `json:"author,omitempty"` - // The type of source. "TfsVersionControl", "TfsGit", etc. - ChangeType *string `json:"changeType,omitempty"` - // The location of a user-friendly representation of the resource. - DisplayUri *string `json:"displayUri,omitempty"` - // Something that identifies the change. For a commit, this would be the SHA1. For a TFVC changeset, this would be the changeset id. - Id *string `json:"id,omitempty"` - // The location of the full representation of the resource. - Location *string `json:"location,omitempty"` - // A description of the change. This might be a commit message or changeset description. - Message *string `json:"message,omitempty"` - // The person or process that pushed the change. - PushedBy *webapi.IdentityRef `json:"pushedBy,omitempty"` - // Deprecated: Use PushedBy instead - Pusher *string `json:"pusher,omitempty"` - // A timestamp for the change. - Timestamp *azuredevops.Time `json:"timestamp,omitempty"` -} - -type CodeRepositoryReference struct { - // Gets and sets the repository references. - RepositoryReference *map[string]ReleaseManagementInputValue `json:"repositoryReference,omitempty"` - // It can have value as ‘GitHub’, ‘Vsts’. - SystemType *PullRequestSystemType `json:"systemType,omitempty"` -} - -type ComplianceSettings struct { - // Scan the release definition for secrets - CheckForCredentialsAndOtherSecrets *bool `json:"checkForCredentialsAndOtherSecrets,omitempty"` -} - -type Condition struct { - // Gets or sets the condition type. - ConditionType *ConditionType `json:"conditionType,omitempty"` - // Gets or sets the name of the condition. e.g. 'ReleaseStarted'. - Name *string `json:"name,omitempty"` - // Gets or set value of the condition. - Value *string `json:"value,omitempty"` -} - -type ConditionType string - -type conditionTypeValuesType struct { - Undefined ConditionType - Event ConditionType - EnvironmentState ConditionType - Artifact ConditionType -} - -var ConditionTypeValues = conditionTypeValuesType{ - // The condition type is undefined. - Undefined: "undefined", - // The condition type is event. - Event: "event", - // The condition type is environment state. - EnvironmentState: "environmentState", - // The condition type is artifact. - Artifact: "artifact", -} - -type ConfigurationVariableValue struct { - // Gets and sets if a variable can be overridden at deployment time or not. - AllowOverride *bool `json:"allowOverride,omitempty"` - // Gets or sets as variable is secret or not. - IsSecret *bool `json:"isSecret,omitempty"` - // Gets and sets value of the configuration variable. - Value *string `json:"value,omitempty"` -} - -type Consumer struct { - // ID of the consumer. - ConsumerId *int `json:"consumerId,omitempty"` - // Name of the consumer. - ConsumerName *string `json:"consumerName,omitempty"` -} - -type ContainerImageTrigger struct { - // Type of release trigger. - TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` - // Alias of the trigger. - Alias *string `json:"alias,omitempty"` - // List tag filters applied while trigger. - TagFilters *[]TagFilter `json:"tagFilters,omitempty"` -} - -type ContinuousDeploymentTriggerIssue struct { - Issue *Issue `json:"issue,omitempty"` - IssueSource *IssueSource `json:"issueSource,omitempty"` - Project *ProjectReference `json:"project,omitempty"` - ReleaseDefinitionReference *ReleaseDefinitionShallowReference `json:"releaseDefinitionReference,omitempty"` - ReleaseTriggerType *ReleaseTriggerType `json:"releaseTriggerType,omitempty"` - // Artifact type. - ArtifactType *string `json:"artifactType,omitempty"` - // ArtifactVersion ID. - ArtifactVersionId *string `json:"artifactVersionId,omitempty"` - // Artifact source ID. - SourceId *string `json:"sourceId,omitempty"` -} - -type ControlOptions struct { - // Always run the job. - AlwaysRun *bool `json:"alwaysRun,omitempty"` - // Indicates whether to continue job on error or not. - ContinueOnError *bool `json:"continueOnError,omitempty"` - // Indicates the job enabled or not. - Enabled *bool `json:"enabled,omitempty"` -} - -type CustomArtifactDownloadInput struct { - // Gets or sets the alias of artifact. - Alias *string `json:"alias,omitempty"` - // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. - ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` - // Gets or sets the artifact items of the input. - ArtifactItems *[]string `json:"artifactItems,omitempty"` - // Gets or sets the type of artifact. - ArtifactType *string `json:"artifactType,omitempty"` -} - -type DataSourceBinding struct { - // Pagination format supported by this data source(ContinuationToken/SkipTop). - CallbackContextTemplate *string `json:"callbackContextTemplate,omitempty"` - // Subsequent calls needed? - CallBackRequiredTemplate *string `json:"callBackRequiredTemplate,omitempty"` - // Name of the datasource. - DataSourceName *string `json:"dataSourceName,omitempty"` - // Endpoint ID of the datasource. - EndpointId *string `json:"endpointId,omitempty"` - // Endpoint URL of the datasource. - EndpointUrl *string `json:"endpointUrl,omitempty"` - // Defines the initial value of the query params - InitialContextTemplate *string `json:"initialContextTemplate,omitempty"` - // Parameters of the datasource. - Parameters *map[string]string `json:"parameters,omitempty"` - // Gets or sets http request body - RequestContent *string `json:"requestContent,omitempty"` - // Gets or sets http request verb - RequestVerb *string `json:"requestVerb,omitempty"` - // Result selector applied on output of datasource result, for example jsonpath:$.value[?(@.properties.isEnabled == true)]. - ResultSelector *string `json:"resultSelector,omitempty"` - // Format of the return results, for example. { "Value" : "{{{id}}}", "DisplayValue" : "{{{name}}}" }. - ResultTemplate *string `json:"resultTemplate,omitempty"` - // Target of the datasource. - Target *string `json:"target,omitempty"` -} - -type DefinitionEnvironmentReference struct { - // Definition environment ID. - DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` - // Definition environment name. - DefinitionEnvironmentName *string `json:"definitionEnvironmentName,omitempty"` - // ReleaseDefinition ID. - ReleaseDefinitionId *int `json:"releaseDefinitionId,omitempty"` - // ReleaseDefinition name. - ReleaseDefinitionName *string `json:"releaseDefinitionName,omitempty"` -} - -type Demand struct { - // Gets and sets the name of demand. - Name *string `json:"name,omitempty"` - // Gets and sets the value of demand. - Value *string `json:"value,omitempty"` -} - -type Deployment struct { - // Deprecated: Use ReleaseReference instead. - Links interface{} `json:"_links,omitempty"` - // Gets attempt number. - Attempt *int `json:"attempt,omitempty"` - // Gets the date on which deployment is complete. - CompletedOn *azuredevops.Time `json:"completedOn,omitempty"` - // Gets the list of condition associated with deployment. - Conditions *[]Condition `json:"conditions,omitempty"` - // Gets release definition environment id. - DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` - // Gets status of the deployment. - DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` - // Gets the unique identifier for deployment. - Id *int `json:"id,omitempty"` - // Gets the identity who last modified the deployment. - LastModifiedBy *webapi.IdentityRef `json:"lastModifiedBy,omitempty"` - // Gets the date on which deployment is last modified. - LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` - // Gets operation status of deployment. - OperationStatus *DeploymentOperationStatus `json:"operationStatus,omitempty"` - // Gets list of PostDeployApprovals. - PostDeployApprovals *[]ReleaseApproval `json:"postDeployApprovals,omitempty"` - // Gets list of PreDeployApprovals. - PreDeployApprovals *[]ReleaseApproval `json:"preDeployApprovals,omitempty"` - // Gets or sets project reference. - ProjectReference *ProjectReference `json:"projectReference,omitempty"` - // Gets the date on which deployment is queued. - QueuedOn *azuredevops.Time `json:"queuedOn,omitempty"` - // Gets reason of deployment. - Reason *DeploymentReason `json:"reason,omitempty"` - // Gets the reference of release. - Release *ReleaseReference `json:"release,omitempty"` - // Gets releaseDefinitionReference which specifies the reference of the release definition to which the deployment is associated. - ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` - // Gets releaseEnvironmentReference which specifies the reference of the release environment to which the deployment is associated. - ReleaseEnvironment *ReleaseEnvironmentShallowReference `json:"releaseEnvironment,omitempty"` - // Gets the identity who requested. - RequestedBy *webapi.IdentityRef `json:"requestedBy,omitempty"` - // Gets the identity for whom deployment is requested. - RequestedFor *webapi.IdentityRef `json:"requestedFor,omitempty"` - // Gets the date on which deployment is scheduled. - ScheduledDeploymentTime *azuredevops.Time `json:"scheduledDeploymentTime,omitempty"` - // Gets the date on which deployment is started. - StartedOn *azuredevops.Time `json:"startedOn,omitempty"` -} - -type DeploymentApprovalCompletedEvent struct { - Approval *ReleaseApproval `json:"approval,omitempty"` - Project *ProjectReference `json:"project,omitempty"` - Release *Release `json:"release,omitempty"` -} - -type DeploymentApprovalPendingEvent struct { - Approval *ReleaseApproval `json:"approval,omitempty"` - ApprovalOptions *ApprovalOptions `json:"approvalOptions,omitempty"` - CompletedApprovals *[]ReleaseApproval `json:"completedApprovals,omitempty"` - Data *map[string]interface{} `json:"data,omitempty"` - Deployment *Deployment `json:"deployment,omitempty"` - IsMultipleRankApproval *bool `json:"isMultipleRankApproval,omitempty"` - PendingApprovals *[]ReleaseApproval `json:"pendingApprovals,omitempty"` - Project *ProjectReference `json:"project,omitempty"` - Release *Release `json:"release,omitempty"` -} - -type DeploymentAttempt struct { - // Deployment attempt. - Attempt *int `json:"attempt,omitempty"` - // ID of the deployment. - DeploymentId *int `json:"deploymentId,omitempty"` - // Deprecated: Instead use Issues which contains both errors and warnings related to deployment - ErrorLog *string `json:"errorLog,omitempty"` - // Specifies whether deployment has started or not. - HasStarted *bool `json:"hasStarted,omitempty"` - // ID of deployment. - Id *int `json:"id,omitempty"` - // All the issues related to the deployment. - Issues *[]Issue `json:"issues,omitempty"` - // Deprecated: Use ReleaseDeployPhase.DeploymentJobs.Job instead. - Job *ReleaseTask `json:"job,omitempty"` - // Identity who last modified this deployment. - LastModifiedBy *webapi.IdentityRef `json:"lastModifiedBy,omitempty"` - // Time when this deployment last modified. - LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` - // Deployment operation status. - OperationStatus *DeploymentOperationStatus `json:"operationStatus,omitempty"` - // Post deployment gates that executed in this deployment. - PostDeploymentGates *ReleaseGates `json:"postDeploymentGates,omitempty"` - // Pre deployment gates that executed in this deployment. - PreDeploymentGates *ReleaseGates `json:"preDeploymentGates,omitempty"` - // When this deployment queued on. - QueuedOn *azuredevops.Time `json:"queuedOn,omitempty"` - // Reason for the deployment. - Reason *DeploymentReason `json:"reason,omitempty"` - // List of release deployphases executed in this deployment. - ReleaseDeployPhases *[]ReleaseDeployPhase `json:"releaseDeployPhases,omitempty"` - // Identity who requested this deployment. - RequestedBy *webapi.IdentityRef `json:"requestedBy,omitempty"` - // Identity for this deployment requested. - RequestedFor *webapi.IdentityRef `json:"requestedFor,omitempty"` - // Deprecated: Use ReleaseDeployPhase.RunPlanId instead. - RunPlanId *uuid.UUID `json:"runPlanId,omitempty"` - // status of the deployment. - Status *DeploymentStatus `json:"status,omitempty"` - // Deprecated: Use ReleaseDeployPhase.DeploymentJobs.Tasks instead. - Tasks *[]ReleaseTask `json:"tasks,omitempty"` -} - -type DeploymentAuthorizationInfo struct { - // Authorization header type, typically either RevalidateApproverIdentity or OnBehalfOf. - AuthorizationHeaderFor *AuthorizationHeaderFor `json:"authorizationHeaderFor,omitempty"` - // List of resources. - Resources *[]string `json:"resources,omitempty"` - // ID of the tenant. - TenantId *string `json:"tenantId,omitempty"` - // Access token key. - VstsAccessTokenKey *string `json:"vstsAccessTokenKey,omitempty"` -} - -type DeploymentAuthorizationOwner string - -type deploymentAuthorizationOwnerValuesType struct { - Automatic DeploymentAuthorizationOwner - DeploymentSubmitter DeploymentAuthorizationOwner - FirstPreDeploymentApprover DeploymentAuthorizationOwner -} - -var DeploymentAuthorizationOwnerValues = deploymentAuthorizationOwnerValuesType{ - Automatic: "automatic", - DeploymentSubmitter: "deploymentSubmitter", - FirstPreDeploymentApprover: "firstPreDeploymentApprover", -} - -type DeploymentCompletedEvent struct { - Comment *string `json:"comment,omitempty"` - Data *map[string]interface{} `json:"data,omitempty"` - Deployment *Deployment `json:"deployment,omitempty"` - Environment *ReleaseEnvironment `json:"environment,omitempty"` - Project *ProjectReference `json:"project,omitempty"` -} - -// [Flags] -type DeploymentExpands string - -type deploymentExpandsValuesType struct { - All DeploymentExpands - DeploymentOnly DeploymentExpands - Approvals DeploymentExpands - Artifacts DeploymentExpands -} - -var DeploymentExpandsValues = deploymentExpandsValuesType{ - All: "all", - DeploymentOnly: "deploymentOnly", - Approvals: "approvals", - Artifacts: "artifacts", -} - -type DeploymentInput struct { - // Gets or sets the job condition. - Condition *string `json:"condition,omitempty"` - // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. - JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` - // Gets or sets the override inputs. - OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` - // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. - TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` - // Artifacts that downloaded during job execution. - ArtifactsDownloadInput *ArtifactsDownloadInput `json:"artifactsDownloadInput,omitempty"` - // List demands that needs to meet to execute the job. - Demands *[]interface{} `json:"demands,omitempty"` - // Indicates whether to include access token in deployment job or not. - EnableAccessToken *bool `json:"enableAccessToken,omitempty"` - // Id of the pool on which job get executed. - QueueId *int `json:"queueId,omitempty"` - // Indicates whether artifacts downloaded while job execution or not. - SkipArtifactsDownload *bool `json:"skipArtifactsDownload,omitempty"` -} - -type DeploymentJob struct { - // Parent task of all executed tasks. - Job *ReleaseTask `json:"job,omitempty"` - // List of executed tasks with in job. - Tasks *[]ReleaseTask `json:"tasks,omitempty"` -} - -type DeploymentManualInterventionPendingEvent struct { - Deployment *Deployment `json:"deployment,omitempty"` - EmailRecipients *[]uuid.UUID `json:"emailRecipients,omitempty"` - EnvironmentOwner *webapi.IdentityRef `json:"environmentOwner,omitempty"` - ManualIntervention *ManualIntervention `json:"manualIntervention,omitempty"` - Project *ProjectReference `json:"project,omitempty"` - Release *Release `json:"release,omitempty"` -} - -// [Flags] -type DeploymentOperationStatus string - -type deploymentOperationStatusValuesType struct { - Undefined DeploymentOperationStatus - Queued DeploymentOperationStatus - Scheduled DeploymentOperationStatus - Pending DeploymentOperationStatus - Approved DeploymentOperationStatus - Rejected DeploymentOperationStatus - Deferred DeploymentOperationStatus - QueuedForAgent DeploymentOperationStatus - PhaseInProgress DeploymentOperationStatus - PhaseSucceeded DeploymentOperationStatus - PhasePartiallySucceeded DeploymentOperationStatus - PhaseFailed DeploymentOperationStatus - Canceled DeploymentOperationStatus - PhaseCanceled DeploymentOperationStatus - ManualInterventionPending DeploymentOperationStatus - QueuedForPipeline DeploymentOperationStatus - Cancelling DeploymentOperationStatus - EvaluatingGates DeploymentOperationStatus - GateFailed DeploymentOperationStatus - All DeploymentOperationStatus -} - -var DeploymentOperationStatusValues = deploymentOperationStatusValuesType{ - // The deployment operation status is undefined. - Undefined: "undefined", - // The deployment operation status is queued. - Queued: "queued", - // The deployment operation status is scheduled. - Scheduled: "scheduled", - // The deployment operation status is pending. - Pending: "pending", - // The deployment operation status is approved. - Approved: "approved", - // The deployment operation status is rejected. - Rejected: "rejected", - // The deployment operation status is deferred. - Deferred: "deferred", - // The deployment operation status is queued for agent. - QueuedForAgent: "queuedForAgent", - // The deployment operation status is phase in progress. - PhaseInProgress: "phaseInProgress", - // The deployment operation status is phase succeeded. - PhaseSucceeded: "phaseSucceeded", - // The deployment operation status is phase partially succeeded. - PhasePartiallySucceeded: "phasePartiallySucceeded", - // The deployment operation status is phase failed. - PhaseFailed: "phaseFailed", - // The deployment operation status is canceled. - Canceled: "canceled", - // The deployment operation status is phase canceled. - PhaseCanceled: "phaseCanceled", - // The deployment operation status is manualintervention pending. - ManualInterventionPending: "manualInterventionPending", - // The deployment operation status is queued for pipeline. - QueuedForPipeline: "queuedForPipeline", - // The deployment operation status is cancelling. - Cancelling: "cancelling", - // The deployment operation status is EvaluatingGates. - EvaluatingGates: "evaluatingGates", - // The deployment operation status is GateFailed. - GateFailed: "gateFailed", - // The deployment operation status is all. - All: "all", -} - -type DeploymentQueryParameters struct { - // Query deployments based specified artifact source id. - ArtifactSourceId *string `json:"artifactSourceId,omitempty"` - // Query deployments based specified artifact type id. - ArtifactTypeId *string `json:"artifactTypeId,omitempty"` - // Query deployments based specified artifact versions. - ArtifactVersions *[]string `json:"artifactVersions,omitempty"` - // Query deployments number of deployments per environment. - DeploymentsPerEnvironment *int `json:"deploymentsPerEnvironment,omitempty"` - // Query deployment based on deployment status. - DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` - // Query deployments of specified environments. - Environments *[]DefinitionEnvironmentReference `json:"environments,omitempty"` - // Query deployments based specified expands. - Expands *DeploymentExpands `json:"expands,omitempty"` - // Specify deleted deployments should return or not. - IsDeleted *bool `json:"isDeleted,omitempty"` - // Deprecated: - LatestDeploymentsOnly *bool `json:"latestDeploymentsOnly,omitempty"` - // Deprecated: - MaxDeploymentsPerEnvironment *int `json:"maxDeploymentsPerEnvironment,omitempty"` - // Deprecated: - MaxModifiedTime *azuredevops.Time `json:"maxModifiedTime,omitempty"` - // Deprecated: - MinModifiedTime *azuredevops.Time `json:"minModifiedTime,omitempty"` - // Query deployment based on deployment operation status. - OperationStatus *DeploymentOperationStatus `json:"operationStatus,omitempty"` - // Deprecated: - QueryOrder *ReleaseQueryOrder `json:"queryOrder,omitempty"` - // Query deployments based query type. - QueryType *DeploymentsQueryType `json:"queryType,omitempty"` - // Query deployments based specified source branch. - SourceBranch *string `json:"sourceBranch,omitempty"` -} - -// [Flags] -type DeploymentReason string - -type deploymentReasonValuesType struct { - None DeploymentReason - Manual DeploymentReason - Automated DeploymentReason - Scheduled DeploymentReason - RedeployTrigger DeploymentReason -} - -var DeploymentReasonValues = deploymentReasonValuesType{ - // The deployment reason is none. - None: "none", - // The deployment reason is manual. - Manual: "manual", - // The deployment reason is automated. - Automated: "automated", - // The deployment reason is scheduled. - Scheduled: "scheduled", - // The deployment reason is RedeployTrigger. - RedeployTrigger: "redeployTrigger", -} - -type DeploymentsQueryType string - -type deploymentsQueryTypeValuesType struct { - Regular DeploymentsQueryType - FailingSince DeploymentsQueryType -} - -var DeploymentsQueryTypeValues = deploymentsQueryTypeValuesType{ - Regular: "regular", - FailingSince: "failingSince", -} - -type DeploymentStartedEvent struct { - Environment *ReleaseEnvironment `json:"environment,omitempty"` - Project *ProjectReference `json:"project,omitempty"` - Release *Release `json:"release,omitempty"` -} - -// [Flags] -type DeploymentStatus string - -type deploymentStatusValuesType struct { - Undefined DeploymentStatus - NotDeployed DeploymentStatus - InProgress DeploymentStatus - Succeeded DeploymentStatus - PartiallySucceeded DeploymentStatus - Failed DeploymentStatus - All DeploymentStatus -} - -var DeploymentStatusValues = deploymentStatusValuesType{ - // The deployment status is undefined. - Undefined: "undefined", - // The deployment status is not deployed. - NotDeployed: "notDeployed", - // The deployment status is in progress. - InProgress: "inProgress", - // The deployment status is succeeded. - Succeeded: "succeeded", - // The deployment status is partiallysucceeded. - PartiallySucceeded: "partiallySucceeded", - // The deployment status is failed. - Failed: "failed", - // The deployment status is all. - All: "all", -} - -type DeployPhase struct { - // Gets and sets the name of deploy phase. - Name *string `json:"name,omitempty"` - // Indicates the deploy phase type. - PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` - // Gets and sets the rank of deploy phase. - Rank *int `json:"rank,omitempty"` - // Gets and sets the reference name of deploy phase. - RefName *string `json:"refName,omitempty"` - // Gets and sets the workflow tasks for the deploy phase. - WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` -} - -// [Flags] -type DeployPhaseStatus string - -type deployPhaseStatusValuesType struct { - Undefined DeployPhaseStatus - NotStarted DeployPhaseStatus - InProgress DeployPhaseStatus - PartiallySucceeded DeployPhaseStatus - Succeeded DeployPhaseStatus - Failed DeployPhaseStatus - Canceled DeployPhaseStatus - Skipped DeployPhaseStatus - Cancelling DeployPhaseStatus -} - -var DeployPhaseStatusValues = deployPhaseStatusValuesType{ - // Phase status not set. - Undefined: "undefined", - // Phase execution not started. - NotStarted: "notStarted", - // Phase execution in progress. - InProgress: "inProgress", - // Phase execution partially succeeded. - PartiallySucceeded: "partiallySucceeded", - // Phase execution succeeded. - Succeeded: "succeeded", - // Phase execution failed. - Failed: "failed", - // Phase execution canceled. - Canceled: "canceled", - // Phase execution skipped. - Skipped: "skipped", - // Phase is in cancelling state. - Cancelling: "cancelling", -} - -// [Flags] -type DeployPhaseTypes string - -type deployPhaseTypesValuesType struct { - Undefined DeployPhaseTypes - AgentBasedDeployment DeployPhaseTypes - RunOnServer DeployPhaseTypes - MachineGroupBasedDeployment DeployPhaseTypes - DeploymentGates DeployPhaseTypes -} - -var DeployPhaseTypesValues = deployPhaseTypesValuesType{ - // Phase type not defined. Don't use this. - Undefined: "undefined", - // Phase type which contains tasks executed on agent. - AgentBasedDeployment: "agentBasedDeployment", - // Phase type which contains tasks executed by server. - RunOnServer: "runOnServer", - // Phase type which contains tasks executed on deployment group machines. - MachineGroupBasedDeployment: "machineGroupBasedDeployment", - // Phase type which contains tasks which acts as Gates for the deployment to go forward. - DeploymentGates: "deploymentGates", -} - -type EmailRecipients struct { - // List of email addresses. - EmailAddresses *[]string `json:"emailAddresses,omitempty"` - // List of TFS IDs guids. - TfsIds *[]uuid.UUID `json:"tfsIds,omitempty"` -} - -// Defines policy on environment queuing at Release Management side queue. We will send to Environment Runner [creating pre-deploy and other steps] only when the policies mentioned are satisfied. -type EnvironmentExecutionPolicy struct { - // This policy decides, how many environments would be with Environment Runner. - ConcurrencyCount *int `json:"concurrencyCount,omitempty"` - // Queue depth in the EnvironmentQueue table, this table keeps the environment entries till Environment Runner is free [as per it's policy] to take another environment for running. - QueueDepthCount *int `json:"queueDepthCount,omitempty"` -} - -type EnvironmentOptions struct { - // Gets and sets as the auto link workitems or not. - AutoLinkWorkItems *bool `json:"autoLinkWorkItems,omitempty"` - // Gets and sets as the badge enabled or not. - BadgeEnabled *bool `json:"badgeEnabled,omitempty"` - // Deprecated: Use Notifications instead. - EmailNotificationType *string `json:"emailNotificationType,omitempty"` - // Deprecated: Use Notifications instead. - EmailRecipients *string `json:"emailRecipients,omitempty"` - // Deprecated: Use DeploymentInput.EnableAccessToken instead. - EnableAccessToken *bool `json:"enableAccessToken,omitempty"` - // Gets and sets as the publish deployment status or not. - PublishDeploymentStatus *bool `json:"publishDeploymentStatus,omitempty"` - // Gets and sets as the.pull request deployment enabled or not. - PullRequestDeploymentEnabled *bool `json:"pullRequestDeploymentEnabled,omitempty"` - // Deprecated: Use DeploymentInput.SkipArtifactsDownload instead. - SkipArtifactsDownload *bool `json:"skipArtifactsDownload,omitempty"` - // Deprecated: Use DeploymentInput.TimeoutInMinutes instead. - TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` -} - -type EnvironmentRetentionPolicy struct { - // Gets and sets the number of days to keep environment. - DaysToKeep *int `json:"daysToKeep,omitempty"` - // Gets and sets the number of releases to keep. - ReleasesToKeep *int `json:"releasesToKeep,omitempty"` - // Gets and sets as the build to be retained or not. - RetainBuild *bool `json:"retainBuild,omitempty"` -} - -// [Flags] -type EnvironmentStatus string - -type environmentStatusValuesType struct { - Undefined EnvironmentStatus - NotStarted EnvironmentStatus - InProgress EnvironmentStatus - Succeeded EnvironmentStatus - Canceled EnvironmentStatus - Rejected EnvironmentStatus - Queued EnvironmentStatus - Scheduled EnvironmentStatus - PartiallySucceeded EnvironmentStatus -} - -var EnvironmentStatusValues = environmentStatusValuesType{ - // Environment status not set. - Undefined: "undefined", - // Environment is in not started state. - NotStarted: "notStarted", - // Environment is in progress state. - InProgress: "inProgress", - // Environment is in succeeded state. - Succeeded: "succeeded", - // Environment is in canceled state. - Canceled: "canceled", - // Environment is in rejected state. - Rejected: "rejected", - // Environment is in queued state. - Queued: "queued", - // Environment is in scheduled state. - Scheduled: "scheduled", - // Environment is in partially succeeded state. - PartiallySucceeded: "partiallySucceeded", -} - -type EnvironmentTrigger struct { - // Definition environment ID on which this trigger applicable. - DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` - // ReleaseDefinition ID on which this trigger applicable. - ReleaseDefinitionId *int `json:"releaseDefinitionId,omitempty"` - // Gets or sets the trigger content. - TriggerContent *string `json:"triggerContent,omitempty"` - // Gets or sets the trigger type. - TriggerType *EnvironmentTriggerType `json:"triggerType,omitempty"` -} - -type EnvironmentTriggerContent struct { - // Gets or sets action. - Action *string `json:"action,omitempty"` - // Gets or sets list of event types. - EventTypes *[]string `json:"eventTypes,omitempty"` -} - -type EnvironmentTriggerType string - -type environmentTriggerTypeValuesType struct { - Undefined EnvironmentTriggerType - DeploymentGroupRedeploy EnvironmentTriggerType - RollbackRedeploy EnvironmentTriggerType -} - -var EnvironmentTriggerTypeValues = environmentTriggerTypeValuesType{ - // Environment trigger type undefined. - Undefined: "undefined", - // Environment trigger type is deployment group redeploy. - DeploymentGroupRedeploy: "deploymentGroupRedeploy", - // Environment trigger type is Rollback. - RollbackRedeploy: "rollbackRedeploy", -} - -type ExecutionInput struct { - // Parallel execution type, for example MultiConfiguration or MultiMachine. - ParallelExecutionType *ParallelExecutionTypes `json:"parallelExecutionType,omitempty"` -} - -// Class to represent favorite entry. -type FavoriteItem struct { - // Application specific data for the entry. - Data *string `json:"data,omitempty"` - // Unique Id of the the entry. - Id *uuid.UUID `json:"id,omitempty"` - // Display text for favorite entry. - Name *string `json:"name,omitempty"` - // Application specific favorite entry type. Empty or Null represents that Favorite item is a Folder. - Type *string `json:"type,omitempty"` -} - -type Folder struct { - // Identity who created this folder. - CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` - // Time when this folder created. - CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` - // Description of the folder. - Description *string `json:"description,omitempty"` - // Identity who last changed this folder. - LastChangedBy *webapi.IdentityRef `json:"lastChangedBy,omitempty"` - // Time when this folder last changed. - LastChangedDate *azuredevops.Time `json:"lastChangedDate,omitempty"` - // path of the folder. - Path *string `json:"path,omitempty"` -} - -type FolderPathQueryOrder string - -type folderPathQueryOrderValuesType struct { - None FolderPathQueryOrder - Ascending FolderPathQueryOrder - Descending FolderPathQueryOrder -} - -var FolderPathQueryOrderValues = folderPathQueryOrderValuesType{ - // No order. - None: "none", - // Order by folder name and path ascending. - Ascending: "ascending", - // Order by folder name and path descending. - Descending: "descending", -} - -type GatesDeploymentInput struct { - // Gets or sets the job condition. - Condition *string `json:"condition,omitempty"` - // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. - JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` - // Gets or sets the override inputs. - OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` - // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. - TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` - // Gates minimum success duration. - MinimumSuccessDuration *int `json:"minimumSuccessDuration,omitempty"` - // Gates sampling interval. - SamplingInterval *int `json:"samplingInterval,omitempty"` - // Gates stabilization time. - StabilizationTime *int `json:"stabilizationTime,omitempty"` -} - -type GatesDeployPhase struct { - // Gets and sets the name of deploy phase. - Name *string `json:"name,omitempty"` - // Indicates the deploy phase type. - PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` - // Gets and sets the rank of deploy phase. - Rank *int `json:"rank,omitempty"` - // Gets and sets the reference name of deploy phase. - RefName *string `json:"refName,omitempty"` - // Gets and sets the workflow tasks for the deploy phase. - WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` - // Gets and sets the gate job input. - DeploymentInput *GatesDeploymentInput `json:"deploymentInput,omitempty"` -} - -// [Flags] -type GateStatus string - -type gateStatusValuesType struct { - None GateStatus - Pending GateStatus - InProgress GateStatus - Succeeded GateStatus - Failed GateStatus - Canceled GateStatus -} - -var GateStatusValues = gateStatusValuesType{ - // The gate does not have the status set. - None: "none", - // The gate is in pending state. - Pending: "pending", - // The gate is currently in progress. - InProgress: "inProgress", - // The gate completed successfully. - Succeeded: "succeeded", - // The gate execution failed. - Failed: "failed", - // The gate execution cancelled. - Canceled: "canceled", -} - -type GateUpdateMetadata struct { - // Comment. - Comment *string `json:"comment,omitempty"` - // Name of gate to be ignored. - GatesToIgnore *[]string `json:"gatesToIgnore,omitempty"` -} - -type GitArtifactDownloadInput struct { - // Gets or sets the alias of artifact. - Alias *string `json:"alias,omitempty"` - // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. - ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` - // Gets or sets the artifact items of the input. - ArtifactItems *[]string `json:"artifactItems,omitempty"` - // Gets or sets the type of artifact. - ArtifactType *string `json:"artifactType,omitempty"` -} - -type GitHubArtifactDownloadInput struct { - // Gets or sets the alias of artifact. - Alias *string `json:"alias,omitempty"` - // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. - ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` - // Gets or sets the artifact items of the input. - ArtifactItems *[]string `json:"artifactItems,omitempty"` - // Gets or sets the type of artifact. - ArtifactType *string `json:"artifactType,omitempty"` -} - -type IgnoredGate struct { - // Gets the date on which gate is last ignored. - LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` - // Name of gate ignored. - Name *string `json:"name,omitempty"` -} - -type Issue struct { - // Issue data. - Data *map[string]string `json:"data,omitempty"` - // Issue type, for example error, warning or info. - IssueType *string `json:"issueType,omitempty"` - // Issue message. - Message *string `json:"message,omitempty"` -} - -type IssueSource string - -type issueSourceValuesType struct { - None IssueSource - User IssueSource - System IssueSource -} - -var IssueSourceValues = issueSourceValuesType{ - None: "none", - User: "user", - System: "system", -} - -type JenkinsArtifactDownloadInput struct { - // Gets or sets the alias of artifact. - Alias *string `json:"alias,omitempty"` - // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. - ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` - // Gets or sets the artifact items of the input. - ArtifactItems *[]string `json:"artifactItems,omitempty"` - // Gets or sets the type of artifact. - ArtifactType *string `json:"artifactType,omitempty"` -} - -type MachineGroupBasedDeployPhase struct { - // Gets and sets the name of deploy phase. - Name *string `json:"name,omitempty"` - // Indicates the deploy phase type. - PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` - // Gets and sets the rank of deploy phase. - Rank *int `json:"rank,omitempty"` - // Gets and sets the reference name of deploy phase. - RefName *string `json:"refName,omitempty"` - // Gets and sets the workflow tasks for the deploy phase. - WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` - // Gets and sets the deployment group job input - DeploymentInput *MachineGroupDeploymentInput `json:"deploymentInput,omitempty"` -} - -type MachineGroupDeploymentInput struct { - // Gets or sets the job condition. - Condition *string `json:"condition,omitempty"` - // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. - JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` - // Gets or sets the override inputs. - OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` - // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. - TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` - // Artifacts that downloaded during job execution. - ArtifactsDownloadInput *ArtifactsDownloadInput `json:"artifactsDownloadInput,omitempty"` - // List demands that needs to meet to execute the job. - Demands *[]interface{} `json:"demands,omitempty"` - // Indicates whether to include access token in deployment job or not. - EnableAccessToken *bool `json:"enableAccessToken,omitempty"` - // Id of the pool on which job get executed. - QueueId *int `json:"queueId,omitempty"` - // Indicates whether artifacts downloaded while job execution or not. - SkipArtifactsDownload *bool `json:"skipArtifactsDownload,omitempty"` - // Deployment group health option. - DeploymentHealthOption *string `json:"deploymentHealthOption,omitempty"` - // Minimum percentage of the targets guaranteed to be healthy. - HealthPercent *int `json:"healthPercent,omitempty"` - // Deployment target tag filter. - Tags *[]string `json:"tags,omitempty"` -} - -type MailMessage struct { - // Body of mail. - Body *string `json:"body,omitempty"` - // Mail CC recipients. - Cc *EmailRecipients `json:"cc,omitempty"` - // Reply to. - InReplyTo *string `json:"inReplyTo,omitempty"` - // Message ID of the mail. - MessageId *string `json:"messageId,omitempty"` - // Data when should be replied to mail. - ReplyBy *azuredevops.Time `json:"replyBy,omitempty"` - // Reply to Email recipients. - ReplyTo *EmailRecipients `json:"replyTo,omitempty"` - // List of mail section types. - Sections *[]MailSectionType `json:"sections,omitempty"` - // Mail sender type. - SenderType *SenderType `json:"senderType,omitempty"` - // Subject of the mail. - Subject *string `json:"subject,omitempty"` - // Mail To recipients. - To *EmailRecipients `json:"to,omitempty"` -} - -type MailSectionType string - -type mailSectionTypeValuesType struct { - Details MailSectionType - Environments MailSectionType - Issues MailSectionType - TestResults MailSectionType - WorkItems MailSectionType - ReleaseInfo MailSectionType -} - -var MailSectionTypeValues = mailSectionTypeValuesType{ - Details: "details", - Environments: "environments", - Issues: "issues", - TestResults: "testResults", - WorkItems: "workItems", - ReleaseInfo: "releaseInfo", -} - -type ManualIntervention struct { - // Gets or sets the identity who should approve. - Approver *webapi.IdentityRef `json:"approver,omitempty"` - // Gets or sets comments for approval. - Comments *string `json:"comments,omitempty"` - // Gets date on which it got created. - CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` - // Gets the unique identifier for manual intervention. - Id *int `json:"id,omitempty"` - // Gets or sets instructions for approval. - Instructions *string `json:"instructions,omitempty"` - // Gets date on which it got modified. - ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` - // Gets or sets the name. - Name *string `json:"name,omitempty"` - // Gets releaseReference for manual intervention. - Release *ReleaseShallowReference `json:"release,omitempty"` - // Gets releaseDefinitionReference for manual intervention. - ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` - // Gets releaseEnvironmentReference for manual intervention. - ReleaseEnvironment *ReleaseEnvironmentShallowReference `json:"releaseEnvironment,omitempty"` - // Gets or sets the status of the manual intervention. - Status *ManualInterventionStatus `json:"status,omitempty"` - // Get task instance identifier. - TaskInstanceId *uuid.UUID `json:"taskInstanceId,omitempty"` - // Gets url to access the manual intervention. - Url *string `json:"url,omitempty"` -} - -// [Flags] Describes manual intervention status -type ManualInterventionStatus string - -type manualInterventionStatusValuesType struct { - Unknown ManualInterventionStatus - Pending ManualInterventionStatus - Rejected ManualInterventionStatus - Approved ManualInterventionStatus - Canceled ManualInterventionStatus -} - -var ManualInterventionStatusValues = manualInterventionStatusValuesType{ - // The manual intervention does not have the status set. - Unknown: "unknown", - // The manual intervention is pending. - Pending: "pending", - // The manual intervention is rejected. - Rejected: "rejected", - // The manual intervention is approved. - Approved: "approved", - // The manual intervention is canceled. - Canceled: "canceled", -} - -type ManualInterventionUpdateMetadata struct { - // Sets the comment for manual intervention update. - Comment *string `json:"comment,omitempty"` - // Sets the status of the manual intervention. - Status *ManualInterventionStatus `json:"status,omitempty"` -} - -type MappingDetails struct { - Mappings *map[string]forminput.InputValue `json:"mappings,omitempty"` -} - -type Metric struct { - // Name of the Metric. - Name *string `json:"name,omitempty"` - // Value of the Metric. - Value *int `json:"value,omitempty"` -} - -type MultiConfigInput struct { - // Parallel execution type, for example MultiConfiguration or MultiMachine. - ParallelExecutionType *ParallelExecutionTypes `json:"parallelExecutionType,omitempty"` - // Indicate whether continue execution of deployment on error or not. - ContinueOnError *bool `json:"continueOnError,omitempty"` - // Maximum number of agents used while parallel execution. - MaxNumberOfAgents *int `json:"maxNumberOfAgents,omitempty"` - // Multipliers for parallel execution of deployment, for example x86,x64. - Multipliers *string `json:"multipliers,omitempty"` -} - -type MultiMachineInput struct { - // Parallel execution type, for example MultiConfiguration or MultiMachine. - ParallelExecutionType *ParallelExecutionTypes `json:"parallelExecutionType,omitempty"` - // Indicate whether continue execution of deployment on error or not. - ContinueOnError *bool `json:"continueOnError,omitempty"` - // Maximum number of agents used while parallel execution. - MaxNumberOfAgents *int `json:"maxNumberOfAgents,omitempty"` -} - -type PackageTrigger struct { - // Type of release trigger. - TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` - // Package trigger alias. - Alias *string `json:"alias,omitempty"` -} - -type ParallelExecutionInputBase struct { - // Parallel execution type, for example MultiConfiguration or MultiMachine. - ParallelExecutionType *ParallelExecutionTypes `json:"parallelExecutionType,omitempty"` - // Indicate whether continue execution of deployment on error or not. - ContinueOnError *bool `json:"continueOnError,omitempty"` - // Maximum number of agents used while parallel execution. - MaxNumberOfAgents *int `json:"maxNumberOfAgents,omitempty"` -} - -// [Flags] -type ParallelExecutionTypes string - -type parallelExecutionTypesValuesType struct { - None ParallelExecutionTypes - MultiConfiguration ParallelExecutionTypes - MultiMachine ParallelExecutionTypes -} - -var ParallelExecutionTypesValues = parallelExecutionTypesValuesType{ - None: "none", - MultiConfiguration: "multiConfiguration", - MultiMachine: "multiMachine", -} - -// [Flags] -type PipelineProcessTypes string - -type pipelineProcessTypesValuesType struct { - Designer PipelineProcessTypes - Yaml PipelineProcessTypes -} - -var PipelineProcessTypesValues = pipelineProcessTypesValuesType{ - Designer: "designer", - Yaml: "yaml", -} - -type ProjectReference struct { - // Gets the unique identifier of this field. - Id *uuid.UUID `json:"id,omitempty"` - // Gets name of project. - Name *string `json:"name,omitempty"` -} - -type PropertySelector struct { - // List of properties. - Properties *[]string `json:"properties,omitempty"` - // Property selector type. - SelectorType *PropertySelectorType `json:"selectorType,omitempty"` -} - -type PropertySelectorType string - -type propertySelectorTypeValuesType struct { - Inclusion PropertySelectorType - Exclusion PropertySelectorType -} - -var PropertySelectorTypeValues = propertySelectorTypeValuesType{ - // Include in property selector. - Inclusion: "inclusion", - // Exclude in property selector. - Exclusion: "exclusion", -} - -type PullRequestConfiguration struct { - // Code repository reference. - CodeRepositoryReference *CodeRepositoryReference `json:"codeRepositoryReference,omitempty"` - // In case of Source based artifacts, Code reference will be present in Artifact details. - UseArtifactReference *bool `json:"useArtifactReference,omitempty"` -} - -type PullRequestFilter struct { - // List of tags. - Tags *[]string `json:"tags,omitempty"` - // Target branch of pull request. - TargetBranch *string `json:"targetBranch,omitempty"` -} - -type PullRequestSystemType string - -type pullRequestSystemTypeValuesType struct { - None PullRequestSystemType - TfsGit PullRequestSystemType - GitHub PullRequestSystemType -} - -var PullRequestSystemTypeValues = pullRequestSystemTypeValuesType{ - None: "none", - TfsGit: "tfsGit", - GitHub: "gitHub", -} - -type PullRequestTrigger struct { - // Type of release trigger. - TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` - // Artifact alias trigger is linked to. - ArtifactAlias *string `json:"artifactAlias,omitempty"` - // Code reference details of pull request. - PullRequestConfiguration *PullRequestConfiguration `json:"pullRequestConfiguration,omitempty"` - // Policy name using which status will be published to pull request. - StatusPolicyName *string `json:"statusPolicyName,omitempty"` - // List of filters applied while trigger. - TriggerConditions *[]PullRequestFilter `json:"triggerConditions,omitempty"` -} - -type QueuedReleaseData struct { - // Project ID of the release. - ProjectId *uuid.UUID `json:"projectId,omitempty"` - // Release queue position. - QueuePosition *int `json:"queuePosition,omitempty"` - // Queued release ID. - ReleaseId *int `json:"releaseId,omitempty"` -} - -type RealtimeReleaseDefinitionEvent struct { - DefinitionId *int `json:"definitionId,omitempty"` - ProjectId *uuid.UUID `json:"projectId,omitempty"` -} - -type RealtimeReleaseEvent struct { - EnvironmentId *int `json:"environmentId,omitempty"` - ProjectId *uuid.UUID `json:"projectId,omitempty"` - ReleaseId *int `json:"releaseId,omitempty"` -} - -type Release struct { - // Gets links to access the release. - Links interface{} `json:"_links,omitempty"` - // Gets or sets the list of artifacts. - Artifacts *[]Artifact `json:"artifacts,omitempty"` - // Gets or sets comment. - Comment *string `json:"comment,omitempty"` - // Gets or sets the identity who created. - CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` - // Gets date on which it got created. - CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` - // Gets revision number of definition snapshot. - DefinitionSnapshotRevision *int `json:"definitionSnapshotRevision,omitempty"` - // Gets or sets description of release. - Description *string `json:"description,omitempty"` - // Gets list of environments. - Environments *[]ReleaseEnvironment `json:"environments,omitempty"` - // Gets the unique identifier of this field. - Id *int `json:"id,omitempty"` - // Whether to exclude the release from retention policies. - KeepForever *bool `json:"keepForever,omitempty"` - // Gets logs container url. - LogsContainerUrl *string `json:"logsContainerUrl,omitempty"` - // Gets or sets the identity who modified. - ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` - // Gets date on which it got modified. - ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` - // Gets name. - Name *string `json:"name,omitempty"` - // Gets pool name. - PoolName *string `json:"poolName,omitempty"` - // Gets or sets project reference. - ProjectReference *ProjectReference `json:"projectReference,omitempty"` - Properties interface{} `json:"properties,omitempty"` - // Gets reason of release. - Reason *ReleaseReason `json:"reason,omitempty"` - // Gets releaseDefinitionReference which specifies the reference of the release definition to which this release is associated. - ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` - // Gets or sets the release definition revision. - ReleaseDefinitionRevision *int `json:"releaseDefinitionRevision,omitempty"` - // Gets release name format. - ReleaseNameFormat *string `json:"releaseNameFormat,omitempty"` - // Gets status. - Status *ReleaseStatus `json:"status,omitempty"` - // Gets or sets list of tags. - Tags *[]string `json:"tags,omitempty"` - TriggeringArtifactAlias *string `json:"triggeringArtifactAlias,omitempty"` - // Deprecated: Use Links instead. - Url *string `json:"url,omitempty"` - // Gets the list of variable groups. - VariableGroups *[]VariableGroup `json:"variableGroups,omitempty"` - // Gets or sets the dictionary of variables. - Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` -} - -type ReleaseAbandonedEvent struct { - Project *ProjectReference `json:"project,omitempty"` - Release *Release `json:"release,omitempty"` -} - -type ReleaseApproval struct { - // Gets or sets the type of approval. - ApprovalType *ApprovalType `json:"approvalType,omitempty"` - // Gets the identity who approved. - ApprovedBy *webapi.IdentityRef `json:"approvedBy,omitempty"` - // Gets or sets the identity who should approve. - Approver *webapi.IdentityRef `json:"approver,omitempty"` - // Gets or sets attempt which specifies as which deployment attempt it belongs. - Attempt *int `json:"attempt,omitempty"` - // Gets or sets comments for approval. - Comments *string `json:"comments,omitempty"` - // Gets date on which it got created. - CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` - // Gets history which specifies all approvals associated with this approval. - History *[]ReleaseApprovalHistory `json:"history,omitempty"` - // Gets the unique identifier of this field. - Id *int `json:"id,omitempty"` - // Gets or sets as approval is automated or not. - IsAutomated *bool `json:"isAutomated,omitempty"` - // Deprecated: Use Notifications instead. - IsNotificationOn *bool `json:"isNotificationOn,omitempty"` - // Gets date on which it got modified. - ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` - // Gets or sets rank which specifies the order of the approval. e.g. Same rank denotes parallel approval. - Rank *int `json:"rank,omitempty"` - // Gets releaseReference which specifies the reference of the release to which this approval is associated. - Release *ReleaseShallowReference `json:"release,omitempty"` - // Gets releaseDefinitionReference which specifies the reference of the release definition to which this approval is associated. - ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` - // Gets releaseEnvironmentReference which specifies the reference of the release environment to which this approval is associated. - ReleaseEnvironment *ReleaseEnvironmentShallowReference `json:"releaseEnvironment,omitempty"` - // Gets the revision number. - Revision *int `json:"revision,omitempty"` - // Gets or sets the status of the approval. - Status *ApprovalStatus `json:"status,omitempty"` - // Deprecated: Use Attempt instead. - TrialNumber *int `json:"trialNumber,omitempty"` - // Gets url to access the approval. - Url *string `json:"url,omitempty"` -} - -type ReleaseApprovalHistory struct { - // Identity of the approver. - Approver *webapi.IdentityRef `json:"approver,omitempty"` - // Identity of the object who changed approval. - ChangedBy *webapi.IdentityRef `json:"changedBy,omitempty"` - // Approval history comments. - Comments *string `json:"comments,omitempty"` - // Time when this approval created. - CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` - // Time when this approval modified. - ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` - // Approval history revision. - Revision *int `json:"revision,omitempty"` -} - -type ReleaseApprovalPendingEvent struct { - Approval *ReleaseApproval `json:"approval,omitempty"` - ApprovalOptions *ApprovalOptions `json:"approvalOptions,omitempty"` - CompletedApprovals *[]ReleaseApproval `json:"completedApprovals,omitempty"` - DefinitionName *string `json:"definitionName,omitempty"` - Deployment *Deployment `json:"deployment,omitempty"` - EnvironmentId *int `json:"environmentId,omitempty"` - EnvironmentName *string `json:"environmentName,omitempty"` - Environments *[]ReleaseEnvironment `json:"environments,omitempty"` - IsMultipleRankApproval *bool `json:"isMultipleRankApproval,omitempty"` - PendingApprovals *[]ReleaseApproval `json:"pendingApprovals,omitempty"` - ReleaseCreator *string `json:"releaseCreator,omitempty"` - ReleaseName *string `json:"releaseName,omitempty"` - Title *string `json:"title,omitempty"` - WebAccessUri *string `json:"webAccessUri,omitempty"` -} - -type ReleaseArtifact struct { - // Gets or sets the artifact provider of ReleaseArtifact. - ArtifactProvider *ArtifactProvider `json:"artifactProvider,omitempty"` - // Gets or sets the artifact type of ReleaseArtifact. - ArtifactType *string `json:"artifactType,omitempty"` - // Gets or sets the definition json of ReleaseArtifact. - DefinitionData *string `json:"definitionData,omitempty"` - // Gets or sets the definition id of ReleaseArtifact. - DefinitionId *int `json:"definitionId,omitempty"` - // Gets or sets the description of ReleaseArtifact. - Description *string `json:"description,omitempty"` - // Gets or sets the id of ReleaseArtifact. - Id *int `json:"id,omitempty"` - // Gets or sets the name of ReleaseArtifact. - Name *string `json:"name,omitempty"` - // Gets or sets the release id. - ReleaseId *int `json:"releaseId,omitempty"` -} - -type ReleaseCondition struct { - // Gets or sets the condition type. - ConditionType *ConditionType `json:"conditionType,omitempty"` - // Gets or sets the name of the condition. e.g. 'ReleaseStarted'. - Name *string `json:"name,omitempty"` - // Gets or set value of the condition. - Value *string `json:"value,omitempty"` - // The release condition result. - Result *bool `json:"result,omitempty"` -} - -type ReleaseCreatedEvent struct { - Project *ProjectReference `json:"project,omitempty"` - Release *Release `json:"release,omitempty"` -} - -type ReleaseDefinition struct { - // Gets the links to related resources, APIs, and views for the release definition. - Links interface{} `json:"_links,omitempty"` - // Gets the unique identifier of release definition. - Id *int `json:"id,omitempty"` - // Gets or sets the name of the release definition. - Name *string `json:"name,omitempty"` - // Gets or sets the path of the release definition. - Path *string `json:"path,omitempty"` - // Gets or sets project reference. - ProjectReference *ProjectReference `json:"projectReference,omitempty"` - // Gets the REST API url to access the release definition. - Url *string `json:"url,omitempty"` - // Gets or sets the list of artifacts. - Artifacts *[]Artifact `json:"artifacts,omitempty"` - // Gets or sets comment. - Comment *string `json:"comment,omitempty"` - // Gets or sets the identity who created. - CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` - // Gets date on which it got created. - CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` - // Gets or sets the description. - Description *string `json:"description,omitempty"` - // Gets or sets the list of environments. - Environments *[]ReleaseDefinitionEnvironment `json:"environments,omitempty"` - // Whether release definition is deleted. - IsDeleted *bool `json:"isDeleted,omitempty"` - // Gets the reference of last release. - LastRelease *ReleaseReference `json:"lastRelease,omitempty"` - // Gets or sets the identity who modified. - ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` - // Gets date on which it got modified. - ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` - // Gets or sets properties. - Properties interface{} `json:"properties,omitempty"` - // Gets or sets the release name format. - ReleaseNameFormat *string `json:"releaseNameFormat,omitempty"` - // Deprecated: Retention policy at Release Definition level is deprecated. Use the Retention Policy at environment and API version 3.0-preview.2 or later - RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` - // Gets the revision number. - Revision *int `json:"revision,omitempty"` - // Gets or sets source of release definition. - Source *ReleaseDefinitionSource `json:"source,omitempty"` - // Gets or sets list of tags. - Tags *[]string `json:"tags,omitempty"` - // Gets or sets the list of triggers. - Triggers *[]interface{} `json:"triggers,omitempty"` - // Gets or sets the list of variable groups. - VariableGroups *[]int `json:"variableGroups,omitempty"` - // Gets or sets the dictionary of variables. - Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` -} - -type ReleaseDefinitionApprovals struct { - // Gets or sets the approval options. - ApprovalOptions *ApprovalOptions `json:"approvalOptions,omitempty"` - // Gets or sets the approvals. - Approvals *[]ReleaseDefinitionApprovalStep `json:"approvals,omitempty"` -} - -type ReleaseDefinitionApprovalStep struct { - // ID of the approval or deploy step. - Id *int `json:"id,omitempty"` - // Gets and sets the approver. - Approver *webapi.IdentityRef `json:"approver,omitempty"` - // Indicates whether the approval automated. - IsAutomated *bool `json:"isAutomated,omitempty"` - // Indicates whether the approval notification set. - IsNotificationOn *bool `json:"isNotificationOn,omitempty"` - // Gets or sets the rank of approval step. - Rank *int `json:"rank,omitempty"` -} - -type ReleaseDefinitionDeployStep struct { - // ID of the approval or deploy step. - Id *int `json:"id,omitempty"` - // The list of steps for this definition. - Tasks *[]WorkflowTask `json:"tasks,omitempty"` -} - -type ReleaseDefinitionEnvironment struct { - // Gets or sets the BadgeUrl. BadgeUrl will be used when Badge will be enabled in Release Definition Environment. - BadgeUrl *string `json:"badgeUrl,omitempty"` - // Gets or sets the environment conditions. - Conditions *[]Condition `json:"conditions,omitempty"` - // Gets or sets the current release reference. - CurrentRelease *ReleaseShallowReference `json:"currentRelease,omitempty"` - // Gets or sets the demands. - Demands *[]interface{} `json:"demands,omitempty"` - // Gets or sets the deploy phases of environment. - DeployPhases *[]interface{} `json:"deployPhases,omitempty"` - // Gets or sets the deploystep. - DeployStep *ReleaseDefinitionDeployStep `json:"deployStep,omitempty"` - // Gets or sets the environment options. - EnvironmentOptions *EnvironmentOptions `json:"environmentOptions,omitempty"` - // Gets or sets the triggers on environment. - EnvironmentTriggers *[]EnvironmentTrigger `json:"environmentTriggers,omitempty"` - // Gets or sets the environment execution policy. - ExecutionPolicy *EnvironmentExecutionPolicy `json:"executionPolicy,omitempty"` - // Gets and sets the ID of the ReleaseDefinitionEnvironment. - Id *int `json:"id,omitempty"` - // Gets and sets the name of the ReleaseDefinitionEnvironment. - Name *string `json:"name,omitempty"` - // Gets and sets the Owner of the ReleaseDefinitionEnvironment. - Owner *webapi.IdentityRef `json:"owner,omitempty"` - // Gets or sets the post deployment approvals. - PostDeployApprovals *ReleaseDefinitionApprovals `json:"postDeployApprovals,omitempty"` - // Gets or sets the post deployment gates. - PostDeploymentGates *ReleaseDefinitionGatesStep `json:"postDeploymentGates,omitempty"` - // Gets or sets the pre deployment approvals. - PreDeployApprovals *ReleaseDefinitionApprovals `json:"preDeployApprovals,omitempty"` - // Gets or sets the pre deployment gates. - PreDeploymentGates *ReleaseDefinitionGatesStep `json:"preDeploymentGates,omitempty"` - // Gets or sets the environment process parameters. - ProcessParameters *distributedtaskcommon.ProcessParameters `json:"processParameters,omitempty"` - // Gets or sets the properties on environment. - Properties interface{} `json:"properties,omitempty"` - // Gets or sets the queue ID. - QueueId *int `json:"queueId,omitempty"` - // Gets and sets the rank of the ReleaseDefinitionEnvironment. - Rank *int `json:"rank,omitempty"` - // Gets or sets the environment retention policy. - RetentionPolicy *EnvironmentRetentionPolicy `json:"retentionPolicy,omitempty"` - // Deprecated: This property is deprecated, use EnvironmentOptions instead. - RunOptions *map[string]string `json:"runOptions,omitempty"` - // Gets or sets the schedules - Schedules *[]ReleaseSchedule `json:"schedules,omitempty"` - // Gets or sets the variable groups. - VariableGroups *[]int `json:"variableGroups,omitempty"` - // Gets and sets the variables. - Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` -} - -type ReleaseDefinitionEnvironmentStep struct { - // ID of the approval or deploy step. - Id *int `json:"id,omitempty"` -} - -type ReleaseDefinitionEnvironmentSummary struct { - // ID of ReleaseDefinition environment summary. - Id *int `json:"id,omitempty"` - // List of release shallow reference deployed using this ReleaseDefinition. - LastReleases *[]ReleaseShallowReference `json:"lastReleases,omitempty"` - // Name of ReleaseDefinition environment summary. - Name *string `json:"name,omitempty"` -} - -type ReleaseDefinitionEnvironmentTemplate struct { - // Indicates whether template can be deleted or not. - CanDelete *bool `json:"canDelete,omitempty"` - // Category of the ReleaseDefinition environment template. - Category *string `json:"category,omitempty"` - // Description of the ReleaseDefinition environment template. - Description *string `json:"description,omitempty"` - // ReleaseDefinition environment data which used to create this template. - Environment *ReleaseDefinitionEnvironment `json:"environment,omitempty"` - // ID of the task which used to display icon used for this template. - IconTaskId *uuid.UUID `json:"iconTaskId,omitempty"` - // Icon uri of the template. - IconUri *string `json:"iconUri,omitempty"` - // ID of the ReleaseDefinition environment template. - Id *uuid.UUID `json:"id,omitempty"` - // Indicates whether template deleted or not. - IsDeleted *bool `json:"isDeleted,omitempty"` - // Name of the ReleaseDefinition environment template. - Name *string `json:"name,omitempty"` -} - -// [Flags] -type ReleaseDefinitionExpands string - -type releaseDefinitionExpandsValuesType struct { - None ReleaseDefinitionExpands - Environments ReleaseDefinitionExpands - Artifacts ReleaseDefinitionExpands - Triggers ReleaseDefinitionExpands - Variables ReleaseDefinitionExpands - Tags ReleaseDefinitionExpands - LastRelease ReleaseDefinitionExpands -} - -var ReleaseDefinitionExpandsValues = releaseDefinitionExpandsValuesType{ - // Returns top level properties of object. - None: "none", - // Include environments in return object. - Environments: "environments", - // Include artifacts in return object. - Artifacts: "artifacts", - // Include triggers in return object. - Triggers: "triggers", - // Include variables in return object. - Variables: "variables", - // Include tags in return object. - Tags: "tags", - // Include last release in return object. - LastRelease: "lastRelease", -} - -type ReleaseDefinitionGate struct { - // Gets or sets the gates workflow. - Tasks *[]WorkflowTask `json:"tasks,omitempty"` -} - -type ReleaseDefinitionGatesOptions struct { - // Gets or sets as the gates enabled or not. - IsEnabled *bool `json:"isEnabled,omitempty"` - // Gets or sets the minimum duration for steady results after a successful gates evaluation. - MinimumSuccessDuration *int `json:"minimumSuccessDuration,omitempty"` - // Gets or sets the time between re-evaluation of gates. - SamplingInterval *int `json:"samplingInterval,omitempty"` - // Gets or sets the delay before evaluation. - StabilizationTime *int `json:"stabilizationTime,omitempty"` - // Gets or sets the timeout after which gates fail. - Timeout *int `json:"timeout,omitempty"` -} - -type ReleaseDefinitionGatesStep struct { - // Gets or sets the gates. - Gates *[]ReleaseDefinitionGate `json:"gates,omitempty"` - // Gets or sets the gate options. - GatesOptions *ReleaseDefinitionGatesOptions `json:"gatesOptions,omitempty"` - // ID of the ReleaseDefinitionGateStep. - Id *int `json:"id,omitempty"` -} - -type ReleaseDefinitionQueryOrder string - -type releaseDefinitionQueryOrderValuesType struct { - IdAscending ReleaseDefinitionQueryOrder - IdDescending ReleaseDefinitionQueryOrder - NameAscending ReleaseDefinitionQueryOrder - NameDescending ReleaseDefinitionQueryOrder -} - -var ReleaseDefinitionQueryOrderValues = releaseDefinitionQueryOrderValuesType{ - // Return results based on release definition Id ascending order. - IdAscending: "idAscending", - // Return results based on release definition Id descending order. - IdDescending: "idDescending", - // Return results based on release definition name ascending order. - NameAscending: "nameAscending", - // Return results based on release definition name descending order. - NameDescending: "nameDescending", -} - -type ReleaseDefinitionRevision struct { - // Gets api-version for revision object. - ApiVersion *string `json:"apiVersion,omitempty"` - // Gets the identity who did change. - ChangedBy *webapi.IdentityRef `json:"changedBy,omitempty"` - // Gets date on which ReleaseDefinition changed. - ChangedDate *azuredevops.Time `json:"changedDate,omitempty"` - // Gets type of change. - ChangeType *AuditAction `json:"changeType,omitempty"` - // Gets comments for revision. - Comment *string `json:"comment,omitempty"` - // Get id of the definition. - DefinitionId *int `json:"definitionId,omitempty"` - // Gets definition URL. - DefinitionUrl *string `json:"definitionUrl,omitempty"` - // Get revision number of the definition. - Revision *int `json:"revision,omitempty"` -} - -type ReleaseDefinitionShallowReference struct { - // Gets the links to related resources, APIs, and views for the release definition. - Links interface{} `json:"_links,omitempty"` - // Gets the unique identifier of release definition. - Id *int `json:"id,omitempty"` - // Gets or sets the name of the release definition. - Name *string `json:"name,omitempty"` - // Gets or sets the path of the release definition. - Path *string `json:"path,omitempty"` - // Gets or sets project reference. - ProjectReference *ProjectReference `json:"projectReference,omitempty"` - // Gets the REST API url to access the release definition. - Url *string `json:"url,omitempty"` -} - -// [Flags] -type ReleaseDefinitionSource string - -type releaseDefinitionSourceValuesType struct { - Undefined ReleaseDefinitionSource - RestApi ReleaseDefinitionSource - UserInterface ReleaseDefinitionSource - Ibiza ReleaseDefinitionSource - PortalExtensionApi ReleaseDefinitionSource -} - -var ReleaseDefinitionSourceValues = releaseDefinitionSourceValuesType{ - // Indicates ReleaseDefinition source not defined. - Undefined: "undefined", - // Indicates ReleaseDefinition created using REST API. - RestApi: "restApi", - // Indicates ReleaseDefinition created using UI. - UserInterface: "userInterface", - // Indicates ReleaseDefinition created from Ibiza. - Ibiza: "ibiza", - // Indicates ReleaseDefinition created from PortalExtension API. - PortalExtensionApi: "portalExtensionApi", -} - -type ReleaseDefinitionSummary struct { - // List of Release Definition environment summary. - Environments *[]ReleaseDefinitionEnvironmentSummary `json:"environments,omitempty"` - // Release Definition reference. - ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` - // List of releases deployed using this Release Definition. - Releases *[]Release `json:"releases,omitempty"` -} - -type ReleaseDefinitionUndeleteParameter struct { - // Gets or sets comment. - Comment *string `json:"comment,omitempty"` -} - -type ReleaseDeployPhase struct { - // Deployment jobs of the phase. - DeploymentJobs *[]DeploymentJob `json:"deploymentJobs,omitempty"` - // Phase execution error logs. - ErrorLog *string `json:"errorLog,omitempty"` - // Deprecated: - Id *int `json:"id,omitempty"` - // List of manual intervention tasks execution information in phase. - ManualInterventions *[]ManualIntervention `json:"manualInterventions,omitempty"` - // Name of the phase. - Name *string `json:"name,omitempty"` - // ID of the phase. - PhaseId *string `json:"phaseId,omitempty"` - // Type of the phase. - PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` - // Rank of the phase. - Rank *int `json:"rank,omitempty"` - // Run Plan ID of the phase. - RunPlanId *uuid.UUID `json:"runPlanId,omitempty"` - // Phase start time. - StartedOn *azuredevops.Time `json:"startedOn,omitempty"` - // Status of the phase. - Status *DeployPhaseStatus `json:"status,omitempty"` -} - -type ReleaseEnvironment struct { - // Gets list of conditions. - Conditions *[]ReleaseCondition `json:"conditions,omitempty"` - // Gets date on which it got created. - CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` - // Gets definition environment id. - DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` - // Deprecated: Use DeploymentInput.Demands instead. - Demands *[]interface{} `json:"demands,omitempty"` - // Gets list of deploy phases snapshot. - DeployPhasesSnapshot *[]interface{} `json:"deployPhasesSnapshot,omitempty"` - // Gets deploy steps. - DeploySteps *[]DeploymentAttempt `json:"deploySteps,omitempty"` - // Gets environment options. - EnvironmentOptions *EnvironmentOptions `json:"environmentOptions,omitempty"` - // Gets the unique identifier of this field. - Id *int `json:"id,omitempty"` - // Gets date on which it got modified. - ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` - // Gets name. - Name *string `json:"name,omitempty"` - // Gets next scheduled UTC time. - NextScheduledUtcTime *azuredevops.Time `json:"nextScheduledUtcTime,omitempty"` - // Gets the identity who is owner for release environment. - Owner *webapi.IdentityRef `json:"owner,omitempty"` - // Gets list of post deploy approvals snapshot. - PostApprovalsSnapshot *ReleaseDefinitionApprovals `json:"postApprovalsSnapshot,omitempty"` - // Gets list of post deploy approvals. - PostDeployApprovals *[]ReleaseApproval `json:"postDeployApprovals,omitempty"` - // Post deployment gates snapshot data. - PostDeploymentGatesSnapshot *ReleaseDefinitionGatesStep `json:"postDeploymentGatesSnapshot,omitempty"` - // Gets list of pre deploy approvals snapshot. - PreApprovalsSnapshot *ReleaseDefinitionApprovals `json:"preApprovalsSnapshot,omitempty"` - // Gets list of pre deploy approvals. - PreDeployApprovals *[]ReleaseApproval `json:"preDeployApprovals,omitempty"` - // Pre deployment gates snapshot data. - PreDeploymentGatesSnapshot *ReleaseDefinitionGatesStep `json:"preDeploymentGatesSnapshot,omitempty"` - // Gets process parameters. - ProcessParameters *distributedtaskcommon.ProcessParameters `json:"processParameters,omitempty"` - // Deprecated: Use DeploymentInput.QueueId instead. - QueueId *int `json:"queueId,omitempty"` - // Gets rank. - Rank *int `json:"rank,omitempty"` - // Gets release reference which specifies the reference of the release to which this release environment is associated. - Release *ReleaseShallowReference `json:"release,omitempty"` - // Gets the identity who created release. - ReleaseCreatedBy *webapi.IdentityRef `json:"releaseCreatedBy,omitempty"` - // Gets releaseDefinitionReference which specifies the reference of the release definition to which this release environment is associated. - ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` - // Deprecated: Use Release object Description instead. - ReleaseDescription *string `json:"releaseDescription,omitempty"` - // Gets release id. - ReleaseId *int `json:"releaseId,omitempty"` - // Gets schedule deployment time of release environment. - ScheduledDeploymentTime *azuredevops.Time `json:"scheduledDeploymentTime,omitempty"` - // Gets list of schedules. - Schedules *[]ReleaseSchedule `json:"schedules,omitempty"` - // Gets environment status. - Status *EnvironmentStatus `json:"status,omitempty"` - // Gets time to deploy. - TimeToDeploy *float64 `json:"timeToDeploy,omitempty"` - // Gets trigger reason. - TriggerReason *string `json:"triggerReason,omitempty"` - // Gets the list of variable groups. - VariableGroups *[]VariableGroup `json:"variableGroups,omitempty"` - // Gets the dictionary of variables. - Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` - // Deprecated: Use DeployPhase.WorkflowTasks instead. - WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` -} - -type ReleaseEnvironmentCompletedEvent struct { - CreatedByName *string `json:"createdByName,omitempty"` - DefinitionId *int `json:"definitionId,omitempty"` - DefinitionName *string `json:"definitionName,omitempty"` - Environment *ReleaseEnvironment `json:"environment,omitempty"` - EnvironmentId *int `json:"environmentId,omitempty"` - ProjectName *string `json:"projectName,omitempty"` - Reason *DeploymentReason `json:"reason,omitempty"` - ReleaseCreatedBy *webapi.IdentityRef `json:"releaseCreatedBy,omitempty"` - ReleaseLogsUri *string `json:"releaseLogsUri,omitempty"` - ReleaseName *string `json:"releaseName,omitempty"` - Status *string `json:"status,omitempty"` - Title *string `json:"title,omitempty"` - WebAccessUri *string `json:"webAccessUri,omitempty"` -} - -type ReleaseEnvironmentShallowReference struct { - // Gets the links to related resources, APIs, and views for the release environment. - Links interface{} `json:"_links,omitempty"` - // Gets the unique identifier of release environment. - Id *int `json:"id,omitempty"` - // Gets or sets the name of the release environment. - Name *string `json:"name,omitempty"` - // Gets the REST API url to access the release environment. - Url *string `json:"url,omitempty"` -} - -type ReleaseEnvironmentStatusUpdatedEvent struct { - DefinitionId *int `json:"definitionId,omitempty"` - ProjectId *uuid.UUID `json:"projectId,omitempty"` - EnvironmentId *int `json:"environmentId,omitempty"` - EnvironmentStatus *EnvironmentStatus `json:"environmentStatus,omitempty"` - LatestDeploymentOperationStatus *DeploymentOperationStatus `json:"latestDeploymentOperationStatus,omitempty"` - LatestDeploymentStatus *DeploymentStatus `json:"latestDeploymentStatus,omitempty"` - ReleaseId *int `json:"releaseId,omitempty"` -} - -type ReleaseEnvironmentUpdateMetadata struct { - // Gets or sets comment. - Comment *string `json:"comment,omitempty"` - // Gets or sets scheduled deployment time. - ScheduledDeploymentTime *azuredevops.Time `json:"scheduledDeploymentTime,omitempty"` - // Gets or sets status of environment. - Status *EnvironmentStatus `json:"status,omitempty"` - // Sets list of environment variables to be overridden at deployment time. - Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` -} - -// [Flags] -type ReleaseExpands string - -type releaseExpandsValuesType struct { - None ReleaseExpands - Environments ReleaseExpands - Artifacts ReleaseExpands - Approvals ReleaseExpands - ManualInterventions ReleaseExpands - Variables ReleaseExpands - Tags ReleaseExpands -} - -var ReleaseExpandsValues = releaseExpandsValuesType{ - None: "none", - Environments: "environments", - Artifacts: "artifacts", - Approvals: "approvals", - ManualInterventions: "manualInterventions", - Variables: "variables", - Tags: "tags", -} - -type ReleaseGates struct { - // Contains the gates job details of each evaluation. - DeploymentJobs *[]DeploymentJob `json:"deploymentJobs,omitempty"` - // ID of release gates. - Id *int `json:"id,omitempty"` - // List of ignored gates. - IgnoredGates *[]IgnoredGate `json:"ignoredGates,omitempty"` - // Gates last modified time. - LastModifiedOn *azuredevops.Time `json:"lastModifiedOn,omitempty"` - // Run plan ID of the gates. - RunPlanId *uuid.UUID `json:"runPlanId,omitempty"` - // Gates stabilization completed date and time. - StabilizationCompletedOn *azuredevops.Time `json:"stabilizationCompletedOn,omitempty"` - // Gates evaluation started time. - StartedOn *azuredevops.Time `json:"startedOn,omitempty"` - // Status of release gates. - Status *GateStatus `json:"status,omitempty"` - // Date and time at which all gates executed successfully. - SucceedingSince *azuredevops.Time `json:"succeedingSince,omitempty"` -} - -type ReleaseGatesPhase struct { - // Deployment jobs of the phase. - DeploymentJobs *[]DeploymentJob `json:"deploymentJobs,omitempty"` - // Phase execution error logs. - ErrorLog *string `json:"errorLog,omitempty"` - // ID of the phase. - Id *int `json:"id,omitempty"` - // List of manual intervention tasks execution information in phase. - ManualInterventions *[]ManualIntervention `json:"manualInterventions,omitempty"` - // Name of the phase. - Name *string `json:"name,omitempty"` - // ID of the phase. - PhaseId *string `json:"phaseId,omitempty"` - // Type of the phase. - PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` - // Rank of the phase. - Rank *int `json:"rank,omitempty"` - // Run Plan ID of the phase. - RunPlanId *uuid.UUID `json:"runPlanId,omitempty"` - // Phase start time. - StartedOn *azuredevops.Time `json:"startedOn,omitempty"` - // Status of the phase. - Status *DeployPhaseStatus `json:"status,omitempty"` - // List of ignored gates. - IgnoredGates *[]IgnoredGate `json:"ignoredGates,omitempty"` - // Date and time at which stabilization of gates completed. - StabilizationCompletedOn *azuredevops.Time `json:"stabilizationCompletedOn,omitempty"` - // Date and time at which all gates executed successfully. - SucceedingSince *azuredevops.Time `json:"succeedingSince,omitempty"` -} - -type ReleaseManagementInputValue struct { - // The text to show for the display of this value. - DisplayValue *string `json:"displayValue,omitempty"` - // The value to store for this input. - Value *string `json:"value,omitempty"` -} - -type ReleaseNotCreatedEvent struct { - DefinitionReference *ReleaseDefinitionShallowReference `json:"definitionReference,omitempty"` - Message *string `json:"message,omitempty"` - ReleaseReason *ReleaseReason `json:"releaseReason,omitempty"` - RequestedBy *webapi.IdentityRef `json:"requestedBy,omitempty"` -} - -type ReleaseQueryOrder string - -type releaseQueryOrderValuesType struct { - Descending ReleaseQueryOrder - Ascending ReleaseQueryOrder -} - -var ReleaseQueryOrderValues = releaseQueryOrderValuesType{ - // Return results in descending order. - Descending: "descending", - // Return results in ascending order. - Ascending: "ascending", -} - -type ReleaseReason string - -type releaseReasonValuesType struct { - None ReleaseReason - Manual ReleaseReason - ContinuousIntegration ReleaseReason - Schedule ReleaseReason - PullRequest ReleaseReason -} - -var ReleaseReasonValues = releaseReasonValuesType{ - // Indicates the release triggered reason not set. - None: "none", - // Indicates the release triggered manually. - Manual: "manual", - // Indicates the release triggered by continuous integration. - ContinuousIntegration: "continuousIntegration", - // Indicates the release triggered by schedule. - Schedule: "schedule", - // Indicates the release triggered by PullRequest. - PullRequest: "pullRequest", -} - -type ReleaseReference struct { - // Gets links to access the release. - Links interface{} `json:"_links,omitempty"` - // Gets list of artifacts. - Artifacts *[]Artifact `json:"artifacts,omitempty"` - // Gets the identity who created release. - CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` - // Gets date on when this release created. - CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` - // Gets description. - Description *string `json:"description,omitempty"` - // ID of the Release. - Id *int `json:"id,omitempty"` - // Gets the identity who modified release. - ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` - // Gets name of release. - Name *string `json:"name,omitempty"` - // Gets reason for release. - Reason *ReleaseReason `json:"reason,omitempty"` - // Gets release definition shallow reference. - ReleaseDefinition *ReleaseDefinitionShallowReference `json:"releaseDefinition,omitempty"` - // Deprecated: Use Links instead - Url *string `json:"url,omitempty"` - // Deprecated: Use Links instead - WebAccessUri *string `json:"webAccessUri,omitempty"` -} - -type ReleaseRevision struct { - // Gets or sets the identity who changed. - ChangedBy *webapi.IdentityRef `json:"changedBy,omitempty"` - // Change date of the revision. - ChangedDate *azuredevops.Time `json:"changedDate,omitempty"` - // Change details of the revision. - ChangeDetails *string `json:"changeDetails,omitempty"` - // Change details of the revision. Typically ChangeDetails values are Add and Update. - ChangeType *string `json:"changeType,omitempty"` - // Comment of the revision. - Comment *string `json:"comment,omitempty"` - // Release ID of which this revision belongs. - DefinitionSnapshotRevision *int `json:"definitionSnapshotRevision,omitempty"` - // Gets or sets the release ID of which this revision belongs. - ReleaseId *int `json:"releaseId,omitempty"` -} - -type ReleaseSchedule struct { - // Days of the week to release. - DaysToRelease *ScheduleDays `json:"daysToRelease,omitempty"` - // Team Foundation Job Definition Job Id. - JobId *uuid.UUID `json:"jobId,omitempty"` - // Flag to determine if this schedule should only release if the associated artifact has been changed or release definition changed. - ScheduleOnlyWithChanges *bool `json:"scheduleOnlyWithChanges,omitempty"` - // Local time zone hour to start. - StartHours *int `json:"startHours,omitempty"` - // Local time zone minute to start. - StartMinutes *int `json:"startMinutes,omitempty"` - // Time zone Id of release schedule, such as 'UTC'. - TimeZoneId *string `json:"timeZoneId,omitempty"` -} - -type ReleaseSettings struct { - // Release Compliance settings. - ComplianceSettings *ComplianceSettings `json:"complianceSettings,omitempty"` - // Release retention settings. - RetentionSettings *RetentionSettings `json:"retentionSettings,omitempty"` -} - -type ReleaseShallowReference struct { - // Gets the links to related resources, APIs, and views for the release. - Links interface{} `json:"_links,omitempty"` - // Gets the unique identifier of release. - Id *int `json:"id,omitempty"` - // Gets or sets the name of the release. - Name *string `json:"name,omitempty"` - // Gets the REST API url to access the release. - Url *string `json:"url,omitempty"` -} - -type ReleaseStartEnvironmentMetadata struct { - // Sets release definition environment id. - DefinitionEnvironmentId *int `json:"definitionEnvironmentId,omitempty"` - // Sets list of environments variables to be overridden at deployment time. - Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` -} - -type ReleaseStartMetadata struct { - // Sets list of artifact to create a release. - Artifacts *[]ArtifactMetadata `json:"artifacts,omitempty"` - // Sets definition Id to create a release. - DefinitionId *int `json:"definitionId,omitempty"` - // Sets description to create a release. - Description *string `json:"description,omitempty"` - // Sets list of environments meta data. - EnvironmentsMetadata *[]ReleaseStartEnvironmentMetadata `json:"environmentsMetadata,omitempty"` - // Sets 'true' to create release in draft mode, 'false' otherwise. - IsDraft *bool `json:"isDraft,omitempty"` - // Sets list of environments to manual as condition. - ManualEnvironments *[]string `json:"manualEnvironments,omitempty"` - Properties interface{} `json:"properties,omitempty"` - // Sets reason to create a release. - Reason *ReleaseReason `json:"reason,omitempty"` - // Sets list of release variables to be overridden at deployment time. - Variables *map[string]ConfigurationVariableValue `json:"variables,omitempty"` -} - -// [Flags] -type ReleaseStatus string - -type releaseStatusValuesType struct { - Undefined ReleaseStatus - Draft ReleaseStatus - Active ReleaseStatus - Abandoned ReleaseStatus -} - -var ReleaseStatusValues = releaseStatusValuesType{ - // Release status not set. - Undefined: "undefined", - // Release is in draft state. - Draft: "draft", - // Release status is in active. - Active: "active", - // Release status is in abandoned. - Abandoned: "abandoned", -} - -type ReleaseTask struct { - // Agent name on which task executed. - AgentName *string `json:"agentName,omitempty"` - // Deprecated: Use FinishTime instead - DateEnded *azuredevops.Time `json:"dateEnded,omitempty"` - // Deprecated: Use StartTime instead. - DateStarted *azuredevops.Time `json:"dateStarted,omitempty"` - // Finish time of the release task. - FinishTime *azuredevops.Time `json:"finishTime,omitempty"` - // ID of the release task. - Id *int `json:"id,omitempty"` - // List of issues occurred while execution of task. - Issues *[]Issue `json:"issues,omitempty"` - // Number of lines log release task has. - LineCount *uint64 `json:"lineCount,omitempty"` - // Log URL of the task. - LogUrl *string `json:"logUrl,omitempty"` - // Name of the task. - Name *string `json:"name,omitempty"` - // Task execution complete precent. - PercentComplete *int `json:"percentComplete,omitempty"` - // Rank of the release task. - Rank *int `json:"rank,omitempty"` - // Result code of the task. - ResultCode *string `json:"resultCode,omitempty"` - // ID of the release task. - StartTime *azuredevops.Time `json:"startTime,omitempty"` - // Status of release task. - Status *TaskStatus `json:"status,omitempty"` - // Workflow task reference. - Task *WorkflowTaskReference `json:"task,omitempty"` - // Timeline record ID of the release task. - TimelineRecordId *uuid.UUID `json:"timelineRecordId,omitempty"` -} - -type ReleaseTaskAttachment struct { - // Reference links of task. - Links interface{} `json:"_links,omitempty"` - // Data and time when it created. - CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` - // Identity who modified. - ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` - // Data and time when modified. - ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` - // Name of the task attachment. - Name *string `json:"name,omitempty"` - // Record ID of the task. - RecordId *uuid.UUID `json:"recordId,omitempty"` - // Timeline ID of the task. - TimelineId *uuid.UUID `json:"timelineId,omitempty"` - // Type of task attachment. - Type *string `json:"type,omitempty"` -} - -type ReleaseTaskLogUpdatedEvent struct { - EnvironmentId *int `json:"environmentId,omitempty"` - ProjectId *uuid.UUID `json:"projectId,omitempty"` - ReleaseId *int `json:"releaseId,omitempty"` - Lines *[]string `json:"lines,omitempty"` - StepRecordId *uuid.UUID `json:"stepRecordId,omitempty"` - TimelineRecordId *uuid.UUID `json:"timelineRecordId,omitempty"` -} - -type ReleaseTasksUpdatedEvent struct { - EnvironmentId *int `json:"environmentId,omitempty"` - ProjectId *uuid.UUID `json:"projectId,omitempty"` - ReleaseId *int `json:"releaseId,omitempty"` - Job *ReleaseTask `json:"job,omitempty"` - PlanId *uuid.UUID `json:"planId,omitempty"` - // Deprecated: - ReleaseDeployPhaseId *int `json:"releaseDeployPhaseId,omitempty"` - ReleaseStepId *int `json:"releaseStepId,omitempty"` - Tasks *[]ReleaseTask `json:"tasks,omitempty"` -} - -type ReleaseTriggerBase struct { - // Type of release trigger. - TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` -} - -type ReleaseTriggerType string - -type releaseTriggerTypeValuesType struct { - Undefined ReleaseTriggerType - ArtifactSource ReleaseTriggerType - Schedule ReleaseTriggerType - SourceRepo ReleaseTriggerType - ContainerImage ReleaseTriggerType - Package ReleaseTriggerType - PullRequest ReleaseTriggerType -} - -var ReleaseTriggerTypeValues = releaseTriggerTypeValuesType{ - // Release trigger type not set. - Undefined: "undefined", - // Artifact based release trigger. - ArtifactSource: "artifactSource", - // Schedule based release trigger. - Schedule: "schedule", - // Source repository based release trigger. - SourceRepo: "sourceRepo", - // Container image based release trigger. - ContainerImage: "containerImage", - // Package based release trigger. - Package: "package", - // Pull request based release trigger. - PullRequest: "pullRequest", -} - -type ReleaseUpdatedEvent struct { - EnvironmentId *int `json:"environmentId,omitempty"` - ProjectId *uuid.UUID `json:"projectId,omitempty"` - ReleaseId *int `json:"releaseId,omitempty"` - Release *Release `json:"release,omitempty"` -} - -type ReleaseUpdateMetadata struct { - // Sets comment for release. - Comment *string `json:"comment,omitempty"` - // Set 'true' to exclude the release from retention policies. - KeepForever *bool `json:"keepForever,omitempty"` - // Sets list of manual environments. - ManualEnvironments *[]string `json:"manualEnvironments,omitempty"` - // Sets name of the release. - Name *string `json:"name,omitempty"` - // Sets status of the release. - Status *ReleaseStatus `json:"status,omitempty"` -} - -type ReleaseWorkItemRef struct { - // Deprecated: - Assignee *string `json:"assignee,omitempty"` - // Gets or sets the ID. - Id *string `json:"id,omitempty"` - // Gets or sets the state. - State *string `json:"state,omitempty"` - // Gets or sets the title. - Title *string `json:"title,omitempty"` - // Gets or sets the type. - Type *string `json:"type,omitempty"` - // Gets or sets the workitem url. - Url *string `json:"url,omitempty"` -} - -type RetentionPolicy struct { - // Indicates the number of days to keep deployment. - DaysToKeep *int `json:"daysToKeep,omitempty"` -} - -type RetentionSettings struct { - // Number of days to keep deleted releases. - DaysToKeepDeletedReleases *int `json:"daysToKeepDeletedReleases,omitempty"` - // Specifies the default environment retention policy. - DefaultEnvironmentRetentionPolicy *EnvironmentRetentionPolicy `json:"defaultEnvironmentRetentionPolicy,omitempty"` - // Specifies the maximum environment retention policy. - MaximumEnvironmentRetentionPolicy *EnvironmentRetentionPolicy `json:"maximumEnvironmentRetentionPolicy,omitempty"` -} - -type RunOnServerDeployPhase struct { - // Gets and sets the name of deploy phase. - Name *string `json:"name,omitempty"` - // Indicates the deploy phase type. - PhaseType *DeployPhaseTypes `json:"phaseType,omitempty"` - // Gets and sets the rank of deploy phase. - Rank *int `json:"rank,omitempty"` - // Gets and sets the reference name of deploy phase. - RefName *string `json:"refName,omitempty"` - // Gets and sets the workflow tasks for the deploy phase. - WorkflowTasks *[]WorkflowTask `json:"workflowTasks,omitempty"` - // Gets and sets the agentless job input. - DeploymentInput *ServerDeploymentInput `json:"deploymentInput,omitempty"` -} - -type ScheduleDays string - -type scheduleDaysValuesType struct { - None ScheduleDays - Monday ScheduleDays - Tuesday ScheduleDays - Wednesday ScheduleDays - Thursday ScheduleDays - Friday ScheduleDays - Saturday ScheduleDays - Sunday ScheduleDays - All ScheduleDays -} - -var ScheduleDaysValues = scheduleDaysValuesType{ - // Scheduled day not set. - None: "none", - // Scheduled on Monday. - Monday: "monday", - // Scheduled on Tuesday. - Tuesday: "tuesday", - // Scheduled on Wednesday. - Wednesday: "wednesday", - // Scheduled on Thursday. - Thursday: "thursday", - // Scheduled on Friday. - Friday: "friday", - // Scheduled on Saturday. - Saturday: "saturday", - // Scheduled on Sunday. - Sunday: "sunday", - // Scheduled on all the days in week. - All: "all", -} - -type ScheduledReleaseTrigger struct { - // Type of release trigger. - TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` - // Release schedule for Scheduled Release trigger type. - Schedule *ReleaseSchedule `json:"schedule,omitempty"` -} - -type SenderType string - -type senderTypeValuesType struct { - ServiceAccount SenderType - RequestingUser SenderType -} - -var SenderTypeValues = senderTypeValuesType{ - ServiceAccount: "serviceAccount", - RequestingUser: "requestingUser", -} - -type ServerDeploymentInput struct { - // Gets or sets the job condition. - Condition *string `json:"condition,omitempty"` - // Gets or sets the job cancel timeout in minutes for deployment which are cancelled by user for this release environment. - JobCancelTimeoutInMinutes *int `json:"jobCancelTimeoutInMinutes,omitempty"` - // Gets or sets the override inputs. - OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` - // Gets or sets the job execution timeout in minutes for deployment which are queued against this release environment. - TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` - // Gets or sets the parallel execution input. - ParallelExecution *ExecutionInput `json:"parallelExecution,omitempty"` -} - -// [Flags] -type SingleReleaseExpands string - -type singleReleaseExpandsValuesType struct { - None SingleReleaseExpands - Tasks SingleReleaseExpands -} - -var SingleReleaseExpandsValues = singleReleaseExpandsValuesType{ - // Return top level properties of object. - None: "none", - // Expand release with tasks. - Tasks: "tasks", -} - -type SourceIdInput struct { - // ID of source. - Id *string `json:"id,omitempty"` - // Name of the source. - Name *string `json:"name,omitempty"` -} - -type SourcePullRequestVersion struct { - // Pull Request Iteration Id for which the release will publish status. - IterationId *string `json:"iterationId,omitempty"` - // Pull Request Id for which the release will publish status. - PullRequestId *string `json:"pullRequestId,omitempty"` - // Date and time of the pull request merge creation. It is required to keep timeline record of Releases created by pull request. - PullRequestMergedAt *azuredevops.Time `json:"pullRequestMergedAt,omitempty"` - // Source branch of the Pull Request. - SourceBranch *string `json:"sourceBranch,omitempty"` - // Source branch commit Id of the Pull Request for which the release will publish status. - SourceBranchCommitId *string `json:"sourceBranchCommitId,omitempty"` - // Target branch of the Pull Request. - TargetBranch *string `json:"targetBranch,omitempty"` -} - -type SourceRepoTrigger struct { - // Type of release trigger. - TriggerType *ReleaseTriggerType `json:"triggerType,omitempty"` - // Alias of the source repo trigger. - Alias *string `json:"alias,omitempty"` - BranchFilters *[]string `json:"branchFilters,omitempty"` -} - -type SummaryMailSection struct { - // Html content of summary mail. - HtmlContent *string `json:"htmlContent,omitempty"` - // Rank of the summary mail. - Rank *int `json:"rank,omitempty"` - // Summary mail section type. MailSectionType has section types. - SectionType *MailSectionType `json:"sectionType,omitempty"` - // Title of the summary mail. - Title *string `json:"title,omitempty"` -} - -type TagFilter struct { - // Gets or sets the tag filter pattern. - Pattern *string `json:"pattern,omitempty"` -} - -type TaskOrchestrationPlanGroupReference struct { - // Gets or sets the plan group. - PlanGroup *string `json:"planGroup,omitempty"` - // ID of the Project. - ProjectId *uuid.UUID `json:"projectId,omitempty"` -} - -type TaskOrchestrationPlanGroupsStartedEvent struct { - PlanGroups *[]TaskOrchestrationPlanGroupReference `json:"planGroups,omitempty"` -} - -type TaskStatus string - -type taskStatusValuesType struct { - Unknown TaskStatus - Pending TaskStatus - InProgress TaskStatus - Success TaskStatus - Failure TaskStatus - Canceled TaskStatus - Skipped TaskStatus - Succeeded TaskStatus - Failed TaskStatus - PartiallySucceeded TaskStatus -} - -var TaskStatusValues = taskStatusValuesType{ - // The task does not have the status set. - Unknown: "unknown", - // The task is in pending status. - Pending: "pending", - // The task is currently in progress. - InProgress: "inProgress", - // The task completed successfully. - Success: "success", - // The task execution failed. - Failure: "failure", - // The task execution canceled. - Canceled: "canceled", - // The task execution skipped. - Skipped: "skipped", - // The task completed successfully. - Succeeded: "succeeded", - // The task execution failed. - Failed: "failed", - // The task execution partially succeeded. - PartiallySucceeded: "partiallySucceeded", -} - -type TfvcArtifactDownloadInput struct { - // Gets or sets the alias of artifact. - Alias *string `json:"alias,omitempty"` - // Gets or sets the name of artifact definition. Valid values are 'Skip', 'Selective', 'All'. - ArtifactDownloadMode *string `json:"artifactDownloadMode,omitempty"` - // Gets or sets the artifact items of the input. - ArtifactItems *[]string `json:"artifactItems,omitempty"` - // Gets or sets the type of artifact. - ArtifactType *string `json:"artifactType,omitempty"` -} - -type TimeZone struct { - // Display name of the time zone. - DisplayName *string `json:"displayName,omitempty"` - // Id of the time zone. - Id *string `json:"id,omitempty"` -} - -type TimeZoneList struct { - // UTC timezone. - UtcTimeZone *TimeZone `json:"utcTimeZone,omitempty"` - // List of valid timezones. - ValidTimeZones *[]TimeZone `json:"validTimeZones,omitempty"` -} - -type VariableGroup struct { - // Gets or sets the identity who created. - CreatedBy *webapi.IdentityRef `json:"createdBy,omitempty"` - // Gets date on which it got created. - CreatedOn *azuredevops.Time `json:"createdOn,omitempty"` - // Gets or sets description. - Description *string `json:"description,omitempty"` - // Gets the unique identifier of this field. - Id *int `json:"id,omitempty"` - // Denotes if a variable group is shared with other project or not. - IsShared *bool `json:"isShared,omitempty"` - // Gets or sets the identity who modified. - ModifiedBy *webapi.IdentityRef `json:"modifiedBy,omitempty"` - // Gets date on which it got modified. - ModifiedOn *azuredevops.Time `json:"modifiedOn,omitempty"` - // Gets or sets name. - Name *string `json:"name,omitempty"` - // Gets or sets provider data. - ProviderData interface{} `json:"providerData,omitempty"` - // Gets or sets type. - Type *string `json:"type,omitempty"` - // Gets and sets the dictionary of variables. - Variables *map[string]interface{} `json:"variables,omitempty"` -} - -// [Flags] -type VariableGroupActionFilter string - -type variableGroupActionFilterValuesType struct { - None VariableGroupActionFilter - Manage VariableGroupActionFilter - Use VariableGroupActionFilter -} - -var VariableGroupActionFilterValues = variableGroupActionFilterValuesType{ - None: "none", - Manage: "manage", - Use: "use", -} - -type VariableGroupProviderData struct { -} - -type VariableValue struct { - // Gets or sets as the variable is secret or not. - IsSecret *bool `json:"isSecret,omitempty"` - // Gets or sets the value. - Value *string `json:"value,omitempty"` -} - -type WorkflowTask struct { - // Gets or sets as the task always run or not. - AlwaysRun *bool `json:"alwaysRun,omitempty"` - // Gets or sets the task condition. - Condition *string `json:"condition,omitempty"` - // Gets or sets as the task continue run on error or not. - ContinueOnError *bool `json:"continueOnError,omitempty"` - // Gets or sets the task definition type. Example:- 'Agent', DeploymentGroup', 'Server' or 'ServerGate'. - DefinitionType *string `json:"definitionType,omitempty"` - // Gets or sets as the task enabled or not. - Enabled *bool `json:"enabled,omitempty"` - // Gets or sets the task environment variables. - Environment *map[string]string `json:"environment,omitempty"` - // Gets or sets the task inputs. - Inputs *map[string]string `json:"inputs,omitempty"` - // Gets or sets the name of the task. - Name *string `json:"name,omitempty"` - // Gets or sets the task override inputs. - OverrideInputs *map[string]string `json:"overrideInputs,omitempty"` - // Gets or sets the reference name of the task. - RefName *string `json:"refName,omitempty"` - // Gets or sets the ID of the task. - TaskId *uuid.UUID `json:"taskId,omitempty"` - // Gets or sets the task timeout. - TimeoutInMinutes *int `json:"timeoutInMinutes,omitempty"` - // Gets or sets the version of the task. - Version *string `json:"version,omitempty"` -} - -type WorkflowTaskReference struct { - // Task identifier. - Id *uuid.UUID `json:"id,omitempty"` - // Name of the task. - Name *string `json:"name,omitempty"` - // Version of the task. - Version *string `json:"version,omitempty"` -} - -// [Flags] -type YamlFileSourceTypes string - -type yamlFileSourceTypesValuesType struct { - None YamlFileSourceTypes - TfsGit YamlFileSourceTypes -} - -var YamlFileSourceTypesValues = yamlFileSourceTypesValuesType{ - None: "none", - TfsGit: "tfsGit", -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 39daf9502..6ed7eeff3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -166,7 +166,6 @@ github.com/microsoft/azure-devops-go-api/azuredevops/forminput github.com/microsoft/azure-devops-go-api/azuredevops/graph github.com/microsoft/azure-devops-go-api/azuredevops/identity github.com/microsoft/azure-devops-go-api/azuredevops/profile -github.com/microsoft/azure-devops-go-api/azuredevops/release github.com/microsoft/azure-devops-go-api/azuredevops/system github.com/microsoft/azure-devops-go-api/azuredevops/taskagent github.com/microsoft/azure-devops-go-api/azuredevops/webapi