diff --git a/sdk/containerregistry/armcontainerregistry/CHANGELOG.md b/sdk/containerregistry/armcontainerregistry/CHANGELOG.md new file mode 100644 index 000000000000..c7196df9ed8b --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## v0.1.0 (released) diff --git a/sdk/containerregistry/armcontainerregistry/README.md b/sdk/containerregistry/armcontainerregistry/README.md new file mode 100644 index 000000000000..b2eadff34932 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/README.md @@ -0,0 +1,76 @@ +# Azure Container Registry Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/containerregistry/armcontainerregistry)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/containerregistry/armcontainerregistry) + +The `armcontainerregistry` module provides operations for working with Azure Container Registry. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/containerregistry/armcontainerregistry) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Container Registry module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/containerregistry/armcontainerregistry +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Container Registry. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Connecting to Azure Containerregistry + +Once you have a credential, create a connection to the desired ARM endpoint. The `armcore` module provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack. + +```go +con := armcore.NewDefaultConnection(cred, nil) +``` + +For more information on ARM connections, please see the documentation for `armcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore). + +## Clients + +Azure Container Registry modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your `armcore.Connection`. + +```go +client := armcontainerregistry.NewRegistriesClient(con, "") +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `containerregistry` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. diff --git a/sdk/containerregistry/armcontainerregistry/_meta.json b/sdk/containerregistry/armcontainerregistry/_meta.json new file mode 100644 index 000000000000..4d5598bca2db --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "036c2de2b40ad05a1542b665a9e8bda18c813194", + "readme": "/_/azure-rest-api-specs/specification/containerregistry/resource-manager/readme.md", + "tag": "package-2021-06-preview", + "use": "@autorest/go@4.0.0-preview.22", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@autorest/go@4.0.0-preview.22 --version:3.1.5 --go --track2 --go-sdk-folder=/_/azure-sdk-for-go --file-prefix=\"zz_generated_\" --clear-output-folder=false /_/azure-rest-api-specs/specification/containerregistry/resource-manager/readme.md", + "additional_properties": { + "additional_options": " --version:3.1.5 --go --track2 --file-prefix=\"zz_generated_\" --clear-output-folder=false" + } + } \ No newline at end of file diff --git a/sdk/containerregistry/armcontainerregistry/go.mod b/sdk/containerregistry/armcontainerregistry/go.mod new file mode 100644 index 000000000000..7455389a7364 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/go.mod @@ -0,0 +1,10 @@ +module github.com/Azure/azure-sdk-for-go/sdk/containerregistry/armcontainerregistry + +go 1.13 + +require ( + github.com/Azure/azure-sdk-for-go v55.5.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 + golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect +) diff --git a/sdk/containerregistry/armcontainerregistry/go.sum b/sdk/containerregistry/armcontainerregistry/go.sum new file mode 100644 index 000000000000..135e5a010466 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/go.sum @@ -0,0 +1,21 @@ +github.com/Azure/azure-sdk-for-go v55.5.0+incompatible h1:GToUAq2Qdrh6g2ITPXx95zQ2DGMFSIatf9QwFplUTmk= +github.com/Azure/azure-sdk-for-go v55.5.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0 h1:HQQoaSGOh32mpoRkpLDjkngMwYJqkxu93FRx0epdLHE= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0/go.mod h1:BSKvHb/5cy8j4hahIInXH92X/2zGJ3TxKF6b9pw1Btg= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 h1:UC4vfOhW2l0f2QOCQpOxJS4/K6oKFy2tQZE+uWU1MEo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2/go.mod h1:MVdrcUC4Hup35qHym3VdzoW+NBgBxrta9Vei97jRtM8= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1 h1:vx8McI56N5oLSQu8xa+xdiE0fjQq8W8Zt49vHP8Rygw= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1/go.mod h1:k4KbFSunV/+0hOHL1vyFaPsiYQ1Vmvy1TBpmtvCDLZM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/sdk/containerregistry/armcontainerregistry/go_mod_tidy_hack.go b/sdk/containerregistry/armcontainerregistry/go_mod_tidy_hack.go new file mode 100644 index 000000000000..a1deffee6df2 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/go_mod_tidy_hack.go @@ -0,0 +1,12 @@ +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armcontainerregistry + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_agentpools_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_agentpools_client.go new file mode 100644 index 000000000000..d4bcbe079110 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_agentpools_client.go @@ -0,0 +1,565 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// AgentPoolsClient contains the methods for the AgentPools group. +// Don't use this type directly, use NewAgentPoolsClient() instead. +type AgentPoolsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAgentPoolsClient creates a new instance of AgentPoolsClient with the specified values. +func NewAgentPoolsClient(con *armcore.Connection, subscriptionID string) *AgentPoolsClient { + return &AgentPoolsClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Creates an agent pool for a container registry with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AgentPoolsClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, agentPool AgentPool, options *AgentPoolsBeginCreateOptions) (AgentPoolPollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, registryName, agentPoolName, agentPool, options) + if err != nil { + return AgentPoolPollerResponse{}, err + } + result := AgentPoolPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("AgentPoolsClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return AgentPoolPollerResponse{}, err + } + poller := &agentPoolPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (AgentPoolResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new AgentPoolPoller from the specified resume token. +// token - The value must come from a previous call to AgentPoolPoller.ResumeToken(). +func (client *AgentPoolsClient) ResumeCreate(ctx context.Context, token string) (AgentPoolPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("AgentPoolsClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return AgentPoolPollerResponse{}, err + } + poller := &agentPoolPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return AgentPoolPollerResponse{}, err + } + result := AgentPoolPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (AgentPoolResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates an agent pool for a container registry with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AgentPoolsClient) create(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, agentPool AgentPool, options *AgentPoolsBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, agentPoolName, agentPool, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *AgentPoolsClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, agentPool AgentPool, options *AgentPoolsBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if agentPoolName == "" { + return nil, errors.New("parameter agentPoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{agentPoolName}", url.PathEscape(agentPoolName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(agentPool) +} + +// createHandleError handles the Create error response. +func (client *AgentPoolsClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginDelete - Deletes a specified agent pool resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AgentPoolsClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, agentPoolName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("AgentPoolsClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *AgentPoolsClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("AgentPoolsClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a specified agent pool resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AgentPoolsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, agentPoolName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AgentPoolsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if agentPoolName == "" { + return nil, errors.New("parameter agentPoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{agentPoolName}", url.PathEscape(agentPoolName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *AgentPoolsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the detailed information for a given agent pool. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AgentPoolsClient) Get(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsGetOptions) (AgentPoolResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, agentPoolName, options) + if err != nil { + return AgentPoolResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AgentPoolResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return AgentPoolResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AgentPoolsClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if agentPoolName == "" { + return nil, errors.New("parameter agentPoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{agentPoolName}", url.PathEscape(agentPoolName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AgentPoolsClient) getHandleResponse(resp *azcore.Response) (AgentPoolResponse, error) { + var val *AgentPool + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AgentPoolResponse{}, err + } + return AgentPoolResponse{RawResponse: resp.Response, AgentPool: val}, nil +} + +// getHandleError handles the Get error response. +func (client *AgentPoolsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetQueueStatus - Gets the count of queued runs for a given agent pool. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AgentPoolsClient) GetQueueStatus(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsGetQueueStatusOptions) (AgentPoolQueueStatusResponse, error) { + req, err := client.getQueueStatusCreateRequest(ctx, resourceGroupName, registryName, agentPoolName, options) + if err != nil { + return AgentPoolQueueStatusResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AgentPoolQueueStatusResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return AgentPoolQueueStatusResponse{}, client.getQueueStatusHandleError(resp) + } + return client.getQueueStatusHandleResponse(resp) +} + +// getQueueStatusCreateRequest creates the GetQueueStatus request. +func (client *AgentPoolsClient) getQueueStatusCreateRequest(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsGetQueueStatusOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}/listQueueStatus" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if agentPoolName == "" { + return nil, errors.New("parameter agentPoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{agentPoolName}", url.PathEscape(agentPoolName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getQueueStatusHandleResponse handles the GetQueueStatus response. +func (client *AgentPoolsClient) getQueueStatusHandleResponse(resp *azcore.Response) (AgentPoolQueueStatusResponse, error) { + var val *AgentPoolQueueStatus + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AgentPoolQueueStatusResponse{}, err + } + return AgentPoolQueueStatusResponse{RawResponse: resp.Response, AgentPoolQueueStatus: val}, nil +} + +// getQueueStatusHandleError handles the GetQueueStatus error response. +func (client *AgentPoolsClient) getQueueStatusHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Lists all the agent pools for a specified container registry. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AgentPoolsClient) List(resourceGroupName string, registryName string, options *AgentPoolsListOptions) AgentPoolListResultPager { + return &agentPoolListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp AgentPoolListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.AgentPoolListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *AgentPoolsClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *AgentPoolsListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *AgentPoolsClient) listHandleResponse(resp *azcore.Response) (AgentPoolListResultResponse, error) { + var val *AgentPoolListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return AgentPoolListResultResponse{}, err + } + return AgentPoolListResultResponse{RawResponse: resp.Response, AgentPoolListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *AgentPoolsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginUpdate - Updates an agent pool with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AgentPoolsClient) BeginUpdate(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, updateParameters AgentPoolUpdateParameters, options *AgentPoolsBeginUpdateOptions) (AgentPoolPollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, registryName, agentPoolName, updateParameters, options) + if err != nil { + return AgentPoolPollerResponse{}, err + } + result := AgentPoolPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("AgentPoolsClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return AgentPoolPollerResponse{}, err + } + poller := &agentPoolPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (AgentPoolResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new AgentPoolPoller from the specified resume token. +// token - The value must come from a previous call to AgentPoolPoller.ResumeToken(). +func (client *AgentPoolsClient) ResumeUpdate(ctx context.Context, token string) (AgentPoolPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("AgentPoolsClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return AgentPoolPollerResponse{}, err + } + poller := &agentPoolPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return AgentPoolPollerResponse{}, err + } + result := AgentPoolPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (AgentPoolResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates an agent pool with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AgentPoolsClient) update(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, updateParameters AgentPoolUpdateParameters, options *AgentPoolsBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, agentPoolName, updateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *AgentPoolsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, updateParameters AgentPoolUpdateParameters, options *AgentPoolsBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/agentPools/{agentPoolName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if agentPoolName == "" { + return nil, errors.New("parameter agentPoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{agentPoolName}", url.PathEscape(agentPoolName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(updateParameters) +} + +// updateHandleError handles the Update error response. +func (client *AgentPoolsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_connectedregistries_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_connectedregistries_client.go new file mode 100644 index 000000000000..ec1695f0a52d --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_connectedregistries_client.go @@ -0,0 +1,607 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// ConnectedRegistriesClient contains the methods for the ConnectedRegistries group. +// Don't use this type directly, use NewConnectedRegistriesClient() instead. +type ConnectedRegistriesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewConnectedRegistriesClient creates a new instance of ConnectedRegistriesClient with the specified values. +func NewConnectedRegistriesClient(con *armcore.Connection, subscriptionID string) *ConnectedRegistriesClient { + return &ConnectedRegistriesClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Creates a connected registry for a container registry with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedRegistriesClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, connectedRegistryCreateParameters ConnectedRegistry, options *ConnectedRegistriesBeginCreateOptions) (ConnectedRegistryPollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, registryName, connectedRegistryName, connectedRegistryCreateParameters, options) + if err != nil { + return ConnectedRegistryPollerResponse{}, err + } + result := ConnectedRegistryPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ConnectedRegistriesClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return ConnectedRegistryPollerResponse{}, err + } + poller := &connectedRegistryPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ConnectedRegistryResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new ConnectedRegistryPoller from the specified resume token. +// token - The value must come from a previous call to ConnectedRegistryPoller.ResumeToken(). +func (client *ConnectedRegistriesClient) ResumeCreate(ctx context.Context, token string) (ConnectedRegistryPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ConnectedRegistriesClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return ConnectedRegistryPollerResponse{}, err + } + poller := &connectedRegistryPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ConnectedRegistryPollerResponse{}, err + } + result := ConnectedRegistryPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ConnectedRegistryResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates a connected registry for a container registry with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedRegistriesClient) create(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, connectedRegistryCreateParameters ConnectedRegistry, options *ConnectedRegistriesBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, connectedRegistryName, connectedRegistryCreateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *ConnectedRegistriesClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, connectedRegistryCreateParameters ConnectedRegistry, options *ConnectedRegistriesBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if connectedRegistryName == "" { + return nil, errors.New("parameter connectedRegistryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectedRegistryName}", url.PathEscape(connectedRegistryName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(connectedRegistryCreateParameters) +} + +// createHandleError handles the Create error response. +func (client *ConnectedRegistriesClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginDeactivate - Deactivates the connected registry instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedRegistriesClient) BeginDeactivate(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *ConnectedRegistriesBeginDeactivateOptions) (HTTPPollerResponse, error) { + resp, err := client.deactivate(ctx, resourceGroupName, registryName, connectedRegistryName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ConnectedRegistriesClient.Deactivate", "", resp, client.con.Pipeline(), client.deactivateHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDeactivate creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *ConnectedRegistriesClient) ResumeDeactivate(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ConnectedRegistriesClient.Deactivate", token, client.con.Pipeline(), client.deactivateHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Deactivate - Deactivates the connected registry instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedRegistriesClient) deactivate(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *ConnectedRegistriesBeginDeactivateOptions) (*azcore.Response, error) { + req, err := client.deactivateCreateRequest(ctx, resourceGroupName, registryName, connectedRegistryName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.deactivateHandleError(resp) + } + return resp, nil +} + +// deactivateCreateRequest creates the Deactivate request. +func (client *ConnectedRegistriesClient) deactivateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *ConnectedRegistriesBeginDeactivateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}/deactivate" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if connectedRegistryName == "" { + return nil, errors.New("parameter connectedRegistryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectedRegistryName}", url.PathEscape(connectedRegistryName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deactivateHandleError handles the Deactivate error response. +func (client *ConnectedRegistriesClient) deactivateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginDelete - Deletes a connected registry from a container registry. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedRegistriesClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *ConnectedRegistriesBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, connectedRegistryName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ConnectedRegistriesClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *ConnectedRegistriesClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ConnectedRegistriesClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a connected registry from a container registry. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedRegistriesClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *ConnectedRegistriesBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, connectedRegistryName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ConnectedRegistriesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *ConnectedRegistriesBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if connectedRegistryName == "" { + return nil, errors.New("parameter connectedRegistryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectedRegistryName}", url.PathEscape(connectedRegistryName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ConnectedRegistriesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the properties of the connected registry. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedRegistriesClient) Get(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *ConnectedRegistriesGetOptions) (ConnectedRegistryResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, connectedRegistryName, options) + if err != nil { + return ConnectedRegistryResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ConnectedRegistryResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ConnectedRegistryResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ConnectedRegistriesClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, options *ConnectedRegistriesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if connectedRegistryName == "" { + return nil, errors.New("parameter connectedRegistryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectedRegistryName}", url.PathEscape(connectedRegistryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ConnectedRegistriesClient) getHandleResponse(resp *azcore.Response) (ConnectedRegistryResponse, error) { + var val *ConnectedRegistry + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ConnectedRegistryResponse{}, err + } + return ConnectedRegistryResponse{RawResponse: resp.Response, ConnectedRegistry: val}, nil +} + +// getHandleError handles the Get error response. +func (client *ConnectedRegistriesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Lists all connected registries for the specified container registry. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedRegistriesClient) List(resourceGroupName string, registryName string, options *ConnectedRegistriesListOptions) ConnectedRegistryListResultPager { + return &connectedRegistryListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp ConnectedRegistryListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ConnectedRegistryListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *ConnectedRegistriesClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *ConnectedRegistriesListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ConnectedRegistriesClient) listHandleResponse(resp *azcore.Response) (ConnectedRegistryListResultResponse, error) { + var val *ConnectedRegistryListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ConnectedRegistryListResultResponse{}, err + } + return ConnectedRegistryListResultResponse{RawResponse: resp.Response, ConnectedRegistryListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *ConnectedRegistriesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginUpdate - Updates a connected registry with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedRegistriesClient) BeginUpdate(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, connectedRegistryUpdateParameters ConnectedRegistryUpdateParameters, options *ConnectedRegistriesBeginUpdateOptions) (ConnectedRegistryPollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, registryName, connectedRegistryName, connectedRegistryUpdateParameters, options) + if err != nil { + return ConnectedRegistryPollerResponse{}, err + } + result := ConnectedRegistryPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ConnectedRegistriesClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return ConnectedRegistryPollerResponse{}, err + } + poller := &connectedRegistryPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ConnectedRegistryResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new ConnectedRegistryPoller from the specified resume token. +// token - The value must come from a previous call to ConnectedRegistryPoller.ResumeToken(). +func (client *ConnectedRegistriesClient) ResumeUpdate(ctx context.Context, token string) (ConnectedRegistryPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ConnectedRegistriesClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return ConnectedRegistryPollerResponse{}, err + } + poller := &connectedRegistryPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ConnectedRegistryPollerResponse{}, err + } + result := ConnectedRegistryPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ConnectedRegistryResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates a connected registry with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ConnectedRegistriesClient) update(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, connectedRegistryUpdateParameters ConnectedRegistryUpdateParameters, options *ConnectedRegistriesBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, connectedRegistryName, connectedRegistryUpdateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ConnectedRegistriesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, connectedRegistryName string, connectedRegistryUpdateParameters ConnectedRegistryUpdateParameters, options *ConnectedRegistriesBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/connectedRegistries/{connectedRegistryName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if connectedRegistryName == "" { + return nil, errors.New("parameter connectedRegistryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectedRegistryName}", url.PathEscape(connectedRegistryName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(connectedRegistryUpdateParameters) +} + +// updateHandleError handles the Update error response. +func (client *ConnectedRegistriesClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_constants.go b/sdk/containerregistry/armcontainerregistry/zz_generated_constants.go new file mode 100644 index 000000000000..d0318f67ef3f --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_constants.go @@ -0,0 +1,1167 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +const telemetryInfo = "azsdk-go-armcontainerregistry/v0.1.0" + +// Action - The action of virtual network rule. +type Action string + +const ( + ActionAllow Action = "Allow" +) + +// PossibleActionValues returns the possible values for the Action const type. +func PossibleActionValues() []Action { + return []Action{ + ActionAllow, + } +} + +// ToPtr returns a *Action pointing to the current value. +func (c Action) ToPtr() *Action { + return &c +} + +// ActionsRequired - A message indicating if changes on the service provider require any updates on the consumer. +type ActionsRequired string + +const ( + ActionsRequiredNone ActionsRequired = "None" + ActionsRequiredRecreate ActionsRequired = "Recreate" +) + +// PossibleActionsRequiredValues returns the possible values for the ActionsRequired const type. +func PossibleActionsRequiredValues() []ActionsRequired { + return []ActionsRequired{ + ActionsRequiredNone, + ActionsRequiredRecreate, + } +} + +// ToPtr returns a *ActionsRequired pointing to the current value. +func (c ActionsRequired) ToPtr() *ActionsRequired { + return &c +} + +// ActivationStatus - The activation status of the connected registry. +type ActivationStatus string + +const ( + ActivationStatusActive ActivationStatus = "Active" + ActivationStatusInactive ActivationStatus = "Inactive" +) + +// PossibleActivationStatusValues returns the possible values for the ActivationStatus const type. +func PossibleActivationStatusValues() []ActivationStatus { + return []ActivationStatus{ + ActivationStatusActive, + ActivationStatusInactive, + } +} + +// ToPtr returns a *ActivationStatus pointing to the current value. +func (c ActivationStatus) ToPtr() *ActivationStatus { + return &c +} + +// Architecture - The OS architecture. +type Architecture string + +const ( + ArchitectureAmd64 Architecture = "amd64" + ArchitectureArm Architecture = "arm" + ArchitectureArm64 Architecture = "arm64" + ArchitectureThreeHundredEightySix Architecture = "386" + ArchitectureX86 Architecture = "x86" +) + +// PossibleArchitectureValues returns the possible values for the Architecture const type. +func PossibleArchitectureValues() []Architecture { + return []Architecture{ + ArchitectureAmd64, + ArchitectureArm, + ArchitectureArm64, + ArchitectureThreeHundredEightySix, + ArchitectureX86, + } +} + +// ToPtr returns a *Architecture pointing to the current value. +func (c Architecture) ToPtr() *Architecture { + return &c +} + +// AuditLogStatus - Indicates whether audit logs are enabled on the connected registry. +type AuditLogStatus string + +const ( + AuditLogStatusDisabled AuditLogStatus = "Disabled" + AuditLogStatusEnabled AuditLogStatus = "Enabled" +) + +// PossibleAuditLogStatusValues returns the possible values for the AuditLogStatus const type. +func PossibleAuditLogStatusValues() []AuditLogStatus { + return []AuditLogStatus{ + AuditLogStatusDisabled, + AuditLogStatusEnabled, + } +} + +// ToPtr returns a *AuditLogStatus pointing to the current value. +func (c AuditLogStatus) ToPtr() *AuditLogStatus { + return &c +} + +// BaseImageDependencyType - The type of the base image dependency. +type BaseImageDependencyType string + +const ( + BaseImageDependencyTypeBuildTime BaseImageDependencyType = "BuildTime" + BaseImageDependencyTypeRunTime BaseImageDependencyType = "RunTime" +) + +// PossibleBaseImageDependencyTypeValues returns the possible values for the BaseImageDependencyType const type. +func PossibleBaseImageDependencyTypeValues() []BaseImageDependencyType { + return []BaseImageDependencyType{ + BaseImageDependencyTypeBuildTime, + BaseImageDependencyTypeRunTime, + } +} + +// ToPtr returns a *BaseImageDependencyType pointing to the current value. +func (c BaseImageDependencyType) ToPtr() *BaseImageDependencyType { + return &c +} + +// BaseImageTriggerType - The type of the auto trigger for base image dependency updates. +type BaseImageTriggerType string + +const ( + BaseImageTriggerTypeAll BaseImageTriggerType = "All" + BaseImageTriggerTypeRuntime BaseImageTriggerType = "Runtime" +) + +// PossibleBaseImageTriggerTypeValues returns the possible values for the BaseImageTriggerType const type. +func PossibleBaseImageTriggerTypeValues() []BaseImageTriggerType { + return []BaseImageTriggerType{ + BaseImageTriggerTypeAll, + BaseImageTriggerTypeRuntime, + } +} + +// ToPtr returns a *BaseImageTriggerType pointing to the current value. +func (c BaseImageTriggerType) ToPtr() *BaseImageTriggerType { + return &c +} + +// CertificateType - The type of certificate location. +type CertificateType string + +const ( + CertificateTypeLocalDirectory CertificateType = "LocalDirectory" +) + +// PossibleCertificateTypeValues returns the possible values for the CertificateType const type. +func PossibleCertificateTypeValues() []CertificateType { + return []CertificateType{ + CertificateTypeLocalDirectory, + } +} + +// ToPtr returns a *CertificateType pointing to the current value. +func (c CertificateType) ToPtr() *CertificateType { + return &c +} + +// ConnectedRegistryMode - The mode of the connected registry resource that indicates the permissions of the registry. +type ConnectedRegistryMode string + +const ( + ConnectedRegistryModeMirror ConnectedRegistryMode = "Mirror" + ConnectedRegistryModeRegistry ConnectedRegistryMode = "Registry" +) + +// PossibleConnectedRegistryModeValues returns the possible values for the ConnectedRegistryMode const type. +func PossibleConnectedRegistryModeValues() []ConnectedRegistryMode { + return []ConnectedRegistryMode{ + ConnectedRegistryModeMirror, + ConnectedRegistryModeRegistry, + } +} + +// ToPtr returns a *ConnectedRegistryMode pointing to the current value. +func (c ConnectedRegistryMode) ToPtr() *ConnectedRegistryMode { + return &c +} + +// ConnectionState - The current connection state of the connected registry. +type ConnectionState string + +const ( + ConnectionStateOffline ConnectionState = "Offline" + ConnectionStateOnline ConnectionState = "Online" + ConnectionStateSyncing ConnectionState = "Syncing" + ConnectionStateUnhealthy ConnectionState = "Unhealthy" +) + +// PossibleConnectionStateValues returns the possible values for the ConnectionState const type. +func PossibleConnectionStateValues() []ConnectionState { + return []ConnectionState{ + ConnectionStateOffline, + ConnectionStateOnline, + ConnectionStateSyncing, + ConnectionStateUnhealthy, + } +} + +// ToPtr returns a *ConnectionState pointing to the current value. +func (c ConnectionState) ToPtr() *ConnectionState { + return &c +} + +// ConnectionStatus - The private link service connection status. +type ConnectionStatus string + +const ( + ConnectionStatusApproved ConnectionStatus = "Approved" + ConnectionStatusDisconnected ConnectionStatus = "Disconnected" + ConnectionStatusPending ConnectionStatus = "Pending" + ConnectionStatusRejected ConnectionStatus = "Rejected" +) + +// PossibleConnectionStatusValues returns the possible values for the ConnectionStatus const type. +func PossibleConnectionStatusValues() []ConnectionStatus { + return []ConnectionStatus{ + ConnectionStatusApproved, + ConnectionStatusDisconnected, + ConnectionStatusPending, + ConnectionStatusRejected, + } +} + +// ToPtr returns a *ConnectionStatus pointing to the current value. +func (c ConnectionStatus) ToPtr() *ConnectionStatus { + return &c +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// ToPtr returns a *CreatedByType pointing to the current value. +func (c CreatedByType) ToPtr() *CreatedByType { + return &c +} + +// DefaultAction - The default action of allow or deny when no other rules match. +type DefaultAction string + +const ( + DefaultActionAllow DefaultAction = "Allow" + DefaultActionDeny DefaultAction = "Deny" +) + +// PossibleDefaultActionValues returns the possible values for the DefaultAction const type. +func PossibleDefaultActionValues() []DefaultAction { + return []DefaultAction{ + DefaultActionAllow, + DefaultActionDeny, + } +} + +// ToPtr returns a *DefaultAction pointing to the current value. +func (c DefaultAction) ToPtr() *DefaultAction { + return &c +} + +// EncryptionStatus - Indicates whether or not the encryption is enabled for container registry. +type EncryptionStatus string + +const ( + EncryptionStatusDisabled EncryptionStatus = "disabled" + EncryptionStatusEnabled EncryptionStatus = "enabled" +) + +// PossibleEncryptionStatusValues returns the possible values for the EncryptionStatus const type. +func PossibleEncryptionStatusValues() []EncryptionStatus { + return []EncryptionStatus{ + EncryptionStatusDisabled, + EncryptionStatusEnabled, + } +} + +// ToPtr returns a *EncryptionStatus pointing to the current value. +func (c EncryptionStatus) ToPtr() *EncryptionStatus { + return &c +} + +// ExportPolicyStatus - The value that indicates whether the policy is enabled or not. +type ExportPolicyStatus string + +const ( + ExportPolicyStatusDisabled ExportPolicyStatus = "disabled" + ExportPolicyStatusEnabled ExportPolicyStatus = "enabled" +) + +// PossibleExportPolicyStatusValues returns the possible values for the ExportPolicyStatus const type. +func PossibleExportPolicyStatusValues() []ExportPolicyStatus { + return []ExportPolicyStatus{ + ExportPolicyStatusDisabled, + ExportPolicyStatusEnabled, + } +} + +// ToPtr returns a *ExportPolicyStatus pointing to the current value. +func (c ExportPolicyStatus) ToPtr() *ExportPolicyStatus { + return &c +} + +// ImportMode - When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation before any copying +// begins. +type ImportMode string + +const ( + ImportModeForce ImportMode = "Force" + ImportModeNoForce ImportMode = "NoForce" +) + +// PossibleImportModeValues returns the possible values for the ImportMode const type. +func PossibleImportModeValues() []ImportMode { + return []ImportMode{ + ImportModeForce, + ImportModeNoForce, + } +} + +// ToPtr returns a *ImportMode pointing to the current value. +func (c ImportMode) ToPtr() *ImportMode { + return &c +} + +// LastModifiedByType - The type of identity that last modified the resource. +type LastModifiedByType string + +const ( + LastModifiedByTypeApplication LastModifiedByType = "Application" + LastModifiedByTypeKey LastModifiedByType = "Key" + LastModifiedByTypeManagedIdentity LastModifiedByType = "ManagedIdentity" + LastModifiedByTypeUser LastModifiedByType = "User" +) + +// PossibleLastModifiedByTypeValues returns the possible values for the LastModifiedByType const type. +func PossibleLastModifiedByTypeValues() []LastModifiedByType { + return []LastModifiedByType{ + LastModifiedByTypeApplication, + LastModifiedByTypeKey, + LastModifiedByTypeManagedIdentity, + LastModifiedByTypeUser, + } +} + +// ToPtr returns a *LastModifiedByType pointing to the current value. +func (c LastModifiedByType) ToPtr() *LastModifiedByType { + return &c +} + +// LogLevel - The verbosity of logs persisted on the connected registry. +type LogLevel string + +const ( + LogLevelDebug LogLevel = "Debug" + LogLevelError LogLevel = "Error" + LogLevelInformation LogLevel = "Information" + LogLevelNone LogLevel = "None" + LogLevelWarning LogLevel = "Warning" +) + +// PossibleLogLevelValues returns the possible values for the LogLevel const type. +func PossibleLogLevelValues() []LogLevel { + return []LogLevel{ + LogLevelDebug, + LogLevelError, + LogLevelInformation, + LogLevelNone, + LogLevelWarning, + } +} + +// ToPtr returns a *LogLevel pointing to the current value. +func (c LogLevel) ToPtr() *LogLevel { + return &c +} + +// NetworkRuleBypassOptions - Whether to allow trusted Azure services to access a network restricted registry. +type NetworkRuleBypassOptions string + +const ( + NetworkRuleBypassOptionsAzureServices NetworkRuleBypassOptions = "AzureServices" + NetworkRuleBypassOptionsNone NetworkRuleBypassOptions = "None" +) + +// PossibleNetworkRuleBypassOptionsValues returns the possible values for the NetworkRuleBypassOptions const type. +func PossibleNetworkRuleBypassOptionsValues() []NetworkRuleBypassOptions { + return []NetworkRuleBypassOptions{ + NetworkRuleBypassOptionsAzureServices, + NetworkRuleBypassOptionsNone, + } +} + +// ToPtr returns a *NetworkRuleBypassOptions pointing to the current value. +func (c NetworkRuleBypassOptions) ToPtr() *NetworkRuleBypassOptions { + return &c +} + +// OS - The OS of agent machine +type OS string + +const ( + OSLinux OS = "Linux" + OSWindows OS = "Windows" +) + +// PossibleOSValues returns the possible values for the OS const type. +func PossibleOSValues() []OS { + return []OS{ + OSLinux, + OSWindows, + } +} + +// ToPtr returns a *OS pointing to the current value. +func (c OS) ToPtr() *OS { + return &c +} + +// PasswordName - The password name. +type PasswordName string + +const ( + PasswordNamePassword PasswordName = "password" + PasswordNamePassword2 PasswordName = "password2" +) + +// PossiblePasswordNameValues returns the possible values for the PasswordName const type. +func PossiblePasswordNameValues() []PasswordName { + return []PasswordName{ + PasswordNamePassword, + PasswordNamePassword2, + } +} + +// ToPtr returns a *PasswordName pointing to the current value. +func (c PasswordName) ToPtr() *PasswordName { + return &c +} + +type PipelineOptions string + +const ( + PipelineOptionsContinueOnErrors PipelineOptions = "ContinueOnErrors" + PipelineOptionsDeleteSourceBlobOnSuccess PipelineOptions = "DeleteSourceBlobOnSuccess" + PipelineOptionsOverwriteBlobs PipelineOptions = "OverwriteBlobs" + PipelineOptionsOverwriteTags PipelineOptions = "OverwriteTags" +) + +// PossiblePipelineOptionsValues returns the possible values for the PipelineOptions const type. +func PossiblePipelineOptionsValues() []PipelineOptions { + return []PipelineOptions{ + PipelineOptionsContinueOnErrors, + PipelineOptionsDeleteSourceBlobOnSuccess, + PipelineOptionsOverwriteBlobs, + PipelineOptionsOverwriteTags, + } +} + +// ToPtr returns a *PipelineOptions pointing to the current value. +func (c PipelineOptions) ToPtr() *PipelineOptions { + return &c +} + +// PipelineRunSourceType - The type of the source. +type PipelineRunSourceType string + +const ( + PipelineRunSourceTypeAzureStorageBlob PipelineRunSourceType = "AzureStorageBlob" +) + +// PossiblePipelineRunSourceTypeValues returns the possible values for the PipelineRunSourceType const type. +func PossiblePipelineRunSourceTypeValues() []PipelineRunSourceType { + return []PipelineRunSourceType{ + PipelineRunSourceTypeAzureStorageBlob, + } +} + +// ToPtr returns a *PipelineRunSourceType pointing to the current value. +func (c PipelineRunSourceType) ToPtr() *PipelineRunSourceType { + return &c +} + +// PipelineRunTargetType - The type of the target. +type PipelineRunTargetType string + +const ( + PipelineRunTargetTypeAzureStorageBlob PipelineRunTargetType = "AzureStorageBlob" +) + +// PossiblePipelineRunTargetTypeValues returns the possible values for the PipelineRunTargetType const type. +func PossiblePipelineRunTargetTypeValues() []PipelineRunTargetType { + return []PipelineRunTargetType{ + PipelineRunTargetTypeAzureStorageBlob, + } +} + +// ToPtr returns a *PipelineRunTargetType pointing to the current value. +func (c PipelineRunTargetType) ToPtr() *PipelineRunTargetType { + return &c +} + +// PipelineSourceType - The type of source for the import pipeline. +type PipelineSourceType string + +const ( + PipelineSourceTypeAzureStorageBlobContainer PipelineSourceType = "AzureStorageBlobContainer" +) + +// PossiblePipelineSourceTypeValues returns the possible values for the PipelineSourceType const type. +func PossiblePipelineSourceTypeValues() []PipelineSourceType { + return []PipelineSourceType{ + PipelineSourceTypeAzureStorageBlobContainer, + } +} + +// ToPtr returns a *PipelineSourceType pointing to the current value. +func (c PipelineSourceType) ToPtr() *PipelineSourceType { + return &c +} + +// PolicyStatus - The value that indicates whether the policy is enabled or not. +type PolicyStatus string + +const ( + PolicyStatusDisabled PolicyStatus = "disabled" + PolicyStatusEnabled PolicyStatus = "enabled" +) + +// PossiblePolicyStatusValues returns the possible values for the PolicyStatus const type. +func PossiblePolicyStatusValues() []PolicyStatus { + return []PolicyStatus{ + PolicyStatusDisabled, + PolicyStatusEnabled, + } +} + +// ToPtr returns a *PolicyStatus pointing to the current value. +func (c PolicyStatus) ToPtr() *PolicyStatus { + return &c +} + +// ProvisioningState - The provisioning state of this agent pool +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCanceled, + ProvisioningStateCreating, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// PublicNetworkAccess - Whether or not public network access is allowed for the container registry. +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns the possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{ + PublicNetworkAccessDisabled, + PublicNetworkAccessEnabled, + } +} + +// ToPtr returns a *PublicNetworkAccess pointing to the current value. +func (c PublicNetworkAccess) ToPtr() *PublicNetworkAccess { + return &c +} + +// RegistryUsageUnit - The unit of measurement. +type RegistryUsageUnit string + +const ( + RegistryUsageUnitBytes RegistryUsageUnit = "Bytes" + RegistryUsageUnitCount RegistryUsageUnit = "Count" +) + +// PossibleRegistryUsageUnitValues returns the possible values for the RegistryUsageUnit const type. +func PossibleRegistryUsageUnitValues() []RegistryUsageUnit { + return []RegistryUsageUnit{ + RegistryUsageUnitBytes, + RegistryUsageUnitCount, + } +} + +// ToPtr returns a *RegistryUsageUnit pointing to the current value. +func (c RegistryUsageUnit) ToPtr() *RegistryUsageUnit { + return &c +} + +// ResourceIdentityType - The identity type. +type ResourceIdentityType string + +const ( + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" + ResourceIdentityTypeUserAssigned ResourceIdentityType = "UserAssigned" + ResourceIdentityTypeSystemAssignedUserAssigned ResourceIdentityType = "SystemAssigned, UserAssigned" + ResourceIdentityTypeNone ResourceIdentityType = "None" +) + +// PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ + ResourceIdentityTypeSystemAssigned, + ResourceIdentityTypeUserAssigned, + ResourceIdentityTypeSystemAssignedUserAssigned, + ResourceIdentityTypeNone, + } +} + +// ToPtr returns a *ResourceIdentityType pointing to the current value. +func (c ResourceIdentityType) ToPtr() *ResourceIdentityType { + return &c +} + +// RunStatus - The current status of the run. +type RunStatus string + +const ( + RunStatusCanceled RunStatus = "Canceled" + RunStatusError RunStatus = "Error" + RunStatusFailed RunStatus = "Failed" + RunStatusQueued RunStatus = "Queued" + RunStatusRunning RunStatus = "Running" + RunStatusStarted RunStatus = "Started" + RunStatusSucceeded RunStatus = "Succeeded" + RunStatusTimeout RunStatus = "Timeout" +) + +// PossibleRunStatusValues returns the possible values for the RunStatus const type. +func PossibleRunStatusValues() []RunStatus { + return []RunStatus{ + RunStatusCanceled, + RunStatusError, + RunStatusFailed, + RunStatusQueued, + RunStatusRunning, + RunStatusStarted, + RunStatusSucceeded, + RunStatusTimeout, + } +} + +// ToPtr returns a *RunStatus pointing to the current value. +func (c RunStatus) ToPtr() *RunStatus { + return &c +} + +// RunType - The type of run. +type RunType string + +const ( + RunTypeAutoBuild RunType = "AutoBuild" + RunTypeAutoRun RunType = "AutoRun" + RunTypeQuickBuild RunType = "QuickBuild" + RunTypeQuickRun RunType = "QuickRun" +) + +// PossibleRunTypeValues returns the possible values for the RunType const type. +func PossibleRunTypeValues() []RunType { + return []RunType{ + RunTypeAutoBuild, + RunTypeAutoRun, + RunTypeQuickBuild, + RunTypeQuickRun, + } +} + +// ToPtr returns a *RunType pointing to the current value. +func (c RunType) ToPtr() *RunType { + return &c +} + +// SKUName - The SKU name of the container registry. Required for registry creation. +type SKUName string + +const ( + SKUNameBasic SKUName = "Basic" + SKUNameClassic SKUName = "Classic" + SKUNamePremium SKUName = "Premium" + SKUNameStandard SKUName = "Standard" +) + +// PossibleSKUNameValues returns the possible values for the SKUName const type. +func PossibleSKUNameValues() []SKUName { + return []SKUName{ + SKUNameBasic, + SKUNameClassic, + SKUNamePremium, + SKUNameStandard, + } +} + +// ToPtr returns a *SKUName pointing to the current value. +func (c SKUName) ToPtr() *SKUName { + return &c +} + +// SKUTier - The SKU tier based on the SKU name. +type SKUTier string + +const ( + SKUTierBasic SKUTier = "Basic" + SKUTierClassic SKUTier = "Classic" + SKUTierPremium SKUTier = "Premium" + SKUTierStandard SKUTier = "Standard" +) + +// PossibleSKUTierValues returns the possible values for the SKUTier const type. +func PossibleSKUTierValues() []SKUTier { + return []SKUTier{ + SKUTierBasic, + SKUTierClassic, + SKUTierPremium, + SKUTierStandard, + } +} + +// ToPtr returns a *SKUTier pointing to the current value. +func (c SKUTier) ToPtr() *SKUTier { + return &c +} + +// SecretObjectType - The type of the secret object which determines how the value of the secret object has to be interpreted. +type SecretObjectType string + +const ( + SecretObjectTypeOpaque SecretObjectType = "Opaque" + SecretObjectTypeVaultsecret SecretObjectType = "Vaultsecret" +) + +// PossibleSecretObjectTypeValues returns the possible values for the SecretObjectType const type. +func PossibleSecretObjectTypeValues() []SecretObjectType { + return []SecretObjectType{ + SecretObjectTypeOpaque, + SecretObjectTypeVaultsecret, + } +} + +// ToPtr returns a *SecretObjectType pointing to the current value. +func (c SecretObjectType) ToPtr() *SecretObjectType { + return &c +} + +// SourceControlType - The type of source control service. +type SourceControlType string + +const ( + SourceControlTypeGithub SourceControlType = "Github" + SourceControlTypeVisualStudioTeamService SourceControlType = "VisualStudioTeamService" +) + +// PossibleSourceControlTypeValues returns the possible values for the SourceControlType const type. +func PossibleSourceControlTypeValues() []SourceControlType { + return []SourceControlType{ + SourceControlTypeGithub, + SourceControlTypeVisualStudioTeamService, + } +} + +// ToPtr returns a *SourceControlType pointing to the current value. +func (c SourceControlType) ToPtr() *SourceControlType { + return &c +} + +// SourceRegistryLoginMode - The authentication mode which determines the source registry login scope. The credentials for the source registry will be generated +// using the given scope. These credentials will be used to login to +// the source registry during the run. +type SourceRegistryLoginMode string + +const ( + SourceRegistryLoginModeDefault SourceRegistryLoginMode = "Default" + SourceRegistryLoginModeNone SourceRegistryLoginMode = "None" +) + +// PossibleSourceRegistryLoginModeValues returns the possible values for the SourceRegistryLoginMode const type. +func PossibleSourceRegistryLoginModeValues() []SourceRegistryLoginMode { + return []SourceRegistryLoginMode{ + SourceRegistryLoginModeDefault, + SourceRegistryLoginModeNone, + } +} + +// ToPtr returns a *SourceRegistryLoginMode pointing to the current value. +func (c SourceRegistryLoginMode) ToPtr() *SourceRegistryLoginMode { + return &c +} + +type SourceTriggerEvent string + +const ( + SourceTriggerEventCommit SourceTriggerEvent = "commit" + SourceTriggerEventPullrequest SourceTriggerEvent = "pullrequest" +) + +// PossibleSourceTriggerEventValues returns the possible values for the SourceTriggerEvent const type. +func PossibleSourceTriggerEventValues() []SourceTriggerEvent { + return []SourceTriggerEvent{ + SourceTriggerEventCommit, + SourceTriggerEventPullrequest, + } +} + +// ToPtr returns a *SourceTriggerEvent pointing to the current value. +func (c SourceTriggerEvent) ToPtr() *SourceTriggerEvent { + return &c +} + +// StepType - The type of the step. +type StepType string + +const ( + StepTypeDocker StepType = "Docker" + StepTypeEncodedTask StepType = "EncodedTask" + StepTypeFileTask StepType = "FileTask" +) + +// PossibleStepTypeValues returns the possible values for the StepType const type. +func PossibleStepTypeValues() []StepType { + return []StepType{ + StepTypeDocker, + StepTypeEncodedTask, + StepTypeFileTask, + } +} + +// ToPtr returns a *StepType pointing to the current value. +func (c StepType) ToPtr() *StepType { + return &c +} + +// TLSStatus - Indicates whether HTTPS is enabled for the login server. +type TLSStatus string + +const ( + TLSStatusDisabled TLSStatus = "Disabled" + TLSStatusEnabled TLSStatus = "Enabled" +) + +// PossibleTLSStatusValues returns the possible values for the TLSStatus const type. +func PossibleTLSStatusValues() []TLSStatus { + return []TLSStatus{ + TLSStatusDisabled, + TLSStatusEnabled, + } +} + +// ToPtr returns a *TLSStatus pointing to the current value. +func (c TLSStatus) ToPtr() *TLSStatus { + return &c +} + +// TaskStatus - The current status of task. +type TaskStatus string + +const ( + TaskStatusDisabled TaskStatus = "Disabled" + TaskStatusEnabled TaskStatus = "Enabled" +) + +// PossibleTaskStatusValues returns the possible values for the TaskStatus const type. +func PossibleTaskStatusValues() []TaskStatus { + return []TaskStatus{ + TaskStatusDisabled, + TaskStatusEnabled, + } +} + +// ToPtr returns a *TaskStatus pointing to the current value. +func (c TaskStatus) ToPtr() *TaskStatus { + return &c +} + +type TokenCertificateName string + +const ( + TokenCertificateNameCertificate1 TokenCertificateName = "certificate1" + TokenCertificateNameCertificate2 TokenCertificateName = "certificate2" +) + +// PossibleTokenCertificateNameValues returns the possible values for the TokenCertificateName const type. +func PossibleTokenCertificateNameValues() []TokenCertificateName { + return []TokenCertificateName{ + TokenCertificateNameCertificate1, + TokenCertificateNameCertificate2, + } +} + +// ToPtr returns a *TokenCertificateName pointing to the current value. +func (c TokenCertificateName) ToPtr() *TokenCertificateName { + return &c +} + +// TokenPasswordName - The password name "password1" or "password2" +type TokenPasswordName string + +const ( + TokenPasswordNamePassword1 TokenPasswordName = "password1" + TokenPasswordNamePassword2 TokenPasswordName = "password2" +) + +// PossibleTokenPasswordNameValues returns the possible values for the TokenPasswordName const type. +func PossibleTokenPasswordNameValues() []TokenPasswordName { + return []TokenPasswordName{ + TokenPasswordNamePassword1, + TokenPasswordNamePassword2, + } +} + +// ToPtr returns a *TokenPasswordName pointing to the current value. +func (c TokenPasswordName) ToPtr() *TokenPasswordName { + return &c +} + +// TokenStatus - The status of the token example enabled or disabled. +type TokenStatus string + +const ( + TokenStatusDisabled TokenStatus = "disabled" + TokenStatusEnabled TokenStatus = "enabled" +) + +// PossibleTokenStatusValues returns the possible values for the TokenStatus const type. +func PossibleTokenStatusValues() []TokenStatus { + return []TokenStatus{ + TokenStatusDisabled, + TokenStatusEnabled, + } +} + +// ToPtr returns a *TokenStatus pointing to the current value. +func (c TokenStatus) ToPtr() *TokenStatus { + return &c +} + +// TokenType - The type of Auth token. +type TokenType string + +const ( + TokenTypeOAuth TokenType = "OAuth" + TokenTypePAT TokenType = "PAT" +) + +// PossibleTokenTypeValues returns the possible values for the TokenType const type. +func PossibleTokenTypeValues() []TokenType { + return []TokenType{ + TokenTypeOAuth, + TokenTypePAT, + } +} + +// ToPtr returns a *TokenType pointing to the current value. +func (c TokenType) ToPtr() *TokenType { + return &c +} + +// TriggerStatus - The current status of trigger. +type TriggerStatus string + +const ( + TriggerStatusDisabled TriggerStatus = "Disabled" + TriggerStatusEnabled TriggerStatus = "Enabled" +) + +// PossibleTriggerStatusValues returns the possible values for the TriggerStatus const type. +func PossibleTriggerStatusValues() []TriggerStatus { + return []TriggerStatus{ + TriggerStatusDisabled, + TriggerStatusEnabled, + } +} + +// ToPtr returns a *TriggerStatus pointing to the current value. +func (c TriggerStatus) ToPtr() *TriggerStatus { + return &c +} + +// TrustPolicyType - The type of trust policy. +type TrustPolicyType string + +const ( + TrustPolicyTypeNotary TrustPolicyType = "Notary" +) + +// PossibleTrustPolicyTypeValues returns the possible values for the TrustPolicyType const type. +func PossibleTrustPolicyTypeValues() []TrustPolicyType { + return []TrustPolicyType{ + TrustPolicyTypeNotary, + } +} + +// ToPtr returns a *TrustPolicyType pointing to the current value. +func (c TrustPolicyType) ToPtr() *TrustPolicyType { + return &c +} + +// UpdateTriggerPayloadType - Type of Payload body for Base image update triggers. +type UpdateTriggerPayloadType string + +const ( + UpdateTriggerPayloadTypeDefault UpdateTriggerPayloadType = "Default" + UpdateTriggerPayloadTypeToken UpdateTriggerPayloadType = "Token" +) + +// PossibleUpdateTriggerPayloadTypeValues returns the possible values for the UpdateTriggerPayloadType const type. +func PossibleUpdateTriggerPayloadTypeValues() []UpdateTriggerPayloadType { + return []UpdateTriggerPayloadType{ + UpdateTriggerPayloadTypeDefault, + UpdateTriggerPayloadTypeToken, + } +} + +// ToPtr returns a *UpdateTriggerPayloadType pointing to the current value. +func (c UpdateTriggerPayloadType) ToPtr() *UpdateTriggerPayloadType { + return &c +} + +// Variant - Variant of the CPU. +type Variant string + +const ( + VariantV6 Variant = "v6" + VariantV7 Variant = "v7" + VariantV8 Variant = "v8" +) + +// PossibleVariantValues returns the possible values for the Variant const type. +func PossibleVariantValues() []Variant { + return []Variant{ + VariantV6, + VariantV7, + VariantV8, + } +} + +// ToPtr returns a *Variant pointing to the current value. +func (c Variant) ToPtr() *Variant { + return &c +} + +type WebhookAction string + +const ( + WebhookActionChartDelete WebhookAction = "chart_delete" + WebhookActionChartPush WebhookAction = "chart_push" + WebhookActionDelete WebhookAction = "delete" + WebhookActionPush WebhookAction = "push" + WebhookActionQuarantine WebhookAction = "quarantine" +) + +// PossibleWebhookActionValues returns the possible values for the WebhookAction const type. +func PossibleWebhookActionValues() []WebhookAction { + return []WebhookAction{ + WebhookActionChartDelete, + WebhookActionChartPush, + WebhookActionDelete, + WebhookActionPush, + WebhookActionQuarantine, + } +} + +// ToPtr returns a *WebhookAction pointing to the current value. +func (c WebhookAction) ToPtr() *WebhookAction { + return &c +} + +// WebhookStatus - The status of the webhook at the time the operation was called. +type WebhookStatus string + +const ( + WebhookStatusDisabled WebhookStatus = "disabled" + WebhookStatusEnabled WebhookStatus = "enabled" +) + +// PossibleWebhookStatusValues returns the possible values for the WebhookStatus const type. +func PossibleWebhookStatusValues() []WebhookStatus { + return []WebhookStatus{ + WebhookStatusDisabled, + WebhookStatusEnabled, + } +} + +// ToPtr returns a *WebhookStatus pointing to the current value. +func (c WebhookStatus) ToPtr() *WebhookStatus { + return &c +} + +// ZoneRedundancy - Whether or not zone redundancy is enabled for this container registry +type ZoneRedundancy string + +const ( + ZoneRedundancyDisabled ZoneRedundancy = "Disabled" + ZoneRedundancyEnabled ZoneRedundancy = "Enabled" +) + +// PossibleZoneRedundancyValues returns the possible values for the ZoneRedundancy const type. +func PossibleZoneRedundancyValues() []ZoneRedundancy { + return []ZoneRedundancy{ + ZoneRedundancyDisabled, + ZoneRedundancyEnabled, + } +} + +// ToPtr returns a *ZoneRedundancy pointing to the current value. +func (c ZoneRedundancy) ToPtr() *ZoneRedundancy { + return &c +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_exportpipelines_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_exportpipelines_client.go new file mode 100644 index 000000000000..99915a5a3180 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_exportpipelines_client.go @@ -0,0 +1,380 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// ExportPipelinesClient contains the methods for the ExportPipelines group. +// Don't use this type directly, use NewExportPipelinesClient() instead. +type ExportPipelinesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewExportPipelinesClient creates a new instance of ExportPipelinesClient with the specified values. +func NewExportPipelinesClient(con *armcore.Connection, subscriptionID string) *ExportPipelinesClient { + return &ExportPipelinesClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Creates an export pipeline for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *ExportPipelinesClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, exportPipelineCreateParameters ExportPipeline, options *ExportPipelinesBeginCreateOptions) (ExportPipelinePollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, registryName, exportPipelineName, exportPipelineCreateParameters, options) + if err != nil { + return ExportPipelinePollerResponse{}, err + } + result := ExportPipelinePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ExportPipelinesClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return ExportPipelinePollerResponse{}, err + } + poller := &exportPipelinePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ExportPipelineResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new ExportPipelinePoller from the specified resume token. +// token - The value must come from a previous call to ExportPipelinePoller.ResumeToken(). +func (client *ExportPipelinesClient) ResumeCreate(ctx context.Context, token string) (ExportPipelinePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ExportPipelinesClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return ExportPipelinePollerResponse{}, err + } + poller := &exportPipelinePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ExportPipelinePollerResponse{}, err + } + result := ExportPipelinePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ExportPipelineResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates an export pipeline for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *ExportPipelinesClient) create(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, exportPipelineCreateParameters ExportPipeline, options *ExportPipelinesBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, exportPipelineName, exportPipelineCreateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *ExportPipelinesClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, exportPipelineCreateParameters ExportPipeline, options *ExportPipelinesBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if exportPipelineName == "" { + return nil, errors.New("parameter exportPipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{exportPipelineName}", url.PathEscape(exportPipelineName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(exportPipelineCreateParameters) +} + +// createHandleError handles the Create error response. +func (client *ExportPipelinesClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginDelete - Deletes an export pipeline from a container registry. +// If the operation fails it returns a generic error. +func (client *ExportPipelinesClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, options *ExportPipelinesBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, exportPipelineName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ExportPipelinesClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *ExportPipelinesClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ExportPipelinesClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes an export pipeline from a container registry. +// If the operation fails it returns a generic error. +func (client *ExportPipelinesClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, options *ExportPipelinesBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, exportPipelineName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ExportPipelinesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, options *ExportPipelinesBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if exportPipelineName == "" { + return nil, errors.New("parameter exportPipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{exportPipelineName}", url.PathEscape(exportPipelineName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ExportPipelinesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets the properties of the export pipeline. +// If the operation fails it returns a generic error. +func (client *ExportPipelinesClient) Get(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, options *ExportPipelinesGetOptions) (ExportPipelineResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, exportPipelineName, options) + if err != nil { + return ExportPipelineResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ExportPipelineResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ExportPipelineResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ExportPipelinesClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, exportPipelineName string, options *ExportPipelinesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines/{exportPipelineName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if exportPipelineName == "" { + return nil, errors.New("parameter exportPipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{exportPipelineName}", url.PathEscape(exportPipelineName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ExportPipelinesClient) getHandleResponse(resp *azcore.Response) (ExportPipelineResponse, error) { + var val *ExportPipeline + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ExportPipelineResponse{}, err + } + return ExportPipelineResponse{RawResponse: resp.Response, ExportPipeline: val}, nil +} + +// getHandleError handles the Get error response. +func (client *ExportPipelinesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// List - Lists all export pipelines for the specified container registry. +// If the operation fails it returns a generic error. +func (client *ExportPipelinesClient) List(resourceGroupName string, registryName string, options *ExportPipelinesListOptions) ExportPipelineListResultPager { + return &exportPipelineListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp ExportPipelineListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ExportPipelineListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *ExportPipelinesClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *ExportPipelinesListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/exportPipelines" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ExportPipelinesClient) listHandleResponse(resp *azcore.Response) (ExportPipelineListResultResponse, error) { + var val *ExportPipelineListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ExportPipelineListResultResponse{}, err + } + return ExportPipelineListResultResponse{RawResponse: resp.Response, ExportPipelineListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *ExportPipelinesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_importpipelines_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_importpipelines_client.go new file mode 100644 index 000000000000..a7a97896ea1e --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_importpipelines_client.go @@ -0,0 +1,380 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// ImportPipelinesClient contains the methods for the ImportPipelines group. +// Don't use this type directly, use NewImportPipelinesClient() instead. +type ImportPipelinesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewImportPipelinesClient creates a new instance of ImportPipelinesClient with the specified values. +func NewImportPipelinesClient(con *armcore.Connection, subscriptionID string) *ImportPipelinesClient { + return &ImportPipelinesClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Creates an import pipeline for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *ImportPipelinesClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, importPipelineCreateParameters ImportPipeline, options *ImportPipelinesBeginCreateOptions) (ImportPipelinePollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, registryName, importPipelineName, importPipelineCreateParameters, options) + if err != nil { + return ImportPipelinePollerResponse{}, err + } + result := ImportPipelinePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ImportPipelinesClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return ImportPipelinePollerResponse{}, err + } + poller := &importPipelinePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ImportPipelineResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new ImportPipelinePoller from the specified resume token. +// token - The value must come from a previous call to ImportPipelinePoller.ResumeToken(). +func (client *ImportPipelinesClient) ResumeCreate(ctx context.Context, token string) (ImportPipelinePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ImportPipelinesClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return ImportPipelinePollerResponse{}, err + } + poller := &importPipelinePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ImportPipelinePollerResponse{}, err + } + result := ImportPipelinePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ImportPipelineResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates an import pipeline for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *ImportPipelinesClient) create(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, importPipelineCreateParameters ImportPipeline, options *ImportPipelinesBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, importPipelineName, importPipelineCreateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *ImportPipelinesClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, importPipelineCreateParameters ImportPipeline, options *ImportPipelinesBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if importPipelineName == "" { + return nil, errors.New("parameter importPipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{importPipelineName}", url.PathEscape(importPipelineName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(importPipelineCreateParameters) +} + +// createHandleError handles the Create error response. +func (client *ImportPipelinesClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginDelete - Deletes an import pipeline from a container registry. +// If the operation fails it returns a generic error. +func (client *ImportPipelinesClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, options *ImportPipelinesBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, importPipelineName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ImportPipelinesClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *ImportPipelinesClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ImportPipelinesClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes an import pipeline from a container registry. +// If the operation fails it returns a generic error. +func (client *ImportPipelinesClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, options *ImportPipelinesBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, importPipelineName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ImportPipelinesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, options *ImportPipelinesBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if importPipelineName == "" { + return nil, errors.New("parameter importPipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{importPipelineName}", url.PathEscape(importPipelineName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ImportPipelinesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets the properties of the import pipeline. +// If the operation fails it returns a generic error. +func (client *ImportPipelinesClient) Get(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, options *ImportPipelinesGetOptions) (ImportPipelineResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, importPipelineName, options) + if err != nil { + return ImportPipelineResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ImportPipelineResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ImportPipelineResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ImportPipelinesClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, importPipelineName string, options *ImportPipelinesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines/{importPipelineName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if importPipelineName == "" { + return nil, errors.New("parameter importPipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{importPipelineName}", url.PathEscape(importPipelineName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ImportPipelinesClient) getHandleResponse(resp *azcore.Response) (ImportPipelineResponse, error) { + var val *ImportPipeline + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ImportPipelineResponse{}, err + } + return ImportPipelineResponse{RawResponse: resp.Response, ImportPipeline: val}, nil +} + +// getHandleError handles the Get error response. +func (client *ImportPipelinesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// List - Lists all import pipelines for the specified container registry. +// If the operation fails it returns a generic error. +func (client *ImportPipelinesClient) List(resourceGroupName string, registryName string, options *ImportPipelinesListOptions) ImportPipelineListResultPager { + return &importPipelineListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp ImportPipelineListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ImportPipelineListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *ImportPipelinesClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *ImportPipelinesListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importPipelines" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ImportPipelinesClient) listHandleResponse(resp *azcore.Response) (ImportPipelineListResultResponse, error) { + var val *ImportPipelineListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ImportPipelineListResultResponse{}, err + } + return ImportPipelineListResultResponse{RawResponse: resp.Response, ImportPipelineListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *ImportPipelinesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_models.go b/sdk/containerregistry/armcontainerregistry/zz_generated_models.go new file mode 100644 index 000000000000..2b7bb686c9c4 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_models.go @@ -0,0 +1,5256 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// ActivationProperties - The activation properties of the connected registry. +type ActivationProperties struct { + // READ-ONLY; The activation status of the connected registry. + Status *ActivationStatus `json:"status,omitempty" azure:"ro"` +} + +// ActiveDirectoryObject - The Active Directory Object that will be used for authenticating the token of a container registry. +type ActiveDirectoryObject struct { + // The user/group/application object ID for Active Directory Object that will be used for authenticating the token of a container registry. + ObjectID *string `json:"objectId,omitempty"` + + // The tenant ID of user/group/application object Active Directory Object that will be used for authenticating the token of a container registry. + TenantID *string `json:"tenantId,omitempty"` +} + +// Actor - The agent that initiated the event. For most situations, this could be from the authorization context of the request. +type Actor struct { + // The subject or username associated with the request context that generated the event. + Name *string `json:"name,omitempty"` +} + +// AgentPool - The agentpool that has the ARM resource and properties. The agentpool will have all information to create an agent pool. +type AgentPool struct { + Resource + // The properties associated with the agent pool + Properties *AgentPoolProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPool. +func (a AgentPool) MarshalJSON() ([]byte, error) { + objectMap := a.Resource.marshalInternal() + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// AgentPoolListResult - The collection of agent pools. +type AgentPoolListResult struct { + // The URI that can be used to request the next set of paged results. + NextLink *string `json:"nextLink,omitempty"` + + // The collection value. + Value []*AgentPool `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPoolListResult. +func (a AgentPoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AgentPoolProperties - The properties of agent pool. +type AgentPoolProperties struct { + // The count of agent machine + Count *int32 `json:"count,omitempty"` + + // The OS of agent machine + OS *OS `json:"os,omitempty"` + + // The Tier of agent machine + Tier *string `json:"tier,omitempty"` + + // The Virtual Network Subnet Resource Id of the agent machine + VirtualNetworkSubnetResourceID *string `json:"virtualNetworkSubnetResourceId,omitempty"` + + // READ-ONLY; The provisioning state of this agent pool + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +type AgentPoolPropertiesUpdateParameters struct { + // The count of agent machine + Count *int32 `json:"count,omitempty"` +} + +// AgentPoolQueueStatus - The QueueStatus of Agent Pool +type AgentPoolQueueStatus struct { + // The number of pending runs in the queue + Count *int32 `json:"count,omitempty"` +} + +// AgentPoolUpdateParameters - The parameters for updating an agent pool. +type AgentPoolUpdateParameters struct { + // The properties associated with the agent pool + Properties *AgentPoolPropertiesUpdateParameters `json:"properties,omitempty"` + + // The ARM resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPoolUpdateParameters. +func (a AgentPoolUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// AgentPoolsBeginCreateOptions contains the optional parameters for the AgentPools.BeginCreate method. +type AgentPoolsBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// AgentPoolsBeginDeleteOptions contains the optional parameters for the AgentPools.BeginDelete method. +type AgentPoolsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// AgentPoolsBeginUpdateOptions contains the optional parameters for the AgentPools.BeginUpdate method. +type AgentPoolsBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// AgentPoolsGetOptions contains the optional parameters for the AgentPools.Get method. +type AgentPoolsGetOptions struct { + // placeholder for future optional parameters +} + +// AgentPoolsGetQueueStatusOptions contains the optional parameters for the AgentPools.GetQueueStatus method. +type AgentPoolsGetQueueStatusOptions struct { + // placeholder for future optional parameters +} + +// AgentPoolsListOptions contains the optional parameters for the AgentPools.List method. +type AgentPoolsListOptions struct { + // placeholder for future optional parameters +} + +// AgentProperties - The properties that determine the run agent configuration. +type AgentProperties struct { + // The CPU configuration in terms of number of cores required for the run. + CPU *int32 `json:"cpu,omitempty"` +} + +// Argument - The properties of a run argument. +type Argument struct { + // REQUIRED; The name of the argument. + Name *string `json:"name,omitempty"` + + // REQUIRED; The value of the argument. + Value *string `json:"value,omitempty"` + + // Flag to indicate whether the argument represents a secret and want to be removed from build logs. + IsSecret *bool `json:"isSecret,omitempty"` +} + +// AuthInfo - The authorization properties for accessing the source code repository. +type AuthInfo struct { + // REQUIRED; The access token used to access the source control provider. + Token *string `json:"token,omitempty"` + + // REQUIRED; The type of Auth token. + TokenType *TokenType `json:"tokenType,omitempty"` + + // Time in seconds that the token remains valid + ExpiresIn *int32 `json:"expiresIn,omitempty"` + + // The refresh token used to refresh the access token. + RefreshToken *string `json:"refreshToken,omitempty"` + + // The scope of the access token. + Scope *string `json:"scope,omitempty"` +} + +// AuthInfoUpdateParameters - The authorization properties for accessing the source code repository. +type AuthInfoUpdateParameters struct { + // Time in seconds that the token remains valid + ExpiresIn *int32 `json:"expiresIn,omitempty"` + + // The refresh token used to refresh the access token. + RefreshToken *string `json:"refreshToken,omitempty"` + + // The scope of the access token. + Scope *string `json:"scope,omitempty"` + + // The access token used to access the source control provider. + Token *string `json:"token,omitempty"` + + // The type of Auth token. + TokenType *TokenType `json:"tokenType,omitempty"` +} + +// BaseImageDependency - Properties that describe a base image dependency. +type BaseImageDependency struct { + // The sha256-based digest of the image manifest. + Digest *string `json:"digest,omitempty"` + + // The registry login server. + Registry *string `json:"registry,omitempty"` + + // The repository name. + Repository *string `json:"repository,omitempty"` + + // The tag name. + Tag *string `json:"tag,omitempty"` + + // The type of the base image dependency. + Type *BaseImageDependencyType `json:"type,omitempty"` +} + +// BaseImageTrigger - The trigger based on base image dependency. +type BaseImageTrigger struct { + // REQUIRED; The type of the auto trigger for base image dependency updates. + BaseImageTriggerType *BaseImageTriggerType `json:"baseImageTriggerType,omitempty"` + + // REQUIRED; The name of the trigger. + Name *string `json:"name,omitempty"` + + // The current status of trigger. + Status *TriggerStatus `json:"status,omitempty"` + + // The endpoint URL for receiving update triggers. + UpdateTriggerEndpoint *string `json:"updateTriggerEndpoint,omitempty"` + + // Type of Payload body for Base image update triggers. + UpdateTriggerPayloadType *UpdateTriggerPayloadType `json:"updateTriggerPayloadType,omitempty"` +} + +// BaseImageTriggerUpdateParameters - The properties for updating base image dependency trigger. +type BaseImageTriggerUpdateParameters struct { + // REQUIRED; The name of the trigger. + Name *string `json:"name,omitempty"` + + // The type of the auto trigger for base image dependency updates. + BaseImageTriggerType *BaseImageTriggerType `json:"baseImageTriggerType,omitempty"` + + // The current status of trigger. + Status *TriggerStatus `json:"status,omitempty"` + + // The endpoint URL for receiving update triggers. + UpdateTriggerEndpoint *string `json:"updateTriggerEndpoint,omitempty"` + + // Type of Payload body for Base image update triggers. + UpdateTriggerPayloadType *UpdateTriggerPayloadType `json:"updateTriggerPayloadType,omitempty"` +} + +// CallbackConfig - The configuration of service URI and custom headers for the webhook. +type CallbackConfig struct { + // REQUIRED; The service URI for the webhook to post notifications. + ServiceURI *string `json:"serviceUri,omitempty"` + + // Custom headers that will be added to the webhook notifications. + CustomHeaders map[string]*string `json:"customHeaders,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CallbackConfig. +func (c CallbackConfig) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "customHeaders", c.CustomHeaders) + populate(objectMap, "serviceUri", c.ServiceURI) + return json.Marshal(objectMap) +} + +// ConnectedRegistriesBeginCreateOptions contains the optional parameters for the ConnectedRegistries.BeginCreate method. +type ConnectedRegistriesBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// ConnectedRegistriesBeginDeactivateOptions contains the optional parameters for the ConnectedRegistries.BeginDeactivate method. +type ConnectedRegistriesBeginDeactivateOptions struct { + // placeholder for future optional parameters +} + +// ConnectedRegistriesBeginDeleteOptions contains the optional parameters for the ConnectedRegistries.BeginDelete method. +type ConnectedRegistriesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ConnectedRegistriesBeginUpdateOptions contains the optional parameters for the ConnectedRegistries.BeginUpdate method. +type ConnectedRegistriesBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// ConnectedRegistriesGetOptions contains the optional parameters for the ConnectedRegistries.Get method. +type ConnectedRegistriesGetOptions struct { + // placeholder for future optional parameters +} + +// ConnectedRegistriesListOptions contains the optional parameters for the ConnectedRegistries.List method. +type ConnectedRegistriesListOptions struct { + // An OData filter expression that describes a subset of connectedRegistries to return. The parameters that can be filtered are parent.id (the resource + // id of the connectedRegistry parent), mode, and connectionState. The supported operator is eq. + Filter *string +} + +// ConnectedRegistry - An object that represents a connected registry for a container registry. +type ConnectedRegistry struct { + ProxyResource + // The properties of the connected registry. + Properties *ConnectedRegistryProperties `json:"properties,omitempty"` +} + +// ConnectedRegistryListResult - The result of a request to list connected registries for a container registry. +type ConnectedRegistryListResult struct { + // The URI that can be used to request the next list of connected registries. + NextLink *string `json:"nextLink,omitempty"` + + // The list of connected registries. Since this list may be incomplete, the nextLink field should be used to request the next list of connected registries. + Value []*ConnectedRegistry `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ConnectedRegistryListResult. +func (c ConnectedRegistryListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// ConnectedRegistryProperties - The properties of a connected registry. +type ConnectedRegistryProperties struct { + // REQUIRED; The mode of the connected registry resource that indicates the permissions of the registry. + Mode *ConnectedRegistryMode `json:"mode,omitempty"` + + // REQUIRED; The parent of the connected registry. + Parent *ParentProperties `json:"parent,omitempty"` + + // The list of the ACR token resource IDs used to authenticate clients to the connected registry. + ClientTokenIDs []*string `json:"clientTokenIds,omitempty"` + + // The logging properties of the connected registry. + Logging *LoggingProperties `json:"logging,omitempty"` + + // The login server properties of the connected registry. + LoginServer *LoginServerProperties `json:"loginServer,omitempty"` + + // READ-ONLY; The activation properties of the connected registry. + Activation *ActivationProperties `json:"activation,omitempty" azure:"ro"` + + // READ-ONLY; The current connection state of the connected registry. + ConnectionState *ConnectionState `json:"connectionState,omitempty" azure:"ro"` + + // READ-ONLY; The last activity time of the connected registry. + LastActivityTime *time.Time `json:"lastActivityTime,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The list of current statuses of the connected registry. + StatusDetails []*StatusDetailProperties `json:"statusDetails,omitempty" azure:"ro"` + + // READ-ONLY; The current version of ACR runtime on the connected registry. + Version *string `json:"version,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ConnectedRegistryProperties. +func (c ConnectedRegistryProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "activation", c.Activation) + populate(objectMap, "clientTokenIds", c.ClientTokenIDs) + populate(objectMap, "connectionState", c.ConnectionState) + populate(objectMap, "lastActivityTime", (*timeRFC3339)(c.LastActivityTime)) + populate(objectMap, "logging", c.Logging) + populate(objectMap, "loginServer", c.LoginServer) + populate(objectMap, "mode", c.Mode) + populate(objectMap, "parent", c.Parent) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "statusDetails", c.StatusDetails) + populate(objectMap, "version", c.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConnectedRegistryProperties. +func (c *ConnectedRegistryProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "activation": + err = unpopulate(val, &c.Activation) + delete(rawMsg, key) + case "clientTokenIds": + err = unpopulate(val, &c.ClientTokenIDs) + delete(rawMsg, key) + case "connectionState": + err = unpopulate(val, &c.ConnectionState) + delete(rawMsg, key) + case "lastActivityTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + c.LastActivityTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "logging": + err = unpopulate(val, &c.Logging) + delete(rawMsg, key) + case "loginServer": + err = unpopulate(val, &c.LoginServer) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, &c.Mode) + delete(rawMsg, key) + case "parent": + err = unpopulate(val, &c.Parent) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &c.ProvisioningState) + delete(rawMsg, key) + case "statusDetails": + err = unpopulate(val, &c.StatusDetails) + delete(rawMsg, key) + case "version": + err = unpopulate(val, &c.Version) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ConnectedRegistryUpdateParameters - The parameters for updating a connected registry. +type ConnectedRegistryUpdateParameters struct { + // The properties of the connected registry update parameters. + Properties *ConnectedRegistryUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ConnectedRegistryUpdateParameters. +func (c ConnectedRegistryUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// ConnectedRegistryUpdateProperties - The parameters for updating token properties. +type ConnectedRegistryUpdateProperties struct { + // The list of the ACR token resource IDs used to authenticate clients to the connected registry. + ClientTokenIDs []*string `json:"clientTokenIds,omitempty"` + + // The logging properties of the connected registry. + Logging *LoggingProperties `json:"logging,omitempty"` + + // The sync properties of the connected registry with its parent. + SyncProperties *SyncUpdateProperties `json:"syncProperties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ConnectedRegistryUpdateProperties. +func (c ConnectedRegistryUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "clientTokenIds", c.ClientTokenIDs) + populate(objectMap, "logging", c.Logging) + populate(objectMap, "syncProperties", c.SyncProperties) + return json.Marshal(objectMap) +} + +// Credentials - The parameters that describes a set of credentials that will be used when a run is invoked. +type Credentials struct { + // Describes the credential parameters for accessing other custom registries. The key for the dictionary item will be the registry login server (myregistry.azurecr.io) + // and the value of the item will be + // the registry credentials for accessing the registry. + CustomRegistries map[string]*CustomRegistryCredentials `json:"customRegistries,omitempty"` + + // Describes the credential parameters for accessing the source registry. + SourceRegistry *SourceRegistryCredentials `json:"sourceRegistry,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Credentials. +func (c Credentials) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "customRegistries", c.CustomRegistries) + populate(objectMap, "sourceRegistry", c.SourceRegistry) + return json.Marshal(objectMap) +} + +// CustomRegistryCredentials - Describes the credentials that will be used to access a custom registry during a run. +type CustomRegistryCredentials struct { + // Indicates the managed identity assigned to the custom credential. If a user-assigned identity this value is the Client ID. If a system-assigned identity, + // the value will be system. In the case of a + // system-assigned identity, the Client ID will be determined by the runner. This identity may be used to authenticate to key vault to retrieve credentials + // or it may be the only source of authentication + // used for accessing the registry. + Identity *string `json:"identity,omitempty"` + + // The password for logging into the custom registry. The password is a secret object that allows multiple ways of providing the value for it. + Password *SecretObject `json:"password,omitempty"` + + // The username for logging into the custom registry. + UserName *SecretObject `json:"userName,omitempty"` +} + +// DockerBuildRequest - The parameters for a docker quick build. +type DockerBuildRequest struct { + RunRequest + // REQUIRED; The Docker file path relative to the source location. + DockerFilePath *string `json:"dockerFilePath,omitempty"` + + // REQUIRED; The platform properties against which the run has to happen. + Platform *PlatformProperties `json:"platform,omitempty"` + + // The machine configuration of the run agent. + AgentConfiguration *AgentProperties `json:"agentConfiguration,omitempty"` + + // The collection of override arguments to be used when executing the run. + Arguments []*Argument `json:"arguments,omitempty"` + + // The properties that describes a set of credentials that will be used when this run is invoked. + Credentials *Credentials `json:"credentials,omitempty"` + + // The fully qualified image names including the repository and tag. + ImageNames []*string `json:"imageNames,omitempty"` + + // The value of this property indicates whether the image built should be pushed to the registry or not. + IsPushEnabled *bool `json:"isPushEnabled,omitempty"` + + // The value of this property indicates whether the image cache is enabled or not. + NoCache *bool `json:"noCache,omitempty"` + + // The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. If it is relative URL, the relative path should be + // obtained from calling listBuildSourceUploadUrl API. + SourceLocation *string `json:"sourceLocation,omitempty"` + + // The name of the target build stage for the docker build. + Target *string `json:"target,omitempty"` + + // Run timeout in seconds. + Timeout *int32 `json:"timeout,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DockerBuildRequest. +func (d DockerBuildRequest) MarshalJSON() ([]byte, error) { + objectMap := d.RunRequest.marshalInternal("DockerBuildRequest") + populate(objectMap, "agentConfiguration", d.AgentConfiguration) + populate(objectMap, "arguments", d.Arguments) + populate(objectMap, "credentials", d.Credentials) + populate(objectMap, "dockerFilePath", d.DockerFilePath) + populate(objectMap, "imageNames", d.ImageNames) + populate(objectMap, "isPushEnabled", d.IsPushEnabled) + populate(objectMap, "noCache", d.NoCache) + populate(objectMap, "platform", d.Platform) + populate(objectMap, "sourceLocation", d.SourceLocation) + populate(objectMap, "target", d.Target) + populate(objectMap, "timeout", d.Timeout) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DockerBuildRequest. +func (d *DockerBuildRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "agentConfiguration": + err = unpopulate(val, &d.AgentConfiguration) + delete(rawMsg, key) + case "arguments": + err = unpopulate(val, &d.Arguments) + delete(rawMsg, key) + case "credentials": + err = unpopulate(val, &d.Credentials) + delete(rawMsg, key) + case "dockerFilePath": + err = unpopulate(val, &d.DockerFilePath) + delete(rawMsg, key) + case "imageNames": + err = unpopulate(val, &d.ImageNames) + delete(rawMsg, key) + case "isPushEnabled": + err = unpopulate(val, &d.IsPushEnabled) + delete(rawMsg, key) + case "noCache": + err = unpopulate(val, &d.NoCache) + delete(rawMsg, key) + case "platform": + err = unpopulate(val, &d.Platform) + delete(rawMsg, key) + case "sourceLocation": + err = unpopulate(val, &d.SourceLocation) + delete(rawMsg, key) + case "target": + err = unpopulate(val, &d.Target) + delete(rawMsg, key) + case "timeout": + err = unpopulate(val, &d.Timeout) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return d.RunRequest.unmarshalInternal(rawMsg) +} + +// DockerBuildStep - The Docker build step. +type DockerBuildStep struct { + TaskStepProperties + // REQUIRED; The Docker file path relative to the source context. + DockerFilePath *string `json:"dockerFilePath,omitempty"` + + // The collection of override arguments to be used when executing this build step. + Arguments []*Argument `json:"arguments,omitempty"` + + // The fully qualified image names including the repository and tag. + ImageNames []*string `json:"imageNames,omitempty"` + + // The value of this property indicates whether the image built should be pushed to the registry or not. + IsPushEnabled *bool `json:"isPushEnabled,omitempty"` + + // The value of this property indicates whether the image cache is enabled or not. + NoCache *bool `json:"noCache,omitempty"` + + // The name of the target build stage for the docker build. + Target *string `json:"target,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DockerBuildStep. +func (d DockerBuildStep) MarshalJSON() ([]byte, error) { + objectMap := d.TaskStepProperties.marshalInternal(StepTypeDocker) + populate(objectMap, "arguments", d.Arguments) + populate(objectMap, "dockerFilePath", d.DockerFilePath) + populate(objectMap, "imageNames", d.ImageNames) + populate(objectMap, "isPushEnabled", d.IsPushEnabled) + populate(objectMap, "noCache", d.NoCache) + populate(objectMap, "target", d.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DockerBuildStep. +func (d *DockerBuildStep) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "arguments": + err = unpopulate(val, &d.Arguments) + delete(rawMsg, key) + case "dockerFilePath": + err = unpopulate(val, &d.DockerFilePath) + delete(rawMsg, key) + case "imageNames": + err = unpopulate(val, &d.ImageNames) + delete(rawMsg, key) + case "isPushEnabled": + err = unpopulate(val, &d.IsPushEnabled) + delete(rawMsg, key) + case "noCache": + err = unpopulate(val, &d.NoCache) + delete(rawMsg, key) + case "target": + err = unpopulate(val, &d.Target) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return d.TaskStepProperties.unmarshalInternal(rawMsg) +} + +// DockerBuildStepUpdateParameters - The properties for updating a docker build step. +type DockerBuildStepUpdateParameters struct { + TaskStepUpdateParameters + // The collection of override arguments to be used when executing this build step. + Arguments []*Argument `json:"arguments,omitempty"` + + // The Docker file path relative to the source context. + DockerFilePath *string `json:"dockerFilePath,omitempty"` + + // The fully qualified image names including the repository and tag. + ImageNames []*string `json:"imageNames,omitempty"` + + // The value of this property indicates whether the image built should be pushed to the registry or not. + IsPushEnabled *bool `json:"isPushEnabled,omitempty"` + + // The value of this property indicates whether the image cache is enabled or not. + NoCache *bool `json:"noCache,omitempty"` + + // The name of the target build stage for the docker build. + Target *string `json:"target,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DockerBuildStepUpdateParameters. +func (d DockerBuildStepUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := d.TaskStepUpdateParameters.marshalInternal(StepTypeDocker) + populate(objectMap, "arguments", d.Arguments) + populate(objectMap, "dockerFilePath", d.DockerFilePath) + populate(objectMap, "imageNames", d.ImageNames) + populate(objectMap, "isPushEnabled", d.IsPushEnabled) + populate(objectMap, "noCache", d.NoCache) + populate(objectMap, "target", d.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DockerBuildStepUpdateParameters. +func (d *DockerBuildStepUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "arguments": + err = unpopulate(val, &d.Arguments) + delete(rawMsg, key) + case "dockerFilePath": + err = unpopulate(val, &d.DockerFilePath) + delete(rawMsg, key) + case "imageNames": + err = unpopulate(val, &d.ImageNames) + delete(rawMsg, key) + case "isPushEnabled": + err = unpopulate(val, &d.IsPushEnabled) + delete(rawMsg, key) + case "noCache": + err = unpopulate(val, &d.NoCache) + delete(rawMsg, key) + case "target": + err = unpopulate(val, &d.Target) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return d.TaskStepUpdateParameters.unmarshalInternal(rawMsg) +} + +// EncodedTaskRunRequest - The parameters for a quick task run request. +type EncodedTaskRunRequest struct { + RunRequest + // REQUIRED; Base64 encoded value of the template/definition file content. + EncodedTaskContent *string `json:"encodedTaskContent,omitempty"` + + // REQUIRED; The platform properties against which the run has to happen. + Platform *PlatformProperties `json:"platform,omitempty"` + + // The machine configuration of the run agent. + AgentConfiguration *AgentProperties `json:"agentConfiguration,omitempty"` + + // The properties that describes a set of credentials that will be used when this run is invoked. + Credentials *Credentials `json:"credentials,omitempty"` + + // Base64 encoded value of the parameters/values file content. + EncodedValuesContent *string `json:"encodedValuesContent,omitempty"` + + // The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. If it is relative URL, the relative path should be + // obtained from calling listBuildSourceUploadUrl API. + SourceLocation *string `json:"sourceLocation,omitempty"` + + // Run timeout in seconds. + Timeout *int32 `json:"timeout,omitempty"` + + // The collection of overridable values that can be passed when running a task. + Values []*SetValue `json:"values,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EncodedTaskRunRequest. +func (e EncodedTaskRunRequest) MarshalJSON() ([]byte, error) { + objectMap := e.RunRequest.marshalInternal("EncodedTaskRunRequest") + populate(objectMap, "agentConfiguration", e.AgentConfiguration) + populate(objectMap, "credentials", e.Credentials) + populate(objectMap, "encodedTaskContent", e.EncodedTaskContent) + populate(objectMap, "encodedValuesContent", e.EncodedValuesContent) + populate(objectMap, "platform", e.Platform) + populate(objectMap, "sourceLocation", e.SourceLocation) + populate(objectMap, "timeout", e.Timeout) + populate(objectMap, "values", e.Values) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncodedTaskRunRequest. +func (e *EncodedTaskRunRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "agentConfiguration": + err = unpopulate(val, &e.AgentConfiguration) + delete(rawMsg, key) + case "credentials": + err = unpopulate(val, &e.Credentials) + delete(rawMsg, key) + case "encodedTaskContent": + err = unpopulate(val, &e.EncodedTaskContent) + delete(rawMsg, key) + case "encodedValuesContent": + err = unpopulate(val, &e.EncodedValuesContent) + delete(rawMsg, key) + case "platform": + err = unpopulate(val, &e.Platform) + delete(rawMsg, key) + case "sourceLocation": + err = unpopulate(val, &e.SourceLocation) + delete(rawMsg, key) + case "timeout": + err = unpopulate(val, &e.Timeout) + delete(rawMsg, key) + case "values": + err = unpopulate(val, &e.Values) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return e.RunRequest.unmarshalInternal(rawMsg) +} + +// EncodedTaskStep - The properties of a encoded task step. +type EncodedTaskStep struct { + TaskStepProperties + // REQUIRED; Base64 encoded value of the template/definition file content. + EncodedTaskContent *string `json:"encodedTaskContent,omitempty"` + + // Base64 encoded value of the parameters/values file content. + EncodedValuesContent *string `json:"encodedValuesContent,omitempty"` + + // The collection of overridable values that can be passed when running a task. + Values []*SetValue `json:"values,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EncodedTaskStep. +func (e EncodedTaskStep) MarshalJSON() ([]byte, error) { + objectMap := e.TaskStepProperties.marshalInternal(StepTypeEncodedTask) + populate(objectMap, "encodedTaskContent", e.EncodedTaskContent) + populate(objectMap, "encodedValuesContent", e.EncodedValuesContent) + populate(objectMap, "values", e.Values) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncodedTaskStep. +func (e *EncodedTaskStep) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "encodedTaskContent": + err = unpopulate(val, &e.EncodedTaskContent) + delete(rawMsg, key) + case "encodedValuesContent": + err = unpopulate(val, &e.EncodedValuesContent) + delete(rawMsg, key) + case "values": + err = unpopulate(val, &e.Values) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return e.TaskStepProperties.unmarshalInternal(rawMsg) +} + +// EncodedTaskStepUpdateParameters - The properties for updating encoded task step. +type EncodedTaskStepUpdateParameters struct { + TaskStepUpdateParameters + // Base64 encoded value of the template/definition file content. + EncodedTaskContent *string `json:"encodedTaskContent,omitempty"` + + // Base64 encoded value of the parameters/values file content. + EncodedValuesContent *string `json:"encodedValuesContent,omitempty"` + + // The collection of overridable values that can be passed when running a task. + Values []*SetValue `json:"values,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EncodedTaskStepUpdateParameters. +func (e EncodedTaskStepUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := e.TaskStepUpdateParameters.marshalInternal(StepTypeEncodedTask) + populate(objectMap, "encodedTaskContent", e.EncodedTaskContent) + populate(objectMap, "encodedValuesContent", e.EncodedValuesContent) + populate(objectMap, "values", e.Values) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncodedTaskStepUpdateParameters. +func (e *EncodedTaskStepUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "encodedTaskContent": + err = unpopulate(val, &e.EncodedTaskContent) + delete(rawMsg, key) + case "encodedValuesContent": + err = unpopulate(val, &e.EncodedValuesContent) + delete(rawMsg, key) + case "values": + err = unpopulate(val, &e.Values) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return e.TaskStepUpdateParameters.unmarshalInternal(rawMsg) +} + +type EncryptionProperty struct { + // Key vault properties. + KeyVaultProperties *KeyVaultProperties `json:"keyVaultProperties,omitempty"` + + // Indicates whether or not the encryption is enabled for container registry. + Status *EncryptionStatus `json:"status,omitempty"` +} + +// ErrorResponse - An error response from the Azure Container Registry service. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // Azure container registry build API error body. + InnerError *ErrorResponseBody `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// ErrorResponseBody - An error response from the Azure Container Registry service. +type ErrorResponseBody struct { + // REQUIRED; error code. + Code *string `json:"code,omitempty"` + + // REQUIRED; error message. + Message *string `json:"message,omitempty"` + + // an array of additional nested error response info objects, as described by this contract. + Details *InnerErrorDescription `json:"details,omitempty"` + + // target of the particular error. + Target *string `json:"target,omitempty"` +} + +// Event - The event for a webhook. +type Event struct { + EventInfo + // The event request message sent to the service URI. + EventRequestMessage *EventRequestMessage `json:"eventRequestMessage,omitempty"` + + // The event response message received from the service URI. + EventResponseMessage *EventResponseMessage `json:"eventResponseMessage,omitempty"` +} + +// EventContent - The content of the event request message. +type EventContent struct { + // The action that encompasses the provided event. + Action *string `json:"action,omitempty"` + + // The agent that initiated the event. For most situations, this could be from the authorization context of the request. + Actor *Actor `json:"actor,omitempty"` + + // The event ID. + ID *string `json:"id,omitempty"` + + // The request that generated the event. + Request *Request `json:"request,omitempty"` + + // The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. + Source *Source `json:"source,omitempty"` + + // The target of the event. + Target *Target `json:"target,omitempty"` + + // The time at which the event occurred. + Timestamp *time.Time `json:"timestamp,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EventContent. +func (e EventContent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "action", e.Action) + populate(objectMap, "actor", e.Actor) + populate(objectMap, "id", e.ID) + populate(objectMap, "request", e.Request) + populate(objectMap, "source", e.Source) + populate(objectMap, "target", e.Target) + populate(objectMap, "timestamp", (*timeRFC3339)(e.Timestamp)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventContent. +func (e *EventContent) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, &e.Action) + delete(rawMsg, key) + case "actor": + err = unpopulate(val, &e.Actor) + delete(rawMsg, key) + case "id": + err = unpopulate(val, &e.ID) + delete(rawMsg, key) + case "request": + err = unpopulate(val, &e.Request) + delete(rawMsg, key) + case "source": + err = unpopulate(val, &e.Source) + delete(rawMsg, key) + case "target": + err = unpopulate(val, &e.Target) + delete(rawMsg, key) + case "timestamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + e.Timestamp = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// EventInfo - The basic information of an event. +type EventInfo struct { + // The event ID. + ID *string `json:"id,omitempty"` +} + +// EventListResult - The result of a request to list events for a webhook. +type EventListResult struct { + // The URI that can be used to request the next list of events. + NextLink *string `json:"nextLink,omitempty"` + + // The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. + Value []*Event `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EventListResult. +func (e EventListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// EventRequestMessage - The event request message sent to the service URI. +type EventRequestMessage struct { + // The content of the event request message. + Content *EventContent `json:"content,omitempty"` + + // The headers of the event request message. + Headers map[string]*string `json:"headers,omitempty"` + + // The HTTP method used to send the event request message. + Method *string `json:"method,omitempty"` + + // The URI used to send the event request message. + RequestURI *string `json:"requestUri,omitempty"` + + // The HTTP message version. + Version *string `json:"version,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EventRequestMessage. +func (e EventRequestMessage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "content", e.Content) + populate(objectMap, "headers", e.Headers) + populate(objectMap, "method", e.Method) + populate(objectMap, "requestUri", e.RequestURI) + populate(objectMap, "version", e.Version) + return json.Marshal(objectMap) +} + +// EventResponseMessage - The event response message received from the service URI. +type EventResponseMessage struct { + // The content of the event response message. + Content *string `json:"content,omitempty"` + + // The headers of the event response message. + Headers map[string]*string `json:"headers,omitempty"` + + // The reason phrase of the event response message. + ReasonPhrase *string `json:"reasonPhrase,omitempty"` + + // The status code of the event response message. + StatusCode *string `json:"statusCode,omitempty"` + + // The HTTP message version. + Version *string `json:"version,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EventResponseMessage. +func (e EventResponseMessage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "content", e.Content) + populate(objectMap, "headers", e.Headers) + populate(objectMap, "reasonPhrase", e.ReasonPhrase) + populate(objectMap, "statusCode", e.StatusCode) + populate(objectMap, "version", e.Version) + return json.Marshal(objectMap) +} + +// ExportPipeline - An object that represents an export pipeline for a container registry. +type ExportPipeline struct { + ProxyResource + // The identity of the export pipeline. + Identity *IdentityProperties `json:"identity,omitempty"` + + // The location of the export pipeline. + Location *string `json:"location,omitempty"` + + // The properties of the export pipeline. + Properties *ExportPipelineProperties `json:"properties,omitempty"` +} + +// ExportPipelineListResult - The result of a request to list export pipelines for a container registry. +type ExportPipelineListResult struct { + // The URI that can be used to request the next list of pipeline runs. + NextLink *string `json:"nextLink,omitempty"` + + // The list of export pipelines. Since this list may be incomplete, the nextLink field should be used to request the next list of export pipelines. + Value []*ExportPipeline `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExportPipelineListResult. +func (e ExportPipelineListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// ExportPipelineProperties - The properties of an export pipeline. +type ExportPipelineProperties struct { + // REQUIRED; The target properties of the export pipeline. + Target *ExportPipelineTargetProperties `json:"target,omitempty"` + + // The list of all options configured for the pipeline. + Options []*PipelineOptions `json:"options,omitempty"` + + // READ-ONLY; The provisioning state of the pipeline at the time the operation was called. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExportPipelineProperties. +func (e ExportPipelineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "options", e.Options) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// ExportPipelineTargetProperties - The properties of the export pipeline target. +type ExportPipelineTargetProperties struct { + // REQUIRED; They key vault secret uri to obtain the target storage SAS token. + KeyVaultURI *string `json:"keyVaultUri,omitempty"` + + // The type of target for the export pipeline. + Type *string `json:"type,omitempty"` + + // The target uri of the export pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': + // "https://accountName.blob.core.windows.net/containerName" + URI *string `json:"uri,omitempty"` +} + +// ExportPipelinesBeginCreateOptions contains the optional parameters for the ExportPipelines.BeginCreate method. +type ExportPipelinesBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// ExportPipelinesBeginDeleteOptions contains the optional parameters for the ExportPipelines.BeginDelete method. +type ExportPipelinesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ExportPipelinesGetOptions contains the optional parameters for the ExportPipelines.Get method. +type ExportPipelinesGetOptions struct { + // placeholder for future optional parameters +} + +// ExportPipelinesListOptions contains the optional parameters for the ExportPipelines.List method. +type ExportPipelinesListOptions struct { + // placeholder for future optional parameters +} + +// ExportPolicy - The export policy for a container registry. +type ExportPolicy struct { + // The value that indicates whether the policy is enabled or not. + Status *ExportPolicyStatus `json:"status,omitempty"` +} + +// FileTaskRunRequest - The request parameters for a scheduling run against a task file. +type FileTaskRunRequest struct { + RunRequest + // REQUIRED; The platform properties against which the run has to happen. + Platform *PlatformProperties `json:"platform,omitempty"` + + // REQUIRED; The template/definition file path relative to the source. + TaskFilePath *string `json:"taskFilePath,omitempty"` + + // The machine configuration of the run agent. + AgentConfiguration *AgentProperties `json:"agentConfiguration,omitempty"` + + // The properties that describes a set of credentials that will be used when this run is invoked. + Credentials *Credentials `json:"credentials,omitempty"` + + // The URL(absolute or relative) of the source context. It can be an URL to a tar or git repository. If it is relative URL, the relative path should be + // obtained from calling listBuildSourceUploadUrl API. + SourceLocation *string `json:"sourceLocation,omitempty"` + + // Run timeout in seconds. + Timeout *int32 `json:"timeout,omitempty"` + + // The collection of overridable values that can be passed when running a task. + Values []*SetValue `json:"values,omitempty"` + + // The values/parameters file path relative to the source. + ValuesFilePath *string `json:"valuesFilePath,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type FileTaskRunRequest. +func (f FileTaskRunRequest) MarshalJSON() ([]byte, error) { + objectMap := f.RunRequest.marshalInternal("FileTaskRunRequest") + populate(objectMap, "agentConfiguration", f.AgentConfiguration) + populate(objectMap, "credentials", f.Credentials) + populate(objectMap, "platform", f.Platform) + populate(objectMap, "sourceLocation", f.SourceLocation) + populate(objectMap, "taskFilePath", f.TaskFilePath) + populate(objectMap, "timeout", f.Timeout) + populate(objectMap, "values", f.Values) + populate(objectMap, "valuesFilePath", f.ValuesFilePath) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileTaskRunRequest. +func (f *FileTaskRunRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "agentConfiguration": + err = unpopulate(val, &f.AgentConfiguration) + delete(rawMsg, key) + case "credentials": + err = unpopulate(val, &f.Credentials) + delete(rawMsg, key) + case "platform": + err = unpopulate(val, &f.Platform) + delete(rawMsg, key) + case "sourceLocation": + err = unpopulate(val, &f.SourceLocation) + delete(rawMsg, key) + case "taskFilePath": + err = unpopulate(val, &f.TaskFilePath) + delete(rawMsg, key) + case "timeout": + err = unpopulate(val, &f.Timeout) + delete(rawMsg, key) + case "values": + err = unpopulate(val, &f.Values) + delete(rawMsg, key) + case "valuesFilePath": + err = unpopulate(val, &f.ValuesFilePath) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return f.RunRequest.unmarshalInternal(rawMsg) +} + +// FileTaskStep - The properties of a task step. +type FileTaskStep struct { + TaskStepProperties + // REQUIRED; The task template/definition file path relative to the source context. + TaskFilePath *string `json:"taskFilePath,omitempty"` + + // The collection of overridable values that can be passed when running a task. + Values []*SetValue `json:"values,omitempty"` + + // The task values/parameters file path relative to the source context. + ValuesFilePath *string `json:"valuesFilePath,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type FileTaskStep. +func (f FileTaskStep) MarshalJSON() ([]byte, error) { + objectMap := f.TaskStepProperties.marshalInternal(StepTypeFileTask) + populate(objectMap, "taskFilePath", f.TaskFilePath) + populate(objectMap, "values", f.Values) + populate(objectMap, "valuesFilePath", f.ValuesFilePath) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileTaskStep. +func (f *FileTaskStep) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "taskFilePath": + err = unpopulate(val, &f.TaskFilePath) + delete(rawMsg, key) + case "values": + err = unpopulate(val, &f.Values) + delete(rawMsg, key) + case "valuesFilePath": + err = unpopulate(val, &f.ValuesFilePath) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return f.TaskStepProperties.unmarshalInternal(rawMsg) +} + +// FileTaskStepUpdateParameters - The properties of updating a task step. +type FileTaskStepUpdateParameters struct { + TaskStepUpdateParameters + // The task template/definition file path relative to the source context. + TaskFilePath *string `json:"taskFilePath,omitempty"` + + // The collection of overridable values that can be passed when running a task. + Values []*SetValue `json:"values,omitempty"` + + // The values/parameters file path relative to the source context. + ValuesFilePath *string `json:"valuesFilePath,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type FileTaskStepUpdateParameters. +func (f FileTaskStepUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := f.TaskStepUpdateParameters.marshalInternal(StepTypeFileTask) + populate(objectMap, "taskFilePath", f.TaskFilePath) + populate(objectMap, "values", f.Values) + populate(objectMap, "valuesFilePath", f.ValuesFilePath) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileTaskStepUpdateParameters. +func (f *FileTaskStepUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "taskFilePath": + err = unpopulate(val, &f.TaskFilePath) + delete(rawMsg, key) + case "values": + err = unpopulate(val, &f.Values) + delete(rawMsg, key) + case "valuesFilePath": + err = unpopulate(val, &f.ValuesFilePath) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return f.TaskStepUpdateParameters.unmarshalInternal(rawMsg) +} + +// GenerateCredentialsParameters - The parameters used to generate credentials for a specified token or user of a container registry. +type GenerateCredentialsParameters struct { + // The expiry date of the generated credentials after which the credentials become invalid. + Expiry *time.Time `json:"expiry,omitempty"` + + // Specifies name of the password which should be regenerated if any -- password1 or password2. + Name *TokenPasswordName `json:"name,omitempty"` + + // The resource ID of the token for which credentials have to be generated. + TokenID *string `json:"tokenId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GenerateCredentialsParameters. +func (g GenerateCredentialsParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "expiry", (*timeRFC3339)(g.Expiry)) + populate(objectMap, "name", g.Name) + populate(objectMap, "tokenId", g.TokenID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateCredentialsParameters. +func (g *GenerateCredentialsParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "expiry": + var aux timeRFC3339 + err = unpopulate(val, &aux) + g.Expiry = (*time.Time)(&aux) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &g.Name) + delete(rawMsg, key) + case "tokenId": + err = unpopulate(val, &g.TokenID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// GenerateCredentialsResult - The response from the GenerateCredentials operation. +type GenerateCredentialsResult struct { + // The list of passwords for a container registry. + Passwords []*TokenPassword `json:"passwords,omitempty"` + + // The username for a container registry. + Username *string `json:"username,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GenerateCredentialsResult. +func (g GenerateCredentialsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "passwords", g.Passwords) + populate(objectMap, "username", g.Username) + return json.Marshal(objectMap) +} + +// IPRule - IP rule with specific IP or IP range in CIDR format. +type IPRule struct { + // REQUIRED; Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. + IPAddressOrRange *string `json:"value,omitempty"` + + // The action of IP ACL rule. + Action *Action `json:"action,omitempty"` +} + +// IdentityProperties - Managed identity for the resource. +type IdentityProperties struct { + // The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty"` + + // The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty"` + + // The identity type. + Type *ResourceIdentityType `json:"type,omitempty"` + + // The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + UserAssignedIdentities map[string]*UserIdentityProperties `json:"userAssignedIdentities,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IdentityProperties. +func (i IdentityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + populate(objectMap, "type", i.Type) + populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// ImageDescriptor - Properties for a registry image. +type ImageDescriptor struct { + // The sha256-based digest of the image manifest. + Digest *string `json:"digest,omitempty"` + + // The registry login server. + Registry *string `json:"registry,omitempty"` + + // The repository name. + Repository *string `json:"repository,omitempty"` + + // The tag name. + Tag *string `json:"tag,omitempty"` +} + +// ImageUpdateTrigger - The image update trigger that caused a build. +type ImageUpdateTrigger struct { + // The unique ID of the trigger. + ID *string `json:"id,omitempty"` + + // The list of image updates that caused the build. + Images []*ImageDescriptor `json:"images,omitempty"` + + // The timestamp when the image update happened. + Timestamp *time.Time `json:"timestamp,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ImageUpdateTrigger. +func (i ImageUpdateTrigger) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", i.ID) + populate(objectMap, "images", i.Images) + populate(objectMap, "timestamp", (*timeRFC3339)(i.Timestamp)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageUpdateTrigger. +func (i *ImageUpdateTrigger) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, &i.ID) + delete(rawMsg, key) + case "images": + err = unpopulate(val, &i.Images) + delete(rawMsg, key) + case "timestamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + i.Timestamp = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +type ImportImageParameters struct { + // REQUIRED; The source of the image. + Source *ImportSource `json:"source,omitempty"` + + // When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation before any copying begins. + Mode *ImportMode `json:"mode,omitempty"` + + // List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). + TargetTags []*string `json:"targetTags,omitempty"` + + // List of strings of repository names to do a manifest only copy. No tag will be created. + UntaggedTargetRepositories []*string `json:"untaggedTargetRepositories,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ImportImageParameters. +func (i ImportImageParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "mode", i.Mode) + populate(objectMap, "source", i.Source) + populate(objectMap, "targetTags", i.TargetTags) + populate(objectMap, "untaggedTargetRepositories", i.UntaggedTargetRepositories) + return json.Marshal(objectMap) +} + +// ImportPipeline - An object that represents an import pipeline for a container registry. +type ImportPipeline struct { + ProxyResource + // The identity of the import pipeline. + Identity *IdentityProperties `json:"identity,omitempty"` + + // The location of the import pipeline. + Location *string `json:"location,omitempty"` + + // The properties of the import pipeline. + Properties *ImportPipelineProperties `json:"properties,omitempty"` +} + +// ImportPipelineListResult - The result of a request to list import pipelines for a container registry. +type ImportPipelineListResult struct { + // The URI that can be used to request the next list of pipeline runs. + NextLink *string `json:"nextLink,omitempty"` + + // The list of import pipelines. Since this list may be incomplete, the nextLink field should be used to request the next list of import pipelines. + Value []*ImportPipeline `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ImportPipelineListResult. +func (i ImportPipelineListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// ImportPipelineProperties - The properties of an import pipeline. +type ImportPipelineProperties struct { + // REQUIRED; The source properties of the import pipeline. + Source *ImportPipelineSourceProperties `json:"source,omitempty"` + + // The list of all options configured for the pipeline. + Options []*PipelineOptions `json:"options,omitempty"` + + // The properties that describe the trigger of the import pipeline. + Trigger *PipelineTriggerProperties `json:"trigger,omitempty"` + + // READ-ONLY; The provisioning state of the pipeline at the time the operation was called. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ImportPipelineProperties. +func (i ImportPipelineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "options", i.Options) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "source", i.Source) + populate(objectMap, "trigger", i.Trigger) + return json.Marshal(objectMap) +} + +// ImportPipelineSourceProperties - The properties of the import pipeline source. +type ImportPipelineSourceProperties struct { + // REQUIRED; They key vault secret uri to obtain the source storage SAS token. + KeyVaultURI *string `json:"keyVaultUri,omitempty"` + + // The type of source for the import pipeline. + Type *PipelineSourceType `json:"type,omitempty"` + + // The source uri of the import pipeline. When 'AzureStorageBlob': "https://accountName.blob.core.windows.net/containerName/blobName" When 'AzureStorageBlobContainer': + // "https://accountName.blob.core.windows.net/containerName" + URI *string `json:"uri,omitempty"` +} + +// ImportPipelinesBeginCreateOptions contains the optional parameters for the ImportPipelines.BeginCreate method. +type ImportPipelinesBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// ImportPipelinesBeginDeleteOptions contains the optional parameters for the ImportPipelines.BeginDelete method. +type ImportPipelinesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ImportPipelinesGetOptions contains the optional parameters for the ImportPipelines.Get method. +type ImportPipelinesGetOptions struct { + // placeholder for future optional parameters +} + +// ImportPipelinesListOptions contains the optional parameters for the ImportPipelines.List method. +type ImportPipelinesListOptions struct { + // placeholder for future optional parameters +} + +type ImportSource struct { + // REQUIRED; Repository name of the source image. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an image by tag + // ('hello-world:latest'). Specify an image by sha256-based + // manifest digest ('hello-world@sha256:abc123'). + SourceImage *string `json:"sourceImage,omitempty"` + + // Credentials used when importing from a registry uri. + Credentials *ImportSourceCredentials `json:"credentials,omitempty"` + + // The address of the source registry (e.g. 'mcr.microsoft.com'). + RegistryURI *string `json:"registryUri,omitempty"` + + // The resource identifier of the source Azure Container Registry. + ResourceID *string `json:"resourceId,omitempty"` +} + +type ImportSourceCredentials struct { + // REQUIRED; The password used to authenticate with the source registry. + Password *string `json:"password,omitempty"` + + // The username to authenticate with the source registry. + Username *string `json:"username,omitempty"` +} + +// InnerErrorDescription - inner error. +type InnerErrorDescription struct { + // REQUIRED; error code. + Code *string `json:"code,omitempty"` + + // REQUIRED; error message. + Message *string `json:"message,omitempty"` + + // target of the particular error. + Target *string `json:"target,omitempty"` +} + +type KeyVaultProperties struct { + // The client id of the identity which will be used to access key vault. + Identity *string `json:"identity,omitempty"` + + // Key vault uri to access the encryption key. + KeyIdentifier *string `json:"keyIdentifier,omitempty"` + + // READ-ONLY; Auto key rotation status for a CMK enabled registry. + KeyRotationEnabled *bool `json:"keyRotationEnabled,omitempty" azure:"ro"` + + // READ-ONLY; Timestamp of the last successful key rotation. + LastKeyRotationTimestamp *time.Time `json:"lastKeyRotationTimestamp,omitempty" azure:"ro"` + + // READ-ONLY; The fully qualified key identifier that includes the version of the key that is actually used for encryption. + VersionedKeyIdentifier *string `json:"versionedKeyIdentifier,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultProperties. +func (k KeyVaultProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", k.Identity) + populate(objectMap, "keyIdentifier", k.KeyIdentifier) + populate(objectMap, "keyRotationEnabled", k.KeyRotationEnabled) + populate(objectMap, "lastKeyRotationTimestamp", (*timeRFC3339)(k.LastKeyRotationTimestamp)) + populate(objectMap, "versionedKeyIdentifier", k.VersionedKeyIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultProperties. +func (k *KeyVaultProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, &k.Identity) + delete(rawMsg, key) + case "keyIdentifier": + err = unpopulate(val, &k.KeyIdentifier) + delete(rawMsg, key) + case "keyRotationEnabled": + err = unpopulate(val, &k.KeyRotationEnabled) + delete(rawMsg, key) + case "lastKeyRotationTimestamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + k.LastKeyRotationTimestamp = (*time.Time)(&aux) + delete(rawMsg, key) + case "versionedKeyIdentifier": + err = unpopulate(val, &k.VersionedKeyIdentifier) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// LoggingProperties - The logging properties of the connected registry. +type LoggingProperties struct { + // Indicates whether audit logs are enabled on the connected registry. + AuditLogStatus *AuditLogStatus `json:"auditLogStatus,omitempty"` + + // The verbosity of logs persisted on the connected registry. + LogLevel *LogLevel `json:"logLevel,omitempty"` +} + +// LoginServerProperties - The login server properties of the connected registry. +type LoginServerProperties struct { + // READ-ONLY; The host of the connected registry. Can be FQDN or IP. + Host *string `json:"host,omitempty" azure:"ro"` + + // READ-ONLY; The TLS properties of the connected registry login server. + TLS *TLSProperties `json:"tls,omitempty" azure:"ro"` +} + +// NetworkRuleSet - The network rule set for a container registry. +type NetworkRuleSet struct { + // REQUIRED; The default action of allow or deny when no other rules match. + DefaultAction *DefaultAction `json:"defaultAction,omitempty"` + + // The IP ACL rules. + IPRules []*IPRule `json:"ipRules,omitempty"` + + // The virtual network rules. + VirtualNetworkRules []*VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkRuleSet. +func (n NetworkRuleSet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "defaultAction", n.DefaultAction) + populate(objectMap, "ipRules", n.IPRules) + populate(objectMap, "virtualNetworkRules", n.VirtualNetworkRules) + return json.Marshal(objectMap) +} + +// OperationDefinition - The definition of a container registry operation. +type OperationDefinition struct { + // The display information for the container registry operation. + Display *OperationDisplayDefinition `json:"display,omitempty"` + + // This property indicates if the operation is an action or a data action ref: https://docs.microsoft.com/en-us/azure/role-based-access-control/role-definitions#management-and-data-operations + IsDataAction *bool `json:"isDataAction,omitempty"` + + // Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + + // The origin information of the container registry operation. + Origin *string `json:"origin,omitempty"` + + // The properties information for the container registry operation. + Properties *OperationPropertiesDefinition `json:"properties,omitempty"` +} + +// OperationDisplayDefinition - The display information for a container registry operation. +type OperationDisplayDefinition struct { + // The description for the operation. + Description *string `json:"description,omitempty"` + + // The operation that users can perform. + Operation *string `json:"operation,omitempty"` + + // The resource provider name: Microsoft.ContainerRegistry. + Provider *string `json:"provider,omitempty"` + + // The resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` +} + +// OperationListResult - The result of a request to list container registry operations. +type OperationListResult struct { + // The URI that can be used to request the next list of container registry operations. + NextLink *string `json:"nextLink,omitempty"` + + // The list of container registry operations. Since this list may be incomplete, the nextLink field should be used to request the next list of operations. + Value []*OperationDefinition `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationLogSpecificationDefinition - The definition of Azure Monitoring log. +type OperationLogSpecificationDefinition struct { + // Log blob duration. + BlobDuration *string `json:"blobDuration,omitempty"` + + // Log display name. + DisplayName *string `json:"displayName,omitempty"` + + // Log name. + Name *string `json:"name,omitempty"` +} + +// OperationMetricSpecificationDefinition - The definition of Azure Monitoring metric. +type OperationMetricSpecificationDefinition struct { + // Metric aggregation type. + AggregationType *string `json:"aggregationType,omitempty"` + + // Metric description. + DisplayDescription *string `json:"displayDescription,omitempty"` + + // Metric display name. + DisplayName *string `json:"displayName,omitempty"` + + // Internal metric name. + InternalMetricName *string `json:"internalMetricName,omitempty"` + + // Metric name. + Name *string `json:"name,omitempty"` + + // Metric unit. + Unit *string `json:"unit,omitempty"` +} + +// OperationPropertiesDefinition - The definition of Azure Monitoring properties. +type OperationPropertiesDefinition struct { + // The definition of Azure Monitoring service. + ServiceSpecification *OperationServiceSpecificationDefinition `json:"serviceSpecification,omitempty"` +} + +// OperationServiceSpecificationDefinition - The definition of Azure Monitoring list. +type OperationServiceSpecificationDefinition struct { + // A list of Azure Monitoring log definitions. + LogSpecifications []*OperationLogSpecificationDefinition `json:"logSpecifications,omitempty"` + + // A list of Azure Monitoring metrics definition. + MetricSpecifications []*OperationMetricSpecificationDefinition `json:"metricSpecifications,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationServiceSpecificationDefinition. +func (o OperationServiceSpecificationDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "logSpecifications", o.LogSpecifications) + populate(objectMap, "metricSpecifications", o.MetricSpecifications) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +type OverrideTaskStepProperties struct { + // Gets or sets the collection of override arguments to be used when executing a build step. + Arguments []*Argument `json:"arguments,omitempty"` + + // The source context against which run has to be queued. + ContextPath *string `json:"contextPath,omitempty"` + + // The file against which run has to be queued. + File *string `json:"file,omitempty"` + + // The name of the target build stage for the docker build. + Target *string `json:"target,omitempty"` + + // Base64 encoded update trigger token that will be attached with the base image trigger webhook. + UpdateTriggerToken *string `json:"updateTriggerToken,omitempty"` + + // The collection of overridable values that can be passed when running a Task. + Values []*SetValue `json:"values,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OverrideTaskStepProperties. +func (o OverrideTaskStepProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "arguments", o.Arguments) + populate(objectMap, "contextPath", o.ContextPath) + populate(objectMap, "file", o.File) + populate(objectMap, "target", o.Target) + populate(objectMap, "updateTriggerToken", o.UpdateTriggerToken) + populate(objectMap, "values", o.Values) + return json.Marshal(objectMap) +} + +// ParentProperties - The properties of the connected registry parent. +type ParentProperties struct { + // REQUIRED; The sync properties of the connected registry with its parent. + SyncProperties *SyncProperties `json:"syncProperties,omitempty"` + + // The resource ID of the parent to which the connected registry will be associated. + ID *string `json:"id,omitempty"` +} + +// PipelineRun - An object that represents a pipeline run for a container registry. +type PipelineRun struct { + ProxyResource + // The properties of a pipeline run. + Properties *PipelineRunProperties `json:"properties,omitempty"` +} + +// PipelineRunListResult - The result of a request to list pipeline runs for a container registry. +type PipelineRunListResult struct { + // The URI that can be used to request the next list of pipeline runs. + NextLink *string `json:"nextLink,omitempty"` + + // The list of pipeline runs. Since this list may be incomplete, the nextLink field should be used to request the next list of pipeline runs. + Value []*PipelineRun `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineRunListResult. +func (p PipelineRunListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PipelineRunProperties - The properties of a pipeline run. +type PipelineRunProperties struct { + // How the pipeline run should be forced to recreate even if the pipeline run configuration has not changed. + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + + // The request parameters for a pipeline run. + Request *PipelineRunRequest `json:"request,omitempty"` + + // READ-ONLY; The provisioning state of a pipeline run. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The response of a pipeline run. + Response *PipelineRunResponse `json:"response,omitempty" azure:"ro"` +} + +// PipelineRunRequest - The request properties provided for a pipeline run. +type PipelineRunRequest struct { + // List of source artifacts to be transferred by the pipeline. Specify an image by repository ('hello-world'). This will use the 'latest' tag. Specify an + // image by tag ('hello-world:latest'). Specify an + // image by sha256-based manifest digest ('hello-world@sha256:abc123'). + Artifacts []*string `json:"artifacts,omitempty"` + + // The digest of the tar used to transfer the artifacts. + CatalogDigest *string `json:"catalogDigest,omitempty"` + + // The resource ID of the pipeline to run. + PipelineResourceID *string `json:"pipelineResourceId,omitempty"` + + // The source properties of the pipeline run. + Source *PipelineRunSourceProperties `json:"source,omitempty"` + + // The target properties of the pipeline run. + Target *PipelineRunTargetProperties `json:"target,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineRunRequest. +func (p PipelineRunRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "artifacts", p.Artifacts) + populate(objectMap, "catalogDigest", p.CatalogDigest) + populate(objectMap, "pipelineResourceId", p.PipelineResourceID) + populate(objectMap, "source", p.Source) + populate(objectMap, "target", p.Target) + return json.Marshal(objectMap) +} + +// PipelineRunResponse - The response properties returned for a pipeline run. +type PipelineRunResponse struct { + // The digest of the tar used to transfer the artifacts. + CatalogDigest *string `json:"catalogDigest,omitempty"` + + // The time the pipeline run finished. + FinishTime *time.Time `json:"finishTime,omitempty"` + + // The artifacts imported in the pipeline run. + ImportedArtifacts []*string `json:"importedArtifacts,omitempty"` + + // The detailed error message for the pipeline run in the case of failure. + PipelineRunErrorMessage *string `json:"pipelineRunErrorMessage,omitempty"` + + // The current progress of the copy operation. + Progress *ProgressProperties `json:"progress,omitempty"` + + // The source of the pipeline run. + Source *ImportPipelineSourceProperties `json:"source,omitempty"` + + // The time the pipeline run started. + StartTime *time.Time `json:"startTime,omitempty"` + + // The current status of the pipeline run. + Status *string `json:"status,omitempty"` + + // The target of the pipeline run. + Target *ExportPipelineTargetProperties `json:"target,omitempty"` + + // The trigger that caused the pipeline run. + Trigger *PipelineTriggerDescriptor `json:"trigger,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineRunResponse. +func (p PipelineRunResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "catalogDigest", p.CatalogDigest) + populate(objectMap, "finishTime", (*timeRFC3339)(p.FinishTime)) + populate(objectMap, "importedArtifacts", p.ImportedArtifacts) + populate(objectMap, "pipelineRunErrorMessage", p.PipelineRunErrorMessage) + populate(objectMap, "progress", p.Progress) + populate(objectMap, "source", p.Source) + populate(objectMap, "startTime", (*timeRFC3339)(p.StartTime)) + populate(objectMap, "status", p.Status) + populate(objectMap, "target", p.Target) + populate(objectMap, "trigger", p.Trigger) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineRunResponse. +func (p *PipelineRunResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "catalogDigest": + err = unpopulate(val, &p.CatalogDigest) + delete(rawMsg, key) + case "finishTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + p.FinishTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "importedArtifacts": + err = unpopulate(val, &p.ImportedArtifacts) + delete(rawMsg, key) + case "pipelineRunErrorMessage": + err = unpopulate(val, &p.PipelineRunErrorMessage) + delete(rawMsg, key) + case "progress": + err = unpopulate(val, &p.Progress) + delete(rawMsg, key) + case "source": + err = unpopulate(val, &p.Source) + delete(rawMsg, key) + case "startTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + p.StartTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &p.Status) + delete(rawMsg, key) + case "target": + err = unpopulate(val, &p.Target) + delete(rawMsg, key) + case "trigger": + err = unpopulate(val, &p.Trigger) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +type PipelineRunSourceProperties struct { + // The name of the source. + Name *string `json:"name,omitempty"` + + // The type of the source. + Type *PipelineRunSourceType `json:"type,omitempty"` +} + +type PipelineRunTargetProperties struct { + // The name of the target. + Name *string `json:"name,omitempty"` + + // The type of the target. + Type *PipelineRunTargetType `json:"type,omitempty"` +} + +// PipelineRunsBeginCreateOptions contains the optional parameters for the PipelineRuns.BeginCreate method. +type PipelineRunsBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// PipelineRunsBeginDeleteOptions contains the optional parameters for the PipelineRuns.BeginDelete method. +type PipelineRunsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// PipelineRunsGetOptions contains the optional parameters for the PipelineRuns.Get method. +type PipelineRunsGetOptions struct { + // placeholder for future optional parameters +} + +// PipelineRunsListOptions contains the optional parameters for the PipelineRuns.List method. +type PipelineRunsListOptions struct { + // placeholder for future optional parameters +} + +type PipelineSourceTriggerDescriptor struct { + // The timestamp when the source update happened. + Timestamp *time.Time `json:"timestamp,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PipelineSourceTriggerDescriptor. +func (p PipelineSourceTriggerDescriptor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "timestamp", (*timeRFC3339)(p.Timestamp)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineSourceTriggerDescriptor. +func (p *PipelineSourceTriggerDescriptor) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "timestamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + p.Timestamp = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +type PipelineSourceTriggerProperties struct { + // REQUIRED; The current status of the source trigger. + Status *TriggerStatus `json:"status,omitempty"` +} + +type PipelineTriggerDescriptor struct { + // The source trigger that caused the pipeline run. + SourceTrigger *PipelineSourceTriggerDescriptor `json:"sourceTrigger,omitempty"` +} + +type PipelineTriggerProperties struct { + // The source trigger properties of the pipeline. + SourceTrigger *PipelineSourceTriggerProperties `json:"sourceTrigger,omitempty"` +} + +// PlatformProperties - The platform properties against which the run has to happen. +type PlatformProperties struct { + // REQUIRED; The operating system type required for the run. + OS *OS `json:"os,omitempty"` + + // The OS architecture. + Architecture *Architecture `json:"architecture,omitempty"` + + // Variant of the CPU. + Variant *Variant `json:"variant,omitempty"` +} + +// PlatformUpdateParameters - The properties for updating the platform configuration. +type PlatformUpdateParameters struct { + // The OS architecture. + Architecture *Architecture `json:"architecture,omitempty"` + + // The operating system type required for the run. + OS *OS `json:"os,omitempty"` + + // Variant of the CPU. + Variant *Variant `json:"variant,omitempty"` +} + +// Policies - The policies for a container registry. +type Policies struct { + // The export policy for a container registry. + ExportPolicy *ExportPolicy `json:"exportPolicy,omitempty"` + + // The quarantine policy for a container registry. + QuarantinePolicy *QuarantinePolicy `json:"quarantinePolicy,omitempty"` + + // The retention policy for a container registry. + RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"` + + // The content trust policy for a container registry. + TrustPolicy *TrustPolicy `json:"trustPolicy,omitempty"` +} + +// PrivateEndpoint - The Private Endpoint resource. +type PrivateEndpoint struct { + // This is private endpoint resource created with Microsoft.Network resource provider. + ID *string `json:"id,omitempty"` +} + +// PrivateEndpointConnection - An object that represents a private endpoint connection for a container registry. +type PrivateEndpointConnection struct { + ProxyResource + // The properties of a private endpoint connection. + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// PrivateEndpointConnectionListResult - The result of a request to list private endpoint connections for a container registry. +type PrivateEndpointConnectionListResult struct { + // The URI that can be used to request the next list of private endpoint connections. + NextLink *string `json:"nextLink,omitempty"` + + // The list of private endpoint connections. Since this list may be incomplete, the nextLink field should be used to request the next list of private endpoint + // connections. + Value []*PrivateEndpointConnection `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionListResult. +func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionProperties - The properties of a private endpoint connection. +type PrivateEndpointConnectionProperties struct { + // The resource of private endpoint. + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + + // A collection of information about the state of the connection between service consumer and provider. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + + // READ-ONLY; The provisioning state of private endpoint connection resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// PrivateEndpointConnectionsBeginCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnections.BeginCreateOrUpdate method. +type PrivateEndpointConnectionsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsBeginDeleteOptions contains the optional parameters for the PrivateEndpointConnections.BeginDelete method. +type PrivateEndpointConnectionsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsGetOptions contains the optional parameters for the PrivateEndpointConnections.Get method. +type PrivateEndpointConnectionsGetOptions struct { + // placeholder for future optional parameters +} + +// PrivateEndpointConnectionsListOptions contains the optional parameters for the PrivateEndpointConnections.List method. +type PrivateEndpointConnectionsListOptions struct { + // placeholder for future optional parameters +} + +// PrivateLinkResource - A resource that supports private link capabilities. +type PrivateLinkResource struct { + // The resource ID. + ID *string `json:"id,omitempty"` + + // The name of the resource. + Name *string `json:"name,omitempty"` + + // A resource that supports private link capabilities. + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + + // READ-ONLY; The resource type is private link resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// PrivateLinkResourceListResult - The result of a request to list private link resources for a container registry. +type PrivateLinkResourceListResult struct { + // The URI that can be used to request the next list of private link resources. + NextLink *string `json:"nextLink,omitempty"` + + // The list of private link resources. Since this list may be incomplete, the nextLink field should be used to request the next list of private link resources. + Value []*PrivateLinkResource `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. +func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PrivateLinkResourceProperties - The properties of a private link resource. +type PrivateLinkResourceProperties struct { + // The private link resource group id. + GroupID *string `json:"groupId,omitempty"` + + // The private link resource required member names. + RequiredMembers []*string `json:"requiredMembers,omitempty"` + + // The private link resource Private link DNS zone name. + RequiredZoneNames []*string `json:"requiredZoneNames,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. +func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "groupId", p.GroupID) + populate(objectMap, "requiredMembers", p.RequiredMembers) + populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) + return json.Marshal(objectMap) +} + +// PrivateLinkServiceConnectionState - The state of a private link service connection. +type PrivateLinkServiceConnectionState struct { + // A message indicating if changes on the service provider require any updates on the consumer. + ActionsRequired *ActionsRequired `json:"actionsRequired,omitempty"` + + // The description for connection status. For example if connection is rejected it can indicate reason for rejection. + Description *string `json:"description,omitempty"` + + // The private link service connection status. + Status *ConnectionStatus `json:"status,omitempty"` +} + +type ProgressProperties struct { + // The percentage complete of the copy operation. + Percentage *string `json:"percentage,omitempty"` +} + +// ProxyResource - The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. +type ProxyResource struct { + // READ-ONLY; The resource ID. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// QuarantinePolicy - The quarantine policy for a container registry. +type QuarantinePolicy struct { + // The value that indicates whether the policy is enabled or not. + Status *PolicyStatus `json:"status,omitempty"` +} + +// RegenerateCredentialParameters - The parameters used to regenerate the login credential. +type RegenerateCredentialParameters struct { + // REQUIRED; Specifies name of the password which should be regenerated -- password or password2. + Name *PasswordName `json:"name,omitempty"` +} + +// RegistriesBeginCreateOptions contains the optional parameters for the Registries.BeginCreate method. +type RegistriesBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// RegistriesBeginDeleteOptions contains the optional parameters for the Registries.BeginDelete method. +type RegistriesBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// RegistriesBeginGenerateCredentialsOptions contains the optional parameters for the Registries.BeginGenerateCredentials method. +type RegistriesBeginGenerateCredentialsOptions struct { + // placeholder for future optional parameters +} + +// RegistriesBeginImportImageOptions contains the optional parameters for the Registries.BeginImportImage method. +type RegistriesBeginImportImageOptions struct { + // placeholder for future optional parameters +} + +// RegistriesBeginScheduleRunOptions contains the optional parameters for the Registries.BeginScheduleRun method. +type RegistriesBeginScheduleRunOptions struct { + // placeholder for future optional parameters +} + +// RegistriesBeginUpdateOptions contains the optional parameters for the Registries.BeginUpdate method. +type RegistriesBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// RegistriesCheckNameAvailabilityOptions contains the optional parameters for the Registries.CheckNameAvailability method. +type RegistriesCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// RegistriesGetBuildSourceUploadURLOptions contains the optional parameters for the Registries.GetBuildSourceUploadURL method. +type RegistriesGetBuildSourceUploadURLOptions struct { + // placeholder for future optional parameters +} + +// RegistriesGetOptions contains the optional parameters for the Registries.Get method. +type RegistriesGetOptions struct { + // placeholder for future optional parameters +} + +// RegistriesListByResourceGroupOptions contains the optional parameters for the Registries.ListByResourceGroup method. +type RegistriesListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// RegistriesListCredentialsOptions contains the optional parameters for the Registries.ListCredentials method. +type RegistriesListCredentialsOptions struct { + // placeholder for future optional parameters +} + +// RegistriesListOptions contains the optional parameters for the Registries.List method. +type RegistriesListOptions struct { + // placeholder for future optional parameters +} + +// RegistriesListPrivateLinkResourcesOptions contains the optional parameters for the Registries.ListPrivateLinkResources method. +type RegistriesListPrivateLinkResourcesOptions struct { + // placeholder for future optional parameters +} + +// RegistriesListUsagesOptions contains the optional parameters for the Registries.ListUsages method. +type RegistriesListUsagesOptions struct { + // placeholder for future optional parameters +} + +// RegistriesRegenerateCredentialOptions contains the optional parameters for the Registries.RegenerateCredential method. +type RegistriesRegenerateCredentialOptions struct { + // placeholder for future optional parameters +} + +// Registry - An object that represents a container registry. +type Registry struct { + Resource + // REQUIRED; The SKU of the container registry. + SKU *SKU `json:"sku,omitempty"` + + // The identity of the container registry. + Identity *IdentityProperties `json:"identity,omitempty"` + + // The properties of the container registry. + Properties *RegistryProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Registry. +func (r Registry) MarshalJSON() ([]byte, error) { + objectMap := r.Resource.marshalInternal() + populate(objectMap, "identity", r.Identity) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "sku", r.SKU) + return json.Marshal(objectMap) +} + +// RegistryListCredentialsResult - The response from the ListCredentials operation. +type RegistryListCredentialsResult struct { + // The list of passwords for a container registry. + Passwords []*RegistryPassword `json:"passwords,omitempty"` + + // The username for a container registry. + Username *string `json:"username,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RegistryListCredentialsResult. +func (r RegistryListCredentialsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "passwords", r.Passwords) + populate(objectMap, "username", r.Username) + return json.Marshal(objectMap) +} + +// RegistryListResult - The result of a request to list container registries. +type RegistryListResult struct { + // The URI that can be used to request the next list of container registries. + NextLink *string `json:"nextLink,omitempty"` + + // The list of container registries. Since this list may be incomplete, the nextLink field should be used to request the next list of container registries. + Value []*Registry `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RegistryListResult. +func (r RegistryListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RegistryNameCheckRequest - A request to check whether a container registry name is available. +type RegistryNameCheckRequest struct { + // REQUIRED; The name of the container registry. + Name *string `json:"name,omitempty"` + + // REQUIRED; The resource type of the container registry. This field must be set to 'Microsoft.ContainerRegistry/registries'. + Type *string `json:"type,omitempty"` +} + +// RegistryNameStatus - The result of a request to check the availability of a container registry name. +type RegistryNameStatus struct { + // If any, the error message that provides more detail for the reason that the name is not available. + Message *string `json:"message,omitempty"` + + // The value that indicates whether the name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + + // If any, the reason that the name is not available. + Reason *string `json:"reason,omitempty"` +} + +// RegistryPassword - The login password for the container registry. +type RegistryPassword struct { + // The password name. + Name *PasswordName `json:"name,omitempty"` + + // The password value. + Value *string `json:"value,omitempty"` +} + +// RegistryProperties - The properties of a container registry. +type RegistryProperties struct { + // The value that indicates whether the admin user is enabled. + AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` + + // Enables registry-wide pull from unauthenticated clients. + AnonymousPullEnabled *bool `json:"anonymousPullEnabled,omitempty"` + + // Enable a single data endpoint per region for serving data. + DataEndpointEnabled *bool `json:"dataEndpointEnabled,omitempty"` + + // The encryption settings of container registry. + Encryption *EncryptionProperty `json:"encryption,omitempty"` + + // Whether to allow trusted Azure services to access a network restricted registry. + NetworkRuleBypassOptions *NetworkRuleBypassOptions `json:"networkRuleBypassOptions,omitempty"` + + // The network rule set for a container registry. + NetworkRuleSet *NetworkRuleSet `json:"networkRuleSet,omitempty"` + + // The policies for a container registry. + Policies *Policies `json:"policies,omitempty"` + + // Whether or not public network access is allowed for the container registry. + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + + // Whether or not zone redundancy is enabled for this container registry + ZoneRedundancy *ZoneRedundancy `json:"zoneRedundancy,omitempty"` + + // READ-ONLY; The creation date of the container registry in ISO8601 format. + CreationDate *time.Time `json:"creationDate,omitempty" azure:"ro"` + + // READ-ONLY; List of host names that will serve data when dataEndpointEnabled is true. + DataEndpointHostNames []*string `json:"dataEndpointHostNames,omitempty" azure:"ro"` + + // READ-ONLY; The URL that can be used to log into the container registry. + LoginServer *string `json:"loginServer,omitempty" azure:"ro"` + + // READ-ONLY; List of private endpoint connections for a container registry. + PrivateEndpointConnections []*PrivateEndpointConnection `json:"privateEndpointConnections,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the container registry at the time the operation was called. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The status of the container registry at the time the operation was called. + Status *Status `json:"status,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RegistryProperties. +func (r RegistryProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "adminUserEnabled", r.AdminUserEnabled) + populate(objectMap, "anonymousPullEnabled", r.AnonymousPullEnabled) + populate(objectMap, "creationDate", (*timeRFC3339)(r.CreationDate)) + populate(objectMap, "dataEndpointEnabled", r.DataEndpointEnabled) + populate(objectMap, "dataEndpointHostNames", r.DataEndpointHostNames) + populate(objectMap, "encryption", r.Encryption) + populate(objectMap, "loginServer", r.LoginServer) + populate(objectMap, "networkRuleBypassOptions", r.NetworkRuleBypassOptions) + populate(objectMap, "networkRuleSet", r.NetworkRuleSet) + populate(objectMap, "policies", r.Policies) + populate(objectMap, "privateEndpointConnections", r.PrivateEndpointConnections) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "publicNetworkAccess", r.PublicNetworkAccess) + populate(objectMap, "status", r.Status) + populate(objectMap, "zoneRedundancy", r.ZoneRedundancy) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RegistryProperties. +func (r *RegistryProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "adminUserEnabled": + err = unpopulate(val, &r.AdminUserEnabled) + delete(rawMsg, key) + case "anonymousPullEnabled": + err = unpopulate(val, &r.AnonymousPullEnabled) + delete(rawMsg, key) + case "creationDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + r.CreationDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "dataEndpointEnabled": + err = unpopulate(val, &r.DataEndpointEnabled) + delete(rawMsg, key) + case "dataEndpointHostNames": + err = unpopulate(val, &r.DataEndpointHostNames) + delete(rawMsg, key) + case "encryption": + err = unpopulate(val, &r.Encryption) + delete(rawMsg, key) + case "loginServer": + err = unpopulate(val, &r.LoginServer) + delete(rawMsg, key) + case "networkRuleBypassOptions": + err = unpopulate(val, &r.NetworkRuleBypassOptions) + delete(rawMsg, key) + case "networkRuleSet": + err = unpopulate(val, &r.NetworkRuleSet) + delete(rawMsg, key) + case "policies": + err = unpopulate(val, &r.Policies) + delete(rawMsg, key) + case "privateEndpointConnections": + err = unpopulate(val, &r.PrivateEndpointConnections) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &r.ProvisioningState) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, &r.PublicNetworkAccess) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &r.Status) + delete(rawMsg, key) + case "zoneRedundancy": + err = unpopulate(val, &r.ZoneRedundancy) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// RegistryPropertiesUpdateParameters - The parameters for updating the properties of a container registry. +type RegistryPropertiesUpdateParameters struct { + // The value that indicates whether the admin user is enabled. + AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` + + // Enables registry-wide pull from unauthenticated clients. + AnonymousPullEnabled *bool `json:"anonymousPullEnabled,omitempty"` + + // Enable a single data endpoint per region for serving data. + DataEndpointEnabled *bool `json:"dataEndpointEnabled,omitempty"` + + // The encryption settings of container registry. + Encryption *EncryptionProperty `json:"encryption,omitempty"` + + // Whether to allow trusted Azure services to access a network restricted registry. + NetworkRuleBypassOptions *NetworkRuleBypassOptions `json:"networkRuleBypassOptions,omitempty"` + + // The network rule set for a container registry. + NetworkRuleSet *NetworkRuleSet `json:"networkRuleSet,omitempty"` + + // The policies for a container registry. + Policies *Policies `json:"policies,omitempty"` + + // Whether or not public network access is allowed for the container registry. + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// RegistryUpdateParameters - The parameters for updating a container registry. +type RegistryUpdateParameters struct { + // The identity of the container registry. + Identity *IdentityProperties `json:"identity,omitempty"` + + // The properties that the container registry will be updated with. + Properties *RegistryPropertiesUpdateParameters `json:"properties,omitempty"` + + // The SKU of the container registry. + SKU *SKU `json:"sku,omitempty"` + + // The tags for the container registry. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RegistryUpdateParameters. +func (r RegistryUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", r.Identity) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "sku", r.SKU) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +// RegistryUsage - The quota usage for a container registry. +type RegistryUsage struct { + // The current value of the usage. + CurrentValue *int64 `json:"currentValue,omitempty"` + + // The limit of the usage. + Limit *int64 `json:"limit,omitempty"` + + // The name of the usage. + Name *string `json:"name,omitempty"` + + // The unit of measurement. + Unit *RegistryUsageUnit `json:"unit,omitempty"` +} + +// RegistryUsageListResult - The result of a request to get container registry quota usages. +type RegistryUsageListResult struct { + // The list of container registry quota usages. + Value []*RegistryUsage `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RegistryUsageListResult. +func (r RegistryUsageListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// Replication - An object that represents a replication for a container registry. +type Replication struct { + Resource + // The properties of the replication. + Properties *ReplicationProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Replication. +func (r Replication) MarshalJSON() ([]byte, error) { + objectMap := r.Resource.marshalInternal() + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// ReplicationListResult - The result of a request to list replications for a container registry. +type ReplicationListResult struct { + // The URI that can be used to request the next list of replications. + NextLink *string `json:"nextLink,omitempty"` + + // The list of replications. Since this list may be incomplete, the nextLink field should be used to request the next list of replications. + Value []*Replication `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReplicationListResult. +func (r ReplicationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// ReplicationProperties - The properties of a replication. +type ReplicationProperties struct { + // Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however + // its data will continue to be synced with + // other replications. + RegionEndpointEnabled *bool `json:"regionEndpointEnabled,omitempty"` + + // Whether or not zone redundancy is enabled for this container registry replication + ZoneRedundancy *ZoneRedundancy `json:"zoneRedundancy,omitempty"` + + // READ-ONLY; The provisioning state of the replication at the time the operation was called. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The status of the replication at the time the operation was called. + Status *Status `json:"status,omitempty" azure:"ro"` +} + +// ReplicationUpdateParameters - The parameters for updating a replication. +type ReplicationUpdateParameters struct { + // The parameters for updating a replication's properties + Properties *ReplicationUpdateParametersProperties `json:"properties,omitempty"` + + // The tags for the replication. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReplicationUpdateParameters. +func (r ReplicationUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +type ReplicationUpdateParametersProperties struct { + // Specifies whether the replication's regional endpoint is enabled. Requests will not be routed to a replication whose regional endpoint is disabled, however + // its data will continue to be synced with + // other replications. + RegionEndpointEnabled *bool `json:"regionEndpointEnabled,omitempty"` +} + +// ReplicationsBeginCreateOptions contains the optional parameters for the Replications.BeginCreate method. +type ReplicationsBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// ReplicationsBeginDeleteOptions contains the optional parameters for the Replications.BeginDelete method. +type ReplicationsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ReplicationsBeginUpdateOptions contains the optional parameters for the Replications.BeginUpdate method. +type ReplicationsBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// ReplicationsGetOptions contains the optional parameters for the Replications.Get method. +type ReplicationsGetOptions struct { + // placeholder for future optional parameters +} + +// ReplicationsListOptions contains the optional parameters for the Replications.List method. +type ReplicationsListOptions struct { + // placeholder for future optional parameters +} + +// Request - The request that generated the event. +type Request struct { + // The IP or hostname and possibly port of the client connection that initiated the event. This is the RemoteAddr from the standard http request. + Addr *string `json:"addr,omitempty"` + + // The externally accessible hostname of the registry instance, as specified by the http host header on incoming requests. + Host *string `json:"host,omitempty"` + + // The ID of the request that initiated the event. + ID *string `json:"id,omitempty"` + + // The request method that generated the event. + Method *string `json:"method,omitempty"` + + // The user agent header of the request. + Useragent *string `json:"useragent,omitempty"` +} + +// Resource - An Azure resource. +type Resource struct { + // REQUIRED; The location of the resource. This cannot be changed after the resource is created. + Location *string `json:"location,omitempty"` + + // The tags of the resource. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; The resource ID. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := r.marshalInternal() + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return objectMap +} + +// RetentionPolicy - The retention policy for a container registry. +type RetentionPolicy struct { + // The number of days to retain an untagged manifest after which it gets purged. + Days *int32 `json:"days,omitempty"` + + // The value that indicates whether the policy is enabled or not. + Status *PolicyStatus `json:"status,omitempty"` + + // READ-ONLY; The timestamp when the policy was last updated. + LastUpdatedTime *time.Time `json:"lastUpdatedTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RetentionPolicy. +func (r RetentionPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "days", r.Days) + populate(objectMap, "lastUpdatedTime", (*timeRFC3339)(r.LastUpdatedTime)) + populate(objectMap, "status", r.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RetentionPolicy. +func (r *RetentionPolicy) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "days": + err = unpopulate(val, &r.Days) + delete(rawMsg, key) + case "lastUpdatedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + r.LastUpdatedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &r.Status) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// Run resource properties +type Run struct { + ProxyResource + // The properties of a run. + Properties *RunProperties `json:"properties,omitempty"` +} + +// RunFilter - Properties that are enabled for Odata querying on runs. +type RunFilter struct { + // The name of the agent pool that the run corresponds to. + AgentPoolName *string `json:"agentPoolName,omitempty"` + + // The create time for a run. + CreateTime *time.Time `json:"createTime,omitempty"` + + // The time the run finished. + FinishTime *time.Time `json:"finishTime,omitempty"` + + // The value that indicates whether archiving is enabled or not. + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + + // The list of comma-separated image manifests that were generated from the run. This is applicable if the run is of build type. + OutputImageManifests *string `json:"outputImageManifests,omitempty"` + + // The unique identifier for the run. + RunID *string `json:"runId,omitempty"` + + // The type of run. + RunType *RunType `json:"runType,omitempty"` + + // The current status of the run. + Status *RunStatus `json:"status,omitempty"` + + // The name of the task that the run corresponds to. + TaskName *string `json:"taskName,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RunFilter. +func (r RunFilter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "agentPoolName", r.AgentPoolName) + populate(objectMap, "createTime", (*timeRFC3339)(r.CreateTime)) + populate(objectMap, "finishTime", (*timeRFC3339)(r.FinishTime)) + populate(objectMap, "isArchiveEnabled", r.IsArchiveEnabled) + populate(objectMap, "outputImageManifests", r.OutputImageManifests) + populate(objectMap, "runId", r.RunID) + populate(objectMap, "runType", r.RunType) + populate(objectMap, "status", r.Status) + populate(objectMap, "taskName", r.TaskName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RunFilter. +func (r *RunFilter) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "agentPoolName": + err = unpopulate(val, &r.AgentPoolName) + delete(rawMsg, key) + case "createTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + r.CreateTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "finishTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + r.FinishTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "isArchiveEnabled": + err = unpopulate(val, &r.IsArchiveEnabled) + delete(rawMsg, key) + case "outputImageManifests": + err = unpopulate(val, &r.OutputImageManifests) + delete(rawMsg, key) + case "runId": + err = unpopulate(val, &r.RunID) + delete(rawMsg, key) + case "runType": + err = unpopulate(val, &r.RunType) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &r.Status) + delete(rawMsg, key) + case "taskName": + err = unpopulate(val, &r.TaskName) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// RunGetLogResult - The result of get log link operation. +type RunGetLogResult struct { + // The link to logs in registry for a run on a azure container registry. + LogArtifactLink *string `json:"logArtifactLink,omitempty"` + + // The link to logs for a run on a azure container registry. + LogLink *string `json:"logLink,omitempty"` +} + +// RunListResult - Collection of runs. +type RunListResult struct { + // The URI that can be used to request the next set of paged results. + NextLink *string `json:"nextLink,omitempty"` + + // The collection value. + Value []*Run `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RunListResult. +func (r RunListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RunProperties - The properties for a run. +type RunProperties struct { + // The machine configuration of the run agent. + AgentConfiguration *AgentProperties `json:"agentConfiguration,omitempty"` + + // The dedicated agent pool for the run. + AgentPoolName *string `json:"agentPoolName,omitempty"` + + // The time the run was scheduled. + CreateTime *time.Time `json:"createTime,omitempty"` + + // The list of custom registries that were logged in during this run. + CustomRegistries []*string `json:"customRegistries,omitempty"` + + // The time the run finished. + FinishTime *time.Time `json:"finishTime,omitempty"` + + // The image update trigger that caused the run. This is applicable if the task has base image trigger configured. + ImageUpdateTrigger *ImageUpdateTrigger `json:"imageUpdateTrigger,omitempty"` + + // The value that indicates whether archiving is enabled or not. + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + + // The last updated time for the run. + LastUpdatedTime *time.Time `json:"lastUpdatedTime,omitempty"` + + // The list of all images that were generated from the run. This is applicable if the run generates base image dependencies. + OutputImages []*ImageDescriptor `json:"outputImages,omitempty"` + + // The platform properties against which the run will happen. + Platform *PlatformProperties `json:"platform,omitempty"` + + // The provisioning state of a run. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + + // The unique identifier for the run. + RunID *string `json:"runId,omitempty"` + + // The type of run. + RunType *RunType `json:"runType,omitempty"` + + // The scope of the credentials that were used to login to the source registry during this run. + SourceRegistryAuth *string `json:"sourceRegistryAuth,omitempty"` + + // The source trigger that caused the run. + SourceTrigger *SourceTriggerDescriptor `json:"sourceTrigger,omitempty"` + + // The time the run started. + StartTime *time.Time `json:"startTime,omitempty"` + + // The current status of the run. + Status *RunStatus `json:"status,omitempty"` + + // The task against which run was scheduled. + Task *string `json:"task,omitempty"` + + // The timer trigger that caused the run. + TimerTrigger *TimerTriggerDescriptor `json:"timerTrigger,omitempty"` + + // The update trigger token passed for the Run. + UpdateTriggerToken *string `json:"updateTriggerToken,omitempty"` + + // READ-ONLY; The image description for the log artifact. + LogArtifact *ImageDescriptor `json:"logArtifact,omitempty" azure:"ro"` + + // READ-ONLY; The error message received from backend systems after the run is scheduled. + RunErrorMessage *string `json:"runErrorMessage,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RunProperties. +func (r RunProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "agentConfiguration", r.AgentConfiguration) + populate(objectMap, "agentPoolName", r.AgentPoolName) + populate(objectMap, "createTime", (*timeRFC3339)(r.CreateTime)) + populate(objectMap, "customRegistries", r.CustomRegistries) + populate(objectMap, "finishTime", (*timeRFC3339)(r.FinishTime)) + populate(objectMap, "imageUpdateTrigger", r.ImageUpdateTrigger) + populate(objectMap, "isArchiveEnabled", r.IsArchiveEnabled) + populate(objectMap, "lastUpdatedTime", (*timeRFC3339)(r.LastUpdatedTime)) + populate(objectMap, "logArtifact", r.LogArtifact) + populate(objectMap, "outputImages", r.OutputImages) + populate(objectMap, "platform", r.Platform) + populate(objectMap, "provisioningState", r.ProvisioningState) + populate(objectMap, "runErrorMessage", r.RunErrorMessage) + populate(objectMap, "runId", r.RunID) + populate(objectMap, "runType", r.RunType) + populate(objectMap, "sourceRegistryAuth", r.SourceRegistryAuth) + populate(objectMap, "sourceTrigger", r.SourceTrigger) + populate(objectMap, "startTime", (*timeRFC3339)(r.StartTime)) + populate(objectMap, "status", r.Status) + populate(objectMap, "task", r.Task) + populate(objectMap, "timerTrigger", r.TimerTrigger) + populate(objectMap, "updateTriggerToken", r.UpdateTriggerToken) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RunProperties. +func (r *RunProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "agentConfiguration": + err = unpopulate(val, &r.AgentConfiguration) + delete(rawMsg, key) + case "agentPoolName": + err = unpopulate(val, &r.AgentPoolName) + delete(rawMsg, key) + case "createTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + r.CreateTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "customRegistries": + err = unpopulate(val, &r.CustomRegistries) + delete(rawMsg, key) + case "finishTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + r.FinishTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "imageUpdateTrigger": + err = unpopulate(val, &r.ImageUpdateTrigger) + delete(rawMsg, key) + case "isArchiveEnabled": + err = unpopulate(val, &r.IsArchiveEnabled) + delete(rawMsg, key) + case "lastUpdatedTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + r.LastUpdatedTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "logArtifact": + err = unpopulate(val, &r.LogArtifact) + delete(rawMsg, key) + case "outputImages": + err = unpopulate(val, &r.OutputImages) + delete(rawMsg, key) + case "platform": + err = unpopulate(val, &r.Platform) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &r.ProvisioningState) + delete(rawMsg, key) + case "runErrorMessage": + err = unpopulate(val, &r.RunErrorMessage) + delete(rawMsg, key) + case "runId": + err = unpopulate(val, &r.RunID) + delete(rawMsg, key) + case "runType": + err = unpopulate(val, &r.RunType) + delete(rawMsg, key) + case "sourceRegistryAuth": + err = unpopulate(val, &r.SourceRegistryAuth) + delete(rawMsg, key) + case "sourceTrigger": + err = unpopulate(val, &r.SourceTrigger) + delete(rawMsg, key) + case "startTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + r.StartTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &r.Status) + delete(rawMsg, key) + case "task": + err = unpopulate(val, &r.Task) + delete(rawMsg, key) + case "timerTrigger": + err = unpopulate(val, &r.TimerTrigger) + delete(rawMsg, key) + case "updateTriggerToken": + err = unpopulate(val, &r.UpdateTriggerToken) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// RunRequestClassification provides polymorphic access to related types. +// Call the interface's GetRunRequest() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *DockerBuildRequest, *EncodedTaskRunRequest, *FileTaskRunRequest, *RunRequest, *TaskRunRequest +type RunRequestClassification interface { + // GetRunRequest returns the RunRequest content of the underlying type. + GetRunRequest() *RunRequest +} + +// RunRequest - The request parameters for scheduling a run. +type RunRequest struct { + // REQUIRED; The type of the run request. + Type *string `json:"type,omitempty"` + + // The dedicated agent pool for the run. + AgentPoolName *string `json:"agentPoolName,omitempty"` + + // The value that indicates whether archiving is enabled for the run or not. + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + + // The template that describes the repository and tag information for run log artifact. + LogTemplate *string `json:"logTemplate,omitempty"` +} + +// GetRunRequest implements the RunRequestClassification interface for type RunRequest. +func (r *RunRequest) GetRunRequest() *RunRequest { return r } + +// UnmarshalJSON implements the json.Unmarshaller interface for type RunRequest. +func (r *RunRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return r.unmarshalInternal(rawMsg) +} + +func (r RunRequest) marshalInternal(discValue string) map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "agentPoolName", r.AgentPoolName) + populate(objectMap, "isArchiveEnabled", r.IsArchiveEnabled) + populate(objectMap, "logTemplate", r.LogTemplate) + r.Type = &discValue + objectMap["type"] = r.Type + return objectMap +} + +func (r *RunRequest) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "agentPoolName": + err = unpopulate(val, &r.AgentPoolName) + delete(rawMsg, key) + case "isArchiveEnabled": + err = unpopulate(val, &r.IsArchiveEnabled) + delete(rawMsg, key) + case "logTemplate": + err = unpopulate(val, &r.LogTemplate) + delete(rawMsg, key) + case "type": + err = unpopulate(val, &r.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// RunUpdateParameters - The set of run properties that can be updated. +type RunUpdateParameters struct { + // The value that indicates whether archiving is enabled or not. + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RunUpdateParameters. +func (r RunUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "isArchiveEnabled", r.IsArchiveEnabled) + return json.Marshal(objectMap) +} + +// RunsBeginCancelOptions contains the optional parameters for the Runs.BeginCancel method. +type RunsBeginCancelOptions struct { + // placeholder for future optional parameters +} + +// RunsBeginUpdateOptions contains the optional parameters for the Runs.BeginUpdate method. +type RunsBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// RunsGetLogSasURLOptions contains the optional parameters for the Runs.GetLogSasURL method. +type RunsGetLogSasURLOptions struct { + // placeholder for future optional parameters +} + +// RunsGetOptions contains the optional parameters for the Runs.Get method. +type RunsGetOptions struct { + // placeholder for future optional parameters +} + +// RunsListOptions contains the optional parameters for the Runs.List method. +type RunsListOptions struct { + // The runs filter to apply on the operation. Arithmetic operators are not supported. The allowed string function is 'contains'. All logical operators except + // 'Not', 'Has', 'All' are allowed. + Filter *string + // $top is supported for get list of runs, which limits the maximum number of runs to return. + Top *int32 +} + +// SKU - The SKU of a container registry. +type SKU struct { + // REQUIRED; The SKU name of the container registry. Required for registry creation. + Name *SKUName `json:"name,omitempty"` + + // READ-ONLY; The SKU tier based on the SKU name. + Tier *SKUTier `json:"tier,omitempty" azure:"ro"` +} + +// ScopeMap - An object that represents a scope map for a container registry. +type ScopeMap struct { + ProxyResource + // The properties of the scope map. + Properties *ScopeMapProperties `json:"properties,omitempty"` +} + +// ScopeMapListResult - The result of a request to list scope maps for a container registry. +type ScopeMapListResult struct { + // The URI that can be used to request the next list of scope maps. + NextLink *string `json:"nextLink,omitempty"` + + // The list of scope maps. Since this list may be incomplete, the nextLink field should be used to request the next list of scope maps. + Value []*ScopeMap `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScopeMapListResult. +func (s ScopeMapListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// ScopeMapProperties - The properties of a scope map. +type ScopeMapProperties struct { + // REQUIRED; The list of scoped permissions for registry artifacts. E.g. repositories/repository-name/content/read, repositories/repository-name/metadata/write + Actions []*string `json:"actions,omitempty"` + + // The user friendly description of the scope map. + Description *string `json:"description,omitempty"` + + // READ-ONLY; The creation date of scope map. + CreationDate *time.Time `json:"creationDate,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The type of the scope map. E.g. BuildIn scope map. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScopeMapProperties. +func (s ScopeMapProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actions", s.Actions) + populate(objectMap, "creationDate", (*timeRFC3339)(s.CreationDate)) + populate(objectMap, "description", s.Description) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScopeMapProperties. +func (s *ScopeMapProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "actions": + err = unpopulate(val, &s.Actions) + delete(rawMsg, key) + case "creationDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.CreationDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "description": + err = unpopulate(val, &s.Description) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &s.ProvisioningState) + delete(rawMsg, key) + case "type": + err = unpopulate(val, &s.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ScopeMapPropertiesUpdateParameters - The update parameters for scope map properties. +type ScopeMapPropertiesUpdateParameters struct { + // The list of scope permissions for registry artifacts. E.g. repositories/repository-name/pull, repositories/repository-name/delete + Actions []*string `json:"actions,omitempty"` + + // The user friendly description of the scope map. + Description *string `json:"description,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScopeMapPropertiesUpdateParameters. +func (s ScopeMapPropertiesUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actions", s.Actions) + populate(objectMap, "description", s.Description) + return json.Marshal(objectMap) +} + +// ScopeMapUpdateParameters - The properties for updating the scope map. +type ScopeMapUpdateParameters struct { + // The update parameters for scope map properties. + Properties *ScopeMapPropertiesUpdateParameters `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ScopeMapUpdateParameters. +func (s ScopeMapUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// ScopeMapsBeginCreateOptions contains the optional parameters for the ScopeMaps.BeginCreate method. +type ScopeMapsBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// ScopeMapsBeginDeleteOptions contains the optional parameters for the ScopeMaps.BeginDelete method. +type ScopeMapsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ScopeMapsBeginUpdateOptions contains the optional parameters for the ScopeMaps.BeginUpdate method. +type ScopeMapsBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// ScopeMapsGetOptions contains the optional parameters for the ScopeMaps.Get method. +type ScopeMapsGetOptions struct { + // placeholder for future optional parameters +} + +// ScopeMapsListOptions contains the optional parameters for the ScopeMaps.List method. +type ScopeMapsListOptions struct { + // placeholder for future optional parameters +} + +// SecretObject - Describes the properties of a secret object value. +type SecretObject struct { + // The type of the secret object which determines how the value of the secret object has to be interpreted. + Type *SecretObjectType `json:"type,omitempty"` + + // The value of the secret. The format of this value will be determined based on the type of the secret object. If the type is Opaque, the value will be + // used as is without any modification. + Value *string `json:"value,omitempty"` +} + +// SetValue - The properties of a overridable value that can be passed to a task template. +type SetValue struct { + // REQUIRED; The name of the overridable value. + Name *string `json:"name,omitempty"` + + // REQUIRED; The overridable value. + Value *string `json:"value,omitempty"` + + // Flag to indicate whether the value represents a secret or not. + IsSecret *bool `json:"isSecret,omitempty"` +} + +// Source - The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. +type Source struct { + // The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() along with the running + // port. + Addr *string `json:"addr,omitempty"` + + // The running instance of an application. Changes after each restart. + InstanceID *string `json:"instanceID,omitempty"` +} + +// SourceProperties - The properties of the source code repository. +type SourceProperties struct { + // REQUIRED; The full URL to the source code repository + RepositoryURL *string `json:"repositoryUrl,omitempty"` + + // REQUIRED; The type of source control service. + SourceControlType *SourceControlType `json:"sourceControlType,omitempty"` + + // The branch name of the source code. + Branch *string `json:"branch,omitempty"` + + // The authorization properties for accessing the source code repository and to set up webhooks for notifications. + SourceControlAuthProperties *AuthInfo `json:"sourceControlAuthProperties,omitempty"` +} + +// SourceRegistryCredentials - Describes the credential parameters for accessing the source registry. +type SourceRegistryCredentials struct { + // The authentication mode which determines the source registry login scope. The credentials for the source registry will be generated using the given scope. + // These credentials will be used to login to + // the source registry during the run. + LoginMode *SourceRegistryLoginMode `json:"loginMode,omitempty"` +} + +// SourceTrigger - The properties of a source based trigger. +type SourceTrigger struct { + // REQUIRED; The name of the trigger. + Name *string `json:"name,omitempty"` + + // REQUIRED; The properties that describes the source(code) for the task. + SourceRepository *SourceProperties `json:"sourceRepository,omitempty"` + + // REQUIRED; The source event corresponding to the trigger. + SourceTriggerEvents []*SourceTriggerEvent `json:"sourceTriggerEvents,omitempty"` + + // The current status of trigger. + Status *TriggerStatus `json:"status,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SourceTrigger. +func (s SourceTrigger) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", s.Name) + populate(objectMap, "sourceRepository", s.SourceRepository) + populate(objectMap, "sourceTriggerEvents", s.SourceTriggerEvents) + populate(objectMap, "status", s.Status) + return json.Marshal(objectMap) +} + +// SourceTriggerDescriptor - The source trigger that caused a run. +type SourceTriggerDescriptor struct { + // The branch name in the repository. + BranchName *string `json:"branchName,omitempty"` + + // The unique ID that identifies a commit. + CommitID *string `json:"commitId,omitempty"` + + // The event type of the trigger. + EventType *string `json:"eventType,omitempty"` + + // The unique ID of the trigger. + ID *string `json:"id,omitempty"` + + // The source control provider type. + ProviderType *string `json:"providerType,omitempty"` + + // The unique ID that identifies pull request. + PullRequestID *string `json:"pullRequestId,omitempty"` + + // The repository URL. + RepositoryURL *string `json:"repositoryUrl,omitempty"` +} + +// SourceTriggerUpdateParameters - The properties for updating a source based trigger. +type SourceTriggerUpdateParameters struct { + // REQUIRED; The name of the trigger. + Name *string `json:"name,omitempty"` + + // The properties that describes the source(code) for the task. + SourceRepository *SourceUpdateParameters `json:"sourceRepository,omitempty"` + + // The source event corresponding to the trigger. + SourceTriggerEvents []*SourceTriggerEvent `json:"sourceTriggerEvents,omitempty"` + + // The current status of trigger. + Status *TriggerStatus `json:"status,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SourceTriggerUpdateParameters. +func (s SourceTriggerUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", s.Name) + populate(objectMap, "sourceRepository", s.SourceRepository) + populate(objectMap, "sourceTriggerEvents", s.SourceTriggerEvents) + populate(objectMap, "status", s.Status) + return json.Marshal(objectMap) +} + +// SourceUpdateParameters - The properties for updating the source code repository. +type SourceUpdateParameters struct { + // The branch name of the source code. + Branch *string `json:"branch,omitempty"` + + // The full URL to the source code repository + RepositoryURL *string `json:"repositoryUrl,omitempty"` + + // The authorization properties for accessing the source code repository and to set up webhooks for notifications. + SourceControlAuthProperties *AuthInfoUpdateParameters `json:"sourceControlAuthProperties,omitempty"` + + // The type of source control service. + SourceControlType *SourceControlType `json:"sourceControlType,omitempty"` +} + +// SourceUploadDefinition - The properties of a response to source upload request. +type SourceUploadDefinition struct { + // The relative path to the source. This is used to submit the subsequent queue build request. + RelativePath *string `json:"relativePath,omitempty"` + + // The URL where the client can upload the source. + UploadURL *string `json:"uploadUrl,omitempty"` +} + +// Status - The status of an Azure resource at the time the operation was called. +type Status struct { + // READ-ONLY; The short label for the status. + DisplayStatus *string `json:"displayStatus,omitempty" azure:"ro"` + + // READ-ONLY; The detailed message for the status, including alerts and error messages. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The timestamp when the status was changed to the current value. + Timestamp *time.Time `json:"timestamp,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Status. +func (s Status) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "displayStatus", s.DisplayStatus) + populate(objectMap, "message", s.Message) + populate(objectMap, "timestamp", (*timeRFC3339)(s.Timestamp)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Status. +func (s *Status) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "displayStatus": + err = unpopulate(val, &s.DisplayStatus) + delete(rawMsg, key) + case "message": + err = unpopulate(val, &s.Message) + delete(rawMsg, key) + case "timestamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.Timestamp = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// StatusDetailProperties - The status detail properties of the connected registry. +type StatusDetailProperties struct { + // READ-ONLY; The code of the status. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The correlation ID of the status. + CorrelationID *string `json:"correlationId,omitempty" azure:"ro"` + + // READ-ONLY; The description of the status. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The timestamp of the status. + Timestamp *time.Time `json:"timestamp,omitempty" azure:"ro"` + + // READ-ONLY; The component of the connected registry corresponding to the status. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type StatusDetailProperties. +func (s StatusDetailProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", s.Code) + populate(objectMap, "correlationId", s.CorrelationID) + populate(objectMap, "description", s.Description) + populate(objectMap, "timestamp", (*timeRFC3339)(s.Timestamp)) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StatusDetailProperties. +func (s *StatusDetailProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, &s.Code) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, &s.CorrelationID) + delete(rawMsg, key) + case "description": + err = unpopulate(val, &s.Description) + delete(rawMsg, key) + case "timestamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.Timestamp = (*time.Time)(&aux) + delete(rawMsg, key) + case "type": + err = unpopulate(val, &s.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// SyncProperties - The sync properties of the connected registry with its parent. +type SyncProperties struct { + // REQUIRED; The period of time for which a message is available to sync before it is expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S + // as per ISO8601. + MessageTTL *string `json:"messageTtl,omitempty"` + + // REQUIRED; The resource ID of the ACR token used to authenticate the connected registry to its parent during sync. + TokenID *string `json:"tokenId,omitempty"` + + // The cron expression indicating the schedule that the connected registry will sync with its parent. + Schedule *string `json:"schedule,omitempty"` + + // The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + SyncWindow *string `json:"syncWindow,omitempty"` + + // READ-ONLY; The gateway endpoint used by the connected registry to communicate with its parent. + GatewayEndpoint *string `json:"gatewayEndpoint,omitempty" azure:"ro"` + + // READ-ONLY; The last time a sync occurred between the connected registry and its parent. + LastSyncTime *time.Time `json:"lastSyncTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type SyncProperties. +func (s SyncProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "gatewayEndpoint", s.GatewayEndpoint) + populate(objectMap, "lastSyncTime", (*timeRFC3339)(s.LastSyncTime)) + populate(objectMap, "messageTtl", s.MessageTTL) + populate(objectMap, "schedule", s.Schedule) + populate(objectMap, "syncWindow", s.SyncWindow) + populate(objectMap, "tokenId", s.TokenID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SyncProperties. +func (s *SyncProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "gatewayEndpoint": + err = unpopulate(val, &s.GatewayEndpoint) + delete(rawMsg, key) + case "lastSyncTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.LastSyncTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "messageTtl": + err = unpopulate(val, &s.MessageTTL) + delete(rawMsg, key) + case "schedule": + err = unpopulate(val, &s.Schedule) + delete(rawMsg, key) + case "syncWindow": + err = unpopulate(val, &s.SyncWindow) + delete(rawMsg, key) + case "tokenId": + err = unpopulate(val, &s.TokenID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// SyncUpdateProperties - The parameters for updating the sync properties of the connected registry with its parent. +type SyncUpdateProperties struct { + // The period of time for which a message is available to sync before it is expired. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as + // per ISO8601. + MessageTTL *string `json:"messageTtl,omitempty"` + + // The cron expression indicating the schedule that the connected registry will sync with its parent. + Schedule *string `json:"schedule,omitempty"` + + // The time window during which sync is enabled for each schedule occurrence. Specify the duration using the format P[n]Y[n]M[n]DT[n]H[n]M[n]S as per ISO8601. + SyncWindow *string `json:"syncWindow,omitempty"` +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource modification (UTC). + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *LastModifiedByType `json:"lastModifiedByType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "createdAt", (*timeRFC3339)(s.CreatedAt)) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populate(objectMap, "lastModifiedAt", (*timeRFC3339)(s.LastModifiedAt)) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.CreatedAt = (*time.Time)(&aux) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.LastModifiedAt = (*time.Time)(&aux) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TLSCertificateProperties - The TLS certificate properties of the connected registry login server. +type TLSCertificateProperties struct { + // READ-ONLY; Indicates the location of the certificates. + Location *string `json:"location,omitempty" azure:"ro"` + + // READ-ONLY; The type of certificate location. + Type *CertificateType `json:"type,omitempty" azure:"ro"` +} + +// TLSProperties - The TLS properties of the connected registry login server. +type TLSProperties struct { + // READ-ONLY; The certificate used to configure HTTPS for the login server. + Certificate *TLSCertificateProperties `json:"certificate,omitempty" azure:"ro"` + + // READ-ONLY; Indicates whether HTTPS is enabled for the login server. + Status *TLSStatus `json:"status,omitempty" azure:"ro"` +} + +// Target - The target of the event. +type Target struct { + // The digest of the content, as defined by the Registry V2 HTTP API Specification. + Digest *string `json:"digest,omitempty"` + + // The number of bytes of the content. Same as Size field. + Length *int64 `json:"length,omitempty"` + + // The MIME type of the referenced object. + MediaType *string `json:"mediaType,omitempty"` + + // The name of the artifact. + Name *string `json:"name,omitempty"` + + // The repository name. + Repository *string `json:"repository,omitempty"` + + // The number of bytes of the content. Same as Length field. + Size *int64 `json:"size,omitempty"` + + // The tag name. + Tag *string `json:"tag,omitempty"` + + // The direct URL to the content. + URL *string `json:"url,omitempty"` + + // The version of the artifact. + Version *string `json:"version,omitempty"` +} + +// Task - The task that has the ARM resource and task properties. The task will have all information to schedule a run against it. +type Task struct { + Resource + // Identity for the resource. + Identity *IdentityProperties `json:"identity,omitempty"` + + // The properties of a task. + Properties *TaskProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Task. +func (t Task) MarshalJSON() ([]byte, error) { + objectMap := t.Resource.marshalInternal() + populate(objectMap, "identity", t.Identity) + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// TaskListResult - The collection of tasks. +type TaskListResult struct { + // The URI that can be used to request the next set of paged results. + NextLink *string `json:"nextLink,omitempty"` + + // The collection value. + Value []*Task `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TaskListResult. +func (t TaskListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// TaskProperties - The properties of a task. +type TaskProperties struct { + // The machine configuration of the run agent. + AgentConfiguration *AgentProperties `json:"agentConfiguration,omitempty"` + + // The dedicated agent pool for the task. + AgentPoolName *string `json:"agentPoolName,omitempty"` + + // The properties that describes a set of credentials that will be used when this run is invoked. + Credentials *Credentials `json:"credentials,omitempty"` + + // The value of this property indicates whether the task resource is system task or not. + IsSystemTask *bool `json:"isSystemTask,omitempty"` + + // The template that describes the repository and tag information for run log artifact. + LogTemplate *string `json:"logTemplate,omitempty"` + + // The platform properties against which the run has to happen. + Platform *PlatformProperties `json:"platform,omitempty"` + + // The current status of task. + Status *TaskStatus `json:"status,omitempty"` + + // The properties of a task step. + Step TaskStepPropertiesClassification `json:"step,omitempty"` + + // Run timeout in seconds. + Timeout *int32 `json:"timeout,omitempty"` + + // The properties that describe all triggers for the task. + Trigger *TriggerProperties `json:"trigger,omitempty"` + + // READ-ONLY; The creation date of task. + CreationDate *time.Time `json:"creationDate,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the task. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type TaskProperties. +func (t TaskProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "agentConfiguration", t.AgentConfiguration) + populate(objectMap, "agentPoolName", t.AgentPoolName) + populate(objectMap, "creationDate", (*timeRFC3339)(t.CreationDate)) + populate(objectMap, "credentials", t.Credentials) + populate(objectMap, "isSystemTask", t.IsSystemTask) + populate(objectMap, "logTemplate", t.LogTemplate) + populate(objectMap, "platform", t.Platform) + populate(objectMap, "provisioningState", t.ProvisioningState) + populate(objectMap, "status", t.Status) + populate(objectMap, "step", t.Step) + populate(objectMap, "timeout", t.Timeout) + populate(objectMap, "trigger", t.Trigger) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskProperties. +func (t *TaskProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "agentConfiguration": + err = unpopulate(val, &t.AgentConfiguration) + delete(rawMsg, key) + case "agentPoolName": + err = unpopulate(val, &t.AgentPoolName) + delete(rawMsg, key) + case "creationDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + t.CreationDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "credentials": + err = unpopulate(val, &t.Credentials) + delete(rawMsg, key) + case "isSystemTask": + err = unpopulate(val, &t.IsSystemTask) + delete(rawMsg, key) + case "logTemplate": + err = unpopulate(val, &t.LogTemplate) + delete(rawMsg, key) + case "platform": + err = unpopulate(val, &t.Platform) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &t.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &t.Status) + delete(rawMsg, key) + case "step": + t.Step, err = unmarshalTaskStepPropertiesClassification(val) + delete(rawMsg, key) + case "timeout": + err = unpopulate(val, &t.Timeout) + delete(rawMsg, key) + case "trigger": + err = unpopulate(val, &t.Trigger) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TaskPropertiesUpdateParameters - The properties for updating a task. +type TaskPropertiesUpdateParameters struct { + // The machine configuration of the run agent. + AgentConfiguration *AgentProperties `json:"agentConfiguration,omitempty"` + + // The dedicated agent pool for the task. + AgentPoolName *string `json:"agentPoolName,omitempty"` + + // The parameters that describes a set of credentials that will be used when this run is invoked. + Credentials *Credentials `json:"credentials,omitempty"` + + // The template that describes the repository and tag information for run log artifact. + LogTemplate *string `json:"logTemplate,omitempty"` + + // The platform properties against which the run has to happen. + Platform *PlatformUpdateParameters `json:"platform,omitempty"` + + // The current status of task. + Status *TaskStatus `json:"status,omitempty"` + + // The properties for updating a task step. + Step TaskStepUpdateParametersClassification `json:"step,omitempty"` + + // Run timeout in seconds. + Timeout *int32 `json:"timeout,omitempty"` + + // The properties for updating trigger properties. + Trigger *TriggerUpdateParameters `json:"trigger,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TaskPropertiesUpdateParameters. +func (t TaskPropertiesUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "agentConfiguration", t.AgentConfiguration) + populate(objectMap, "agentPoolName", t.AgentPoolName) + populate(objectMap, "credentials", t.Credentials) + populate(objectMap, "logTemplate", t.LogTemplate) + populate(objectMap, "platform", t.Platform) + populate(objectMap, "status", t.Status) + populate(objectMap, "step", t.Step) + populate(objectMap, "timeout", t.Timeout) + populate(objectMap, "trigger", t.Trigger) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskPropertiesUpdateParameters. +func (t *TaskPropertiesUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "agentConfiguration": + err = unpopulate(val, &t.AgentConfiguration) + delete(rawMsg, key) + case "agentPoolName": + err = unpopulate(val, &t.AgentPoolName) + delete(rawMsg, key) + case "credentials": + err = unpopulate(val, &t.Credentials) + delete(rawMsg, key) + case "logTemplate": + err = unpopulate(val, &t.LogTemplate) + delete(rawMsg, key) + case "platform": + err = unpopulate(val, &t.Platform) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &t.Status) + delete(rawMsg, key) + case "step": + t.Step, err = unmarshalTaskStepUpdateParametersClassification(val) + delete(rawMsg, key) + case "timeout": + err = unpopulate(val, &t.Timeout) + delete(rawMsg, key) + case "trigger": + err = unpopulate(val, &t.Trigger) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TaskRun - The task run that has the ARM resource and properties. The task run will have the information of request and result of a run. +type TaskRun struct { + ProxyResource + // Identity for the resource. + Identity *IdentityProperties `json:"identity,omitempty"` + + // The location of the resource + Location *string `json:"location,omitempty"` + + // The properties associated with the task run, i.e., request and result of the run + Properties *TaskRunProperties `json:"properties,omitempty"` +} + +// TaskRunListResult - The collection of task runs. +type TaskRunListResult struct { + // The URI that can be used to request the next set of paged results. + NextLink *string `json:"nextLink,omitempty"` + + // The collection value. + Value []*TaskRun `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TaskRunListResult. +func (t TaskRunListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// TaskRunProperties - The properties of task run. +type TaskRunProperties struct { + // How the run should be forced to rerun even if the run request configuration has not changed + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + + // The request (parameters) for the run + RunRequest RunRequestClassification `json:"runRequest,omitempty"` + + // READ-ONLY; The provisioning state of this task run + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The result of this task run + RunResult *Run `json:"runResult,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type TaskRunProperties. +func (t TaskRunProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "forceUpdateTag", t.ForceUpdateTag) + populate(objectMap, "provisioningState", t.ProvisioningState) + populate(objectMap, "runRequest", t.RunRequest) + populate(objectMap, "runResult", t.RunResult) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskRunProperties. +func (t *TaskRunProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "forceUpdateTag": + err = unpopulate(val, &t.ForceUpdateTag) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &t.ProvisioningState) + delete(rawMsg, key) + case "runRequest": + t.RunRequest, err = unmarshalRunRequestClassification(val) + delete(rawMsg, key) + case "runResult": + err = unpopulate(val, &t.RunResult) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TaskRunPropertiesUpdateParameters - The properties of a task run update parameters. +type TaskRunPropertiesUpdateParameters struct { + // How the run should be forced to rerun even if the run request configuration has not changed + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + + // The request (parameters) for the new run + RunRequest RunRequestClassification `json:"runRequest,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TaskRunPropertiesUpdateParameters. +func (t TaskRunPropertiesUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "forceUpdateTag", t.ForceUpdateTag) + populate(objectMap, "runRequest", t.RunRequest) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskRunPropertiesUpdateParameters. +func (t *TaskRunPropertiesUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "forceUpdateTag": + err = unpopulate(val, &t.ForceUpdateTag) + delete(rawMsg, key) + case "runRequest": + t.RunRequest, err = unmarshalRunRequestClassification(val) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TaskRunRequest - The parameters for a task run request. +type TaskRunRequest struct { + RunRequest + // REQUIRED; The resource ID of task against which run has to be queued. + TaskID *string `json:"taskId,omitempty"` + + // Set of overridable parameters that can be passed when running a Task. + OverrideTaskStepProperties *OverrideTaskStepProperties `json:"overrideTaskStepProperties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TaskRunRequest. +func (t TaskRunRequest) MarshalJSON() ([]byte, error) { + objectMap := t.RunRequest.marshalInternal("TaskRunRequest") + populate(objectMap, "overrideTaskStepProperties", t.OverrideTaskStepProperties) + populate(objectMap, "taskId", t.TaskID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskRunRequest. +func (t *TaskRunRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "overrideTaskStepProperties": + err = unpopulate(val, &t.OverrideTaskStepProperties) + delete(rawMsg, key) + case "taskId": + err = unpopulate(val, &t.TaskID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return t.RunRequest.unmarshalInternal(rawMsg) +} + +// TaskRunUpdateParameters - The parameters for updating a task run. +type TaskRunUpdateParameters struct { + // Identity for the resource. + Identity *IdentityProperties `json:"identity,omitempty"` + + // The location of the resource + Location *string `json:"location,omitempty"` + + // The properties for updating a task run. + Properties *TaskRunPropertiesUpdateParameters `json:"properties,omitempty"` + + // The ARM resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TaskRunUpdateParameters. +func (t TaskRunUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", t.Identity) + populate(objectMap, "location", t.Location) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// TaskRunsBeginCreateOptions contains the optional parameters for the TaskRuns.BeginCreate method. +type TaskRunsBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// TaskRunsBeginDeleteOptions contains the optional parameters for the TaskRuns.BeginDelete method. +type TaskRunsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// TaskRunsBeginUpdateOptions contains the optional parameters for the TaskRuns.BeginUpdate method. +type TaskRunsBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// TaskRunsGetDetailsOptions contains the optional parameters for the TaskRuns.GetDetails method. +type TaskRunsGetDetailsOptions struct { + // placeholder for future optional parameters +} + +// TaskRunsGetOptions contains the optional parameters for the TaskRuns.Get method. +type TaskRunsGetOptions struct { + // placeholder for future optional parameters +} + +// TaskRunsListOptions contains the optional parameters for the TaskRuns.List method. +type TaskRunsListOptions struct { + // placeholder for future optional parameters +} + +// TaskStepPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetTaskStepProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *DockerBuildStep, *EncodedTaskStep, *FileTaskStep, *TaskStepProperties +type TaskStepPropertiesClassification interface { + // GetTaskStepProperties returns the TaskStepProperties content of the underlying type. + GetTaskStepProperties() *TaskStepProperties +} + +// TaskStepProperties - Base properties for any task step. +type TaskStepProperties struct { + // REQUIRED; The type of the step. + Type *StepType `json:"type,omitempty"` + + // The token (git PAT or SAS token of storage account blob) associated with the context for a step. + ContextAccessToken *string `json:"contextAccessToken,omitempty"` + + // The URL(absolute or relative) of the source context for the task step. + ContextPath *string `json:"contextPath,omitempty"` + + // READ-ONLY; List of base image dependencies for a step. + BaseImageDependencies []*BaseImageDependency `json:"baseImageDependencies,omitempty" azure:"ro"` +} + +// GetTaskStepProperties implements the TaskStepPropertiesClassification interface for type TaskStepProperties. +func (t *TaskStepProperties) GetTaskStepProperties() *TaskStepProperties { return t } + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskStepProperties. +func (t *TaskStepProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return t.unmarshalInternal(rawMsg) +} + +func (t TaskStepProperties) marshalInternal(discValue StepType) map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "baseImageDependencies", t.BaseImageDependencies) + populate(objectMap, "contextAccessToken", t.ContextAccessToken) + populate(objectMap, "contextPath", t.ContextPath) + t.Type = &discValue + objectMap["type"] = t.Type + return objectMap +} + +func (t *TaskStepProperties) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "baseImageDependencies": + err = unpopulate(val, &t.BaseImageDependencies) + delete(rawMsg, key) + case "contextAccessToken": + err = unpopulate(val, &t.ContextAccessToken) + delete(rawMsg, key) + case "contextPath": + err = unpopulate(val, &t.ContextPath) + delete(rawMsg, key) + case "type": + err = unpopulate(val, &t.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TaskStepUpdateParametersClassification provides polymorphic access to related types. +// Call the interface's GetTaskStepUpdateParameters() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *DockerBuildStepUpdateParameters, *EncodedTaskStepUpdateParameters, *FileTaskStepUpdateParameters, *TaskStepUpdateParameters +type TaskStepUpdateParametersClassification interface { + // GetTaskStepUpdateParameters returns the TaskStepUpdateParameters content of the underlying type. + GetTaskStepUpdateParameters() *TaskStepUpdateParameters +} + +// TaskStepUpdateParameters - Base properties for updating any task step. +type TaskStepUpdateParameters struct { + // REQUIRED; The type of the step. + Type *StepType `json:"type,omitempty"` + + // The token (git PAT or SAS token of storage account blob) associated with the context for a step. + ContextAccessToken *string `json:"contextAccessToken,omitempty"` + + // The URL(absolute or relative) of the source context for the task step. + ContextPath *string `json:"contextPath,omitempty"` +} + +// GetTaskStepUpdateParameters implements the TaskStepUpdateParametersClassification interface for type TaskStepUpdateParameters. +func (t *TaskStepUpdateParameters) GetTaskStepUpdateParameters() *TaskStepUpdateParameters { return t } + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskStepUpdateParameters. +func (t *TaskStepUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return t.unmarshalInternal(rawMsg) +} + +func (t TaskStepUpdateParameters) marshalInternal(discValue StepType) map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "contextAccessToken", t.ContextAccessToken) + populate(objectMap, "contextPath", t.ContextPath) + t.Type = &discValue + objectMap["type"] = t.Type + return objectMap +} + +func (t *TaskStepUpdateParameters) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "contextAccessToken": + err = unpopulate(val, &t.ContextAccessToken) + delete(rawMsg, key) + case "contextPath": + err = unpopulate(val, &t.ContextPath) + delete(rawMsg, key) + case "type": + err = unpopulate(val, &t.Type) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TaskUpdateParameters - The parameters for updating a task. +type TaskUpdateParameters struct { + // Identity for the resource. + Identity *IdentityProperties `json:"identity,omitempty"` + + // The properties for updating a task. + Properties *TaskPropertiesUpdateParameters `json:"properties,omitempty"` + + // The ARM resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TaskUpdateParameters. +func (t TaskUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", t.Identity) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// TasksBeginCreateOptions contains the optional parameters for the Tasks.BeginCreate method. +type TasksBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// TasksBeginDeleteOptions contains the optional parameters for the Tasks.BeginDelete method. +type TasksBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// TasksBeginUpdateOptions contains the optional parameters for the Tasks.BeginUpdate method. +type TasksBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// TasksGetDetailsOptions contains the optional parameters for the Tasks.GetDetails method. +type TasksGetDetailsOptions struct { + // placeholder for future optional parameters +} + +// TasksGetOptions contains the optional parameters for the Tasks.Get method. +type TasksGetOptions struct { + // placeholder for future optional parameters +} + +// TasksListOptions contains the optional parameters for the Tasks.List method. +type TasksListOptions struct { + // placeholder for future optional parameters +} + +// TimerTrigger - The properties of a timer trigger. +type TimerTrigger struct { + // REQUIRED; The name of the trigger. + Name *string `json:"name,omitempty"` + + // REQUIRED; The CRON expression for the task schedule + Schedule *string `json:"schedule,omitempty"` + + // The current status of trigger. + Status *TriggerStatus `json:"status,omitempty"` +} + +type TimerTriggerDescriptor struct { + // The occurrence that triggered the run. + ScheduleOccurrence *string `json:"scheduleOccurrence,omitempty"` + + // The timer trigger name that caused the run. + TimerTriggerName *string `json:"timerTriggerName,omitempty"` +} + +// TimerTriggerUpdateParameters - The properties for updating a timer trigger. +type TimerTriggerUpdateParameters struct { + // REQUIRED; The name of the trigger. + Name *string `json:"name,omitempty"` + + // The CRON expression for the task schedule + Schedule *string `json:"schedule,omitempty"` + + // The current status of trigger. + Status *TriggerStatus `json:"status,omitempty"` +} + +// Token - An object that represents a token for a container registry. +type Token struct { + ProxyResource + // The properties of the token. + Properties *TokenProperties `json:"properties,omitempty"` +} + +// TokenCertificate - The properties of a certificate used for authenticating a token. +type TokenCertificate struct { + // Base 64 encoded string of the public certificate1 in PEM format that will be used for authenticating the token. + EncodedPemCertificate *string `json:"encodedPemCertificate,omitempty"` + + // The expiry datetime of the certificate. + Expiry *time.Time `json:"expiry,omitempty"` + Name *TokenCertificateName `json:"name,omitempty"` + + // The thumbprint of the certificate. + Thumbprint *string `json:"thumbprint,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TokenCertificate. +func (t TokenCertificate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "encodedPemCertificate", t.EncodedPemCertificate) + populate(objectMap, "expiry", (*timeRFC3339)(t.Expiry)) + populate(objectMap, "name", t.Name) + populate(objectMap, "thumbprint", t.Thumbprint) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TokenCertificate. +func (t *TokenCertificate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "encodedPemCertificate": + err = unpopulate(val, &t.EncodedPemCertificate) + delete(rawMsg, key) + case "expiry": + var aux timeRFC3339 + err = unpopulate(val, &aux) + t.Expiry = (*time.Time)(&aux) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &t.Name) + delete(rawMsg, key) + case "thumbprint": + err = unpopulate(val, &t.Thumbprint) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TokenCredentialsProperties - The properties of the credentials that can be used for authenticating the token. +type TokenCredentialsProperties struct { + Certificates []*TokenCertificate `json:"certificates,omitempty"` + Passwords []*TokenPassword `json:"passwords,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TokenCredentialsProperties. +func (t TokenCredentialsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "certificates", t.Certificates) + populate(objectMap, "passwords", t.Passwords) + return json.Marshal(objectMap) +} + +// TokenListResult - The result of a request to list tokens for a container registry. +type TokenListResult struct { + // The URI that can be used to request the next list of tokens. + NextLink *string `json:"nextLink,omitempty"` + + // The list of tokens. Since this list may be incomplete, the nextLink field should be used to request the next list of tokens. + Value []*Token `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TokenListResult. +func (t TokenListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// TokenPassword - The password that will be used for authenticating the token of a container registry. +type TokenPassword struct { + // The creation datetime of the password. + CreationTime *time.Time `json:"creationTime,omitempty"` + + // The expiry datetime of the password. + Expiry *time.Time `json:"expiry,omitempty"` + + // The password name "password1" or "password2" + Name *TokenPasswordName `json:"name,omitempty"` + + // READ-ONLY; The password value. + Value *string `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type TokenPassword. +func (t TokenPassword) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "creationTime", (*timeRFC3339)(t.CreationTime)) + populate(objectMap, "expiry", (*timeRFC3339)(t.Expiry)) + populate(objectMap, "name", t.Name) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TokenPassword. +func (t *TokenPassword) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "creationTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + t.CreationTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "expiry": + var aux timeRFC3339 + err = unpopulate(val, &aux) + t.Expiry = (*time.Time)(&aux) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &t.Name) + delete(rawMsg, key) + case "value": + err = unpopulate(val, &t.Value) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TokenProperties - The properties of a token. +type TokenProperties struct { + // The credentials that can be used for authenticating the token. + Credentials *TokenCredentialsProperties `json:"credentials,omitempty"` + + // The resource ID of the scope map to which the token will be associated with. + ScopeMapID *string `json:"scopeMapId,omitempty"` + + // The status of the token example enabled or disabled. + Status *TokenStatus `json:"status,omitempty"` + + // READ-ONLY; The creation date of scope map. + CreationDate *time.Time `json:"creationDate,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type TokenProperties. +func (t TokenProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "creationDate", (*timeRFC3339)(t.CreationDate)) + populate(objectMap, "credentials", t.Credentials) + populate(objectMap, "provisioningState", t.ProvisioningState) + populate(objectMap, "scopeMapId", t.ScopeMapID) + populate(objectMap, "status", t.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TokenProperties. +func (t *TokenProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "creationDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + t.CreationDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "credentials": + err = unpopulate(val, &t.Credentials) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &t.ProvisioningState) + delete(rawMsg, key) + case "scopeMapId": + err = unpopulate(val, &t.ScopeMapID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &t.Status) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TokenUpdateParameters - The parameters for updating a token. +type TokenUpdateParameters struct { + // The properties of the token update parameters. + Properties *TokenUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TokenUpdateParameters. +func (t TokenUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// TokenUpdateProperties - The parameters for updating token properties. +type TokenUpdateProperties struct { + // The credentials that can be used for authenticating the token. + Credentials *TokenCredentialsProperties `json:"credentials,omitempty"` + + // The resource ID of the scope map to which the token will be associated with. + ScopeMapID *string `json:"scopeMapId,omitempty"` + + // The status of the token example enabled or disabled. + Status *TokenStatus `json:"status,omitempty"` +} + +// TokensBeginCreateOptions contains the optional parameters for the Tokens.BeginCreate method. +type TokensBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// TokensBeginDeleteOptions contains the optional parameters for the Tokens.BeginDelete method. +type TokensBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// TokensBeginUpdateOptions contains the optional parameters for the Tokens.BeginUpdate method. +type TokensBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// TokensGetOptions contains the optional parameters for the Tokens.Get method. +type TokensGetOptions struct { + // placeholder for future optional parameters +} + +// TokensListOptions contains the optional parameters for the Tokens.List method. +type TokensListOptions struct { + // placeholder for future optional parameters +} + +// TriggerProperties - The properties of a trigger. +type TriggerProperties struct { + // The trigger based on base image dependencies. + BaseImageTrigger *BaseImageTrigger `json:"baseImageTrigger,omitempty"` + + // The collection of triggers based on source code repository. + SourceTriggers []*SourceTrigger `json:"sourceTriggers,omitempty"` + + // The collection of timer triggers. + TimerTriggers []*TimerTrigger `json:"timerTriggers,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TriggerProperties. +func (t TriggerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "baseImageTrigger", t.BaseImageTrigger) + populate(objectMap, "sourceTriggers", t.SourceTriggers) + populate(objectMap, "timerTriggers", t.TimerTriggers) + return json.Marshal(objectMap) +} + +// TriggerUpdateParameters - The properties for updating triggers. +type TriggerUpdateParameters struct { + // The trigger based on base image dependencies. + BaseImageTrigger *BaseImageTriggerUpdateParameters `json:"baseImageTrigger,omitempty"` + + // The collection of triggers based on source code repository. + SourceTriggers []*SourceTriggerUpdateParameters `json:"sourceTriggers,omitempty"` + + // The collection of timer triggers. + TimerTriggers []*TimerTriggerUpdateParameters `json:"timerTriggers,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TriggerUpdateParameters. +func (t TriggerUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "baseImageTrigger", t.BaseImageTrigger) + populate(objectMap, "sourceTriggers", t.SourceTriggers) + populate(objectMap, "timerTriggers", t.TimerTriggers) + return json.Marshal(objectMap) +} + +// TrustPolicy - The content trust policy for a container registry. +type TrustPolicy struct { + // The value that indicates whether the policy is enabled or not. + Status *PolicyStatus `json:"status,omitempty"` + + // The type of trust policy. + Type *TrustPolicyType `json:"type,omitempty"` +} + +type UserIdentityProperties struct { + // The client id of user assigned identity. + ClientID *string `json:"clientId,omitempty"` + + // The principal id of user assigned identity. + PrincipalID *string `json:"principalId,omitempty"` +} + +// VirtualNetworkRule - Virtual network rule. +type VirtualNetworkRule struct { + // REQUIRED; Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + VirtualNetworkResourceID *string `json:"id,omitempty"` + + // The action of virtual network rule. + Action *Action `json:"action,omitempty"` +} + +// Webhook - An object that represents a webhook for a container registry. +type Webhook struct { + Resource + // The properties of the webhook. + Properties *WebhookProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type Webhook. +func (w Webhook) MarshalJSON() ([]byte, error) { + objectMap := w.Resource.marshalInternal() + populate(objectMap, "properties", w.Properties) + return json.Marshal(objectMap) +} + +// WebhookCreateParameters - The parameters for creating a webhook. +type WebhookCreateParameters struct { + // REQUIRED; The location of the webhook. This cannot be changed after the resource is created. + Location *string `json:"location,omitempty"` + + // The properties that the webhook will be created with. + Properties *WebhookPropertiesCreateParameters `json:"properties,omitempty"` + + // The tags for the webhook. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WebhookCreateParameters. +func (w WebhookCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", w.Location) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "tags", w.Tags) + return json.Marshal(objectMap) +} + +// WebhookListResult - The result of a request to list webhooks for a container registry. +type WebhookListResult struct { + // The URI that can be used to request the next list of webhooks. + NextLink *string `json:"nextLink,omitempty"` + + // The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of webhooks. + Value []*Webhook `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WebhookListResult. +func (w WebhookListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// WebhookProperties - The properties of a webhook. +type WebhookProperties struct { + // REQUIRED; The list of actions that trigger the webhook to post notifications. + Actions []*WebhookAction `json:"actions,omitempty"` + + // The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events + // for 'foo:bar' only. 'foo' is equivalent to + // 'foo:latest'. Empty means all events. + Scope *string `json:"scope,omitempty"` + + // The status of the webhook at the time the operation was called. + Status *WebhookStatus `json:"status,omitempty"` + + // READ-ONLY; The provisioning state of the webhook at the time the operation was called. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type WebhookProperties. +func (w WebhookProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actions", w.Actions) + populate(objectMap, "provisioningState", w.ProvisioningState) + populate(objectMap, "scope", w.Scope) + populate(objectMap, "status", w.Status) + return json.Marshal(objectMap) +} + +// WebhookPropertiesCreateParameters - The parameters for creating the properties of a webhook. +type WebhookPropertiesCreateParameters struct { + // REQUIRED; The list of actions that trigger the webhook to post notifications. + Actions []*WebhookAction `json:"actions,omitempty"` + + // REQUIRED; The service URI for the webhook to post notifications. + ServiceURI *string `json:"serviceUri,omitempty"` + + // Custom headers that will be added to the webhook notifications. + CustomHeaders map[string]*string `json:"customHeaders,omitempty"` + + // The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events + // for 'foo:bar' only. 'foo' is equivalent to + // 'foo:latest'. Empty means all events. + Scope *string `json:"scope,omitempty"` + + // The status of the webhook at the time the operation was called. + Status *WebhookStatus `json:"status,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WebhookPropertiesCreateParameters. +func (w WebhookPropertiesCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actions", w.Actions) + populate(objectMap, "customHeaders", w.CustomHeaders) + populate(objectMap, "scope", w.Scope) + populate(objectMap, "serviceUri", w.ServiceURI) + populate(objectMap, "status", w.Status) + return json.Marshal(objectMap) +} + +// WebhookPropertiesUpdateParameters - The parameters for updating the properties of a webhook. +type WebhookPropertiesUpdateParameters struct { + // The list of actions that trigger the webhook to post notifications. + Actions []*WebhookAction `json:"actions,omitempty"` + + // Custom headers that will be added to the webhook notifications. + CustomHeaders map[string]*string `json:"customHeaders,omitempty"` + + // The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events + // for 'foo:bar' only. 'foo' is equivalent to + // 'foo:latest'. Empty means all events. + Scope *string `json:"scope,omitempty"` + + // The service URI for the webhook to post notifications. + ServiceURI *string `json:"serviceUri,omitempty"` + + // The status of the webhook at the time the operation was called. + Status *WebhookStatus `json:"status,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WebhookPropertiesUpdateParameters. +func (w WebhookPropertiesUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actions", w.Actions) + populate(objectMap, "customHeaders", w.CustomHeaders) + populate(objectMap, "scope", w.Scope) + populate(objectMap, "serviceUri", w.ServiceURI) + populate(objectMap, "status", w.Status) + return json.Marshal(objectMap) +} + +// WebhookUpdateParameters - The parameters for updating a webhook. +type WebhookUpdateParameters struct { + // The properties that the webhook will be updated with. + Properties *WebhookPropertiesUpdateParameters `json:"properties,omitempty"` + + // The tags for the webhook. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type WebhookUpdateParameters. +func (w WebhookUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "tags", w.Tags) + return json.Marshal(objectMap) +} + +// WebhooksBeginCreateOptions contains the optional parameters for the Webhooks.BeginCreate method. +type WebhooksBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// WebhooksBeginDeleteOptions contains the optional parameters for the Webhooks.BeginDelete method. +type WebhooksBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// WebhooksBeginUpdateOptions contains the optional parameters for the Webhooks.BeginUpdate method. +type WebhooksBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// WebhooksGetCallbackConfigOptions contains the optional parameters for the Webhooks.GetCallbackConfig method. +type WebhooksGetCallbackConfigOptions struct { + // placeholder for future optional parameters +} + +// WebhooksGetOptions contains the optional parameters for the Webhooks.Get method. +type WebhooksGetOptions struct { + // placeholder for future optional parameters +} + +// WebhooksListEventsOptions contains the optional parameters for the Webhooks.ListEvents method. +type WebhooksListEventsOptions struct { + // placeholder for future optional parameters +} + +// WebhooksListOptions contains the optional parameters for the Webhooks.List method. +type WebhooksListOptions struct { + // placeholder for future optional parameters +} + +// WebhooksPingOptions contains the optional parameters for the Webhooks.Ping method. +type WebhooksPingOptions struct { + // placeholder for future optional parameters +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_operations_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_operations_client.go new file mode 100644 index 000000000000..0610c3fa56ba --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_operations_client.go @@ -0,0 +1,80 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + con *armcore.Connection +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(con *armcore.Connection) *OperationsClient { + return &OperationsClient{con: con} +} + +// List - Lists all of the available Azure Container Registry REST API operations. +// If the operation fails it returns a generic error. +func (client *OperationsClient) List(options *OperationsListOptions) OperationListResultPager { + return &operationListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp OperationListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*azcore.Request, error) { + urlPath := "/providers/Microsoft.ContainerRegistry/operations" + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *azcore.Response) (OperationListResultResponse, error) { + var val *OperationListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return OperationListResultResponse{}, err + } + return OperationListResultResponse{RawResponse: resp.Response, OperationListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_pagers.go b/sdk/containerregistry/armcontainerregistry/zz_generated_pagers.go new file mode 100644 index 000000000000..6f8f2fad60a2 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_pagers.go @@ -0,0 +1,1306 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// AgentPoolListResultPager provides iteration over AgentPoolListResult pages. +type AgentPoolListResultPager interface { + azcore.Pager + + // PageResponse returns the current AgentPoolListResultResponse. + PageResponse() AgentPoolListResultResponse +} + +type agentPoolListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type agentPoolListResultHandleError func(*azcore.Response) error + +type agentPoolListResultHandleResponse func(*azcore.Response) (AgentPoolListResultResponse, error) + +type agentPoolListResultAdvancePage func(context.Context, AgentPoolListResultResponse) (*azcore.Request, error) + +type agentPoolListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester agentPoolListResultCreateRequest + // callback for handling response errors + errorer agentPoolListResultHandleError + // callback for handling the HTTP response + responder agentPoolListResultHandleResponse + // callback for advancing to the next page + advancer agentPoolListResultAdvancePage + // contains the current response + current AgentPoolListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *agentPoolListResultPager) Err() error { + return p.err +} + +func (p *agentPoolListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AgentPoolListResult.NextLink == nil || len(*p.current.AgentPoolListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *agentPoolListResultPager) PageResponse() AgentPoolListResultResponse { + return p.current +} + +// ConnectedRegistryListResultPager provides iteration over ConnectedRegistryListResult pages. +type ConnectedRegistryListResultPager interface { + azcore.Pager + + // PageResponse returns the current ConnectedRegistryListResultResponse. + PageResponse() ConnectedRegistryListResultResponse +} + +type connectedRegistryListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type connectedRegistryListResultHandleError func(*azcore.Response) error + +type connectedRegistryListResultHandleResponse func(*azcore.Response) (ConnectedRegistryListResultResponse, error) + +type connectedRegistryListResultAdvancePage func(context.Context, ConnectedRegistryListResultResponse) (*azcore.Request, error) + +type connectedRegistryListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester connectedRegistryListResultCreateRequest + // callback for handling response errors + errorer connectedRegistryListResultHandleError + // callback for handling the HTTP response + responder connectedRegistryListResultHandleResponse + // callback for advancing to the next page + advancer connectedRegistryListResultAdvancePage + // contains the current response + current ConnectedRegistryListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *connectedRegistryListResultPager) Err() error { + return p.err +} + +func (p *connectedRegistryListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ConnectedRegistryListResult.NextLink == nil || len(*p.current.ConnectedRegistryListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *connectedRegistryListResultPager) PageResponse() ConnectedRegistryListResultResponse { + return p.current +} + +// EventListResultPager provides iteration over EventListResult pages. +type EventListResultPager interface { + azcore.Pager + + // PageResponse returns the current EventListResultResponse. + PageResponse() EventListResultResponse +} + +type eventListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type eventListResultHandleError func(*azcore.Response) error + +type eventListResultHandleResponse func(*azcore.Response) (EventListResultResponse, error) + +type eventListResultAdvancePage func(context.Context, EventListResultResponse) (*azcore.Request, error) + +type eventListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester eventListResultCreateRequest + // callback for handling response errors + errorer eventListResultHandleError + // callback for handling the HTTP response + responder eventListResultHandleResponse + // callback for advancing to the next page + advancer eventListResultAdvancePage + // contains the current response + current EventListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *eventListResultPager) Err() error { + return p.err +} + +func (p *eventListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.EventListResult.NextLink == nil || len(*p.current.EventListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *eventListResultPager) PageResponse() EventListResultResponse { + return p.current +} + +// ExportPipelineListResultPager provides iteration over ExportPipelineListResult pages. +type ExportPipelineListResultPager interface { + azcore.Pager + + // PageResponse returns the current ExportPipelineListResultResponse. + PageResponse() ExportPipelineListResultResponse +} + +type exportPipelineListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type exportPipelineListResultHandleError func(*azcore.Response) error + +type exportPipelineListResultHandleResponse func(*azcore.Response) (ExportPipelineListResultResponse, error) + +type exportPipelineListResultAdvancePage func(context.Context, ExportPipelineListResultResponse) (*azcore.Request, error) + +type exportPipelineListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester exportPipelineListResultCreateRequest + // callback for handling response errors + errorer exportPipelineListResultHandleError + // callback for handling the HTTP response + responder exportPipelineListResultHandleResponse + // callback for advancing to the next page + advancer exportPipelineListResultAdvancePage + // contains the current response + current ExportPipelineListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *exportPipelineListResultPager) Err() error { + return p.err +} + +func (p *exportPipelineListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ExportPipelineListResult.NextLink == nil || len(*p.current.ExportPipelineListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *exportPipelineListResultPager) PageResponse() ExportPipelineListResultResponse { + return p.current +} + +// ImportPipelineListResultPager provides iteration over ImportPipelineListResult pages. +type ImportPipelineListResultPager interface { + azcore.Pager + + // PageResponse returns the current ImportPipelineListResultResponse. + PageResponse() ImportPipelineListResultResponse +} + +type importPipelineListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type importPipelineListResultHandleError func(*azcore.Response) error + +type importPipelineListResultHandleResponse func(*azcore.Response) (ImportPipelineListResultResponse, error) + +type importPipelineListResultAdvancePage func(context.Context, ImportPipelineListResultResponse) (*azcore.Request, error) + +type importPipelineListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester importPipelineListResultCreateRequest + // callback for handling response errors + errorer importPipelineListResultHandleError + // callback for handling the HTTP response + responder importPipelineListResultHandleResponse + // callback for advancing to the next page + advancer importPipelineListResultAdvancePage + // contains the current response + current ImportPipelineListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *importPipelineListResultPager) Err() error { + return p.err +} + +func (p *importPipelineListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ImportPipelineListResult.NextLink == nil || len(*p.current.ImportPipelineListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *importPipelineListResultPager) PageResponse() ImportPipelineListResultResponse { + return p.current +} + +// OperationListResultPager provides iteration over OperationListResult pages. +type OperationListResultPager interface { + azcore.Pager + + // PageResponse returns the current OperationListResultResponse. + PageResponse() OperationListResultResponse +} + +type operationListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type operationListResultHandleError func(*azcore.Response) error + +type operationListResultHandleResponse func(*azcore.Response) (OperationListResultResponse, error) + +type operationListResultAdvancePage func(context.Context, OperationListResultResponse) (*azcore.Request, error) + +type operationListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester operationListResultCreateRequest + // callback for handling response errors + errorer operationListResultHandleError + // callback for handling the HTTP response + responder operationListResultHandleResponse + // callback for advancing to the next page + advancer operationListResultAdvancePage + // contains the current response + current OperationListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *operationListResultPager) Err() error { + return p.err +} + +func (p *operationListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *operationListResultPager) PageResponse() OperationListResultResponse { + return p.current +} + +// PipelineRunListResultPager provides iteration over PipelineRunListResult pages. +type PipelineRunListResultPager interface { + azcore.Pager + + // PageResponse returns the current PipelineRunListResultResponse. + PageResponse() PipelineRunListResultResponse +} + +type pipelineRunListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type pipelineRunListResultHandleError func(*azcore.Response) error + +type pipelineRunListResultHandleResponse func(*azcore.Response) (PipelineRunListResultResponse, error) + +type pipelineRunListResultAdvancePage func(context.Context, PipelineRunListResultResponse) (*azcore.Request, error) + +type pipelineRunListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester pipelineRunListResultCreateRequest + // callback for handling response errors + errorer pipelineRunListResultHandleError + // callback for handling the HTTP response + responder pipelineRunListResultHandleResponse + // callback for advancing to the next page + advancer pipelineRunListResultAdvancePage + // contains the current response + current PipelineRunListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *pipelineRunListResultPager) Err() error { + return p.err +} + +func (p *pipelineRunListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PipelineRunListResult.NextLink == nil || len(*p.current.PipelineRunListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *pipelineRunListResultPager) PageResponse() PipelineRunListResultResponse { + return p.current +} + +// PrivateEndpointConnectionListResultPager provides iteration over PrivateEndpointConnectionListResult pages. +type PrivateEndpointConnectionListResultPager interface { + azcore.Pager + + // PageResponse returns the current PrivateEndpointConnectionListResultResponse. + PageResponse() PrivateEndpointConnectionListResultResponse +} + +type privateEndpointConnectionListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type privateEndpointConnectionListResultHandleError func(*azcore.Response) error + +type privateEndpointConnectionListResultHandleResponse func(*azcore.Response) (PrivateEndpointConnectionListResultResponse, error) + +type privateEndpointConnectionListResultAdvancePage func(context.Context, PrivateEndpointConnectionListResultResponse) (*azcore.Request, error) + +type privateEndpointConnectionListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester privateEndpointConnectionListResultCreateRequest + // callback for handling response errors + errorer privateEndpointConnectionListResultHandleError + // callback for handling the HTTP response + responder privateEndpointConnectionListResultHandleResponse + // callback for advancing to the next page + advancer privateEndpointConnectionListResultAdvancePage + // contains the current response + current PrivateEndpointConnectionListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *privateEndpointConnectionListResultPager) Err() error { + return p.err +} + +func (p *privateEndpointConnectionListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PrivateEndpointConnectionListResult.NextLink == nil || len(*p.current.PrivateEndpointConnectionListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *privateEndpointConnectionListResultPager) PageResponse() PrivateEndpointConnectionListResultResponse { + return p.current +} + +// PrivateLinkResourceListResultPager provides iteration over PrivateLinkResourceListResult pages. +type PrivateLinkResourceListResultPager interface { + azcore.Pager + + // PageResponse returns the current PrivateLinkResourceListResultResponse. + PageResponse() PrivateLinkResourceListResultResponse +} + +type privateLinkResourceListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type privateLinkResourceListResultHandleError func(*azcore.Response) error + +type privateLinkResourceListResultHandleResponse func(*azcore.Response) (PrivateLinkResourceListResultResponse, error) + +type privateLinkResourceListResultAdvancePage func(context.Context, PrivateLinkResourceListResultResponse) (*azcore.Request, error) + +type privateLinkResourceListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester privateLinkResourceListResultCreateRequest + // callback for handling response errors + errorer privateLinkResourceListResultHandleError + // callback for handling the HTTP response + responder privateLinkResourceListResultHandleResponse + // callback for advancing to the next page + advancer privateLinkResourceListResultAdvancePage + // contains the current response + current PrivateLinkResourceListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *privateLinkResourceListResultPager) Err() error { + return p.err +} + +func (p *privateLinkResourceListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PrivateLinkResourceListResult.NextLink == nil || len(*p.current.PrivateLinkResourceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *privateLinkResourceListResultPager) PageResponse() PrivateLinkResourceListResultResponse { + return p.current +} + +// RegistryListResultPager provides iteration over RegistryListResult pages. +type RegistryListResultPager interface { + azcore.Pager + + // PageResponse returns the current RegistryListResultResponse. + PageResponse() RegistryListResultResponse +} + +type registryListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type registryListResultHandleError func(*azcore.Response) error + +type registryListResultHandleResponse func(*azcore.Response) (RegistryListResultResponse, error) + +type registryListResultAdvancePage func(context.Context, RegistryListResultResponse) (*azcore.Request, error) + +type registryListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester registryListResultCreateRequest + // callback for handling response errors + errorer registryListResultHandleError + // callback for handling the HTTP response + responder registryListResultHandleResponse + // callback for advancing to the next page + advancer registryListResultAdvancePage + // contains the current response + current RegistryListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *registryListResultPager) Err() error { + return p.err +} + +func (p *registryListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.RegistryListResult.NextLink == nil || len(*p.current.RegistryListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *registryListResultPager) PageResponse() RegistryListResultResponse { + return p.current +} + +// ReplicationListResultPager provides iteration over ReplicationListResult pages. +type ReplicationListResultPager interface { + azcore.Pager + + // PageResponse returns the current ReplicationListResultResponse. + PageResponse() ReplicationListResultResponse +} + +type replicationListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type replicationListResultHandleError func(*azcore.Response) error + +type replicationListResultHandleResponse func(*azcore.Response) (ReplicationListResultResponse, error) + +type replicationListResultAdvancePage func(context.Context, ReplicationListResultResponse) (*azcore.Request, error) + +type replicationListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester replicationListResultCreateRequest + // callback for handling response errors + errorer replicationListResultHandleError + // callback for handling the HTTP response + responder replicationListResultHandleResponse + // callback for advancing to the next page + advancer replicationListResultAdvancePage + // contains the current response + current ReplicationListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *replicationListResultPager) Err() error { + return p.err +} + +func (p *replicationListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ReplicationListResult.NextLink == nil || len(*p.current.ReplicationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *replicationListResultPager) PageResponse() ReplicationListResultResponse { + return p.current +} + +// RunListResultPager provides iteration over RunListResult pages. +type RunListResultPager interface { + azcore.Pager + + // PageResponse returns the current RunListResultResponse. + PageResponse() RunListResultResponse +} + +type runListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type runListResultHandleError func(*azcore.Response) error + +type runListResultHandleResponse func(*azcore.Response) (RunListResultResponse, error) + +type runListResultAdvancePage func(context.Context, RunListResultResponse) (*azcore.Request, error) + +type runListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester runListResultCreateRequest + // callback for handling response errors + errorer runListResultHandleError + // callback for handling the HTTP response + responder runListResultHandleResponse + // callback for advancing to the next page + advancer runListResultAdvancePage + // contains the current response + current RunListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *runListResultPager) Err() error { + return p.err +} + +func (p *runListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.RunListResult.NextLink == nil || len(*p.current.RunListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *runListResultPager) PageResponse() RunListResultResponse { + return p.current +} + +// ScopeMapListResultPager provides iteration over ScopeMapListResult pages. +type ScopeMapListResultPager interface { + azcore.Pager + + // PageResponse returns the current ScopeMapListResultResponse. + PageResponse() ScopeMapListResultResponse +} + +type scopeMapListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type scopeMapListResultHandleError func(*azcore.Response) error + +type scopeMapListResultHandleResponse func(*azcore.Response) (ScopeMapListResultResponse, error) + +type scopeMapListResultAdvancePage func(context.Context, ScopeMapListResultResponse) (*azcore.Request, error) + +type scopeMapListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester scopeMapListResultCreateRequest + // callback for handling response errors + errorer scopeMapListResultHandleError + // callback for handling the HTTP response + responder scopeMapListResultHandleResponse + // callback for advancing to the next page + advancer scopeMapListResultAdvancePage + // contains the current response + current ScopeMapListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *scopeMapListResultPager) Err() error { + return p.err +} + +func (p *scopeMapListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ScopeMapListResult.NextLink == nil || len(*p.current.ScopeMapListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *scopeMapListResultPager) PageResponse() ScopeMapListResultResponse { + return p.current +} + +// TaskListResultPager provides iteration over TaskListResult pages. +type TaskListResultPager interface { + azcore.Pager + + // PageResponse returns the current TaskListResultResponse. + PageResponse() TaskListResultResponse +} + +type taskListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type taskListResultHandleError func(*azcore.Response) error + +type taskListResultHandleResponse func(*azcore.Response) (TaskListResultResponse, error) + +type taskListResultAdvancePage func(context.Context, TaskListResultResponse) (*azcore.Request, error) + +type taskListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester taskListResultCreateRequest + // callback for handling response errors + errorer taskListResultHandleError + // callback for handling the HTTP response + responder taskListResultHandleResponse + // callback for advancing to the next page + advancer taskListResultAdvancePage + // contains the current response + current TaskListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *taskListResultPager) Err() error { + return p.err +} + +func (p *taskListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TaskListResult.NextLink == nil || len(*p.current.TaskListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *taskListResultPager) PageResponse() TaskListResultResponse { + return p.current +} + +// TaskRunListResultPager provides iteration over TaskRunListResult pages. +type TaskRunListResultPager interface { + azcore.Pager + + // PageResponse returns the current TaskRunListResultResponse. + PageResponse() TaskRunListResultResponse +} + +type taskRunListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type taskRunListResultHandleError func(*azcore.Response) error + +type taskRunListResultHandleResponse func(*azcore.Response) (TaskRunListResultResponse, error) + +type taskRunListResultAdvancePage func(context.Context, TaskRunListResultResponse) (*azcore.Request, error) + +type taskRunListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester taskRunListResultCreateRequest + // callback for handling response errors + errorer taskRunListResultHandleError + // callback for handling the HTTP response + responder taskRunListResultHandleResponse + // callback for advancing to the next page + advancer taskRunListResultAdvancePage + // contains the current response + current TaskRunListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *taskRunListResultPager) Err() error { + return p.err +} + +func (p *taskRunListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TaskRunListResult.NextLink == nil || len(*p.current.TaskRunListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *taskRunListResultPager) PageResponse() TaskRunListResultResponse { + return p.current +} + +// TokenListResultPager provides iteration over TokenListResult pages. +type TokenListResultPager interface { + azcore.Pager + + // PageResponse returns the current TokenListResultResponse. + PageResponse() TokenListResultResponse +} + +type tokenListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type tokenListResultHandleError func(*azcore.Response) error + +type tokenListResultHandleResponse func(*azcore.Response) (TokenListResultResponse, error) + +type tokenListResultAdvancePage func(context.Context, TokenListResultResponse) (*azcore.Request, error) + +type tokenListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester tokenListResultCreateRequest + // callback for handling response errors + errorer tokenListResultHandleError + // callback for handling the HTTP response + responder tokenListResultHandleResponse + // callback for advancing to the next page + advancer tokenListResultAdvancePage + // contains the current response + current TokenListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *tokenListResultPager) Err() error { + return p.err +} + +func (p *tokenListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TokenListResult.NextLink == nil || len(*p.current.TokenListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *tokenListResultPager) PageResponse() TokenListResultResponse { + return p.current +} + +// WebhookListResultPager provides iteration over WebhookListResult pages. +type WebhookListResultPager interface { + azcore.Pager + + // PageResponse returns the current WebhookListResultResponse. + PageResponse() WebhookListResultResponse +} + +type webhookListResultCreateRequest func(context.Context) (*azcore.Request, error) + +type webhookListResultHandleError func(*azcore.Response) error + +type webhookListResultHandleResponse func(*azcore.Response) (WebhookListResultResponse, error) + +type webhookListResultAdvancePage func(context.Context, WebhookListResultResponse) (*azcore.Request, error) + +type webhookListResultPager struct { + // the pipeline for making the request + pipeline azcore.Pipeline + // creates the initial request (non-LRO case) + requester webhookListResultCreateRequest + // callback for handling response errors + errorer webhookListResultHandleError + // callback for handling the HTTP response + responder webhookListResultHandleResponse + // callback for advancing to the next page + advancer webhookListResultAdvancePage + // contains the current response + current WebhookListResultResponse + // status codes for successful retrieval + statusCodes []int + // any error encountered + err error +} + +func (p *webhookListResultPager) Err() error { + return p.err +} + +func (p *webhookListResultPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.WebhookListResult.NextLink == nil || len(*p.current.WebhookListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.pipeline.Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(p.statusCodes...) { + p.err = p.errorer(resp) + return false + } + result, err := p.responder(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *webhookListResultPager) PageResponse() WebhookListResultResponse { + return p.current +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_pipelineruns_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_pipelineruns_client.go new file mode 100644 index 000000000000..a39fa3038027 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_pipelineruns_client.go @@ -0,0 +1,380 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// PipelineRunsClient contains the methods for the PipelineRuns group. +// Don't use this type directly, use NewPipelineRunsClient() instead. +type PipelineRunsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPipelineRunsClient creates a new instance of PipelineRunsClient with the specified values. +func NewPipelineRunsClient(con *armcore.Connection, subscriptionID string) *PipelineRunsClient { + return &PipelineRunsClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Creates a pipeline run for a container registry with the specified parameters +// If the operation fails it returns a generic error. +func (client *PipelineRunsClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, pipelineRunCreateParameters PipelineRun, options *PipelineRunsBeginCreateOptions) (PipelineRunPollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, registryName, pipelineRunName, pipelineRunCreateParameters, options) + if err != nil { + return PipelineRunPollerResponse{}, err + } + result := PipelineRunPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("PipelineRunsClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return PipelineRunPollerResponse{}, err + } + poller := &pipelineRunPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (PipelineRunResponseType, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new PipelineRunPoller from the specified resume token. +// token - The value must come from a previous call to PipelineRunPoller.ResumeToken(). +func (client *PipelineRunsClient) ResumeCreate(ctx context.Context, token string) (PipelineRunPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("PipelineRunsClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return PipelineRunPollerResponse{}, err + } + poller := &pipelineRunPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return PipelineRunPollerResponse{}, err + } + result := PipelineRunPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (PipelineRunResponseType, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates a pipeline run for a container registry with the specified parameters +// If the operation fails it returns a generic error. +func (client *PipelineRunsClient) create(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, pipelineRunCreateParameters PipelineRun, options *PipelineRunsBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, pipelineRunName, pipelineRunCreateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *PipelineRunsClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, pipelineRunCreateParameters PipelineRun, options *PipelineRunsBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if pipelineRunName == "" { + return nil, errors.New("parameter pipelineRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineRunName}", url.PathEscape(pipelineRunName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(pipelineRunCreateParameters) +} + +// createHandleError handles the Create error response. +func (client *PipelineRunsClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginDelete - Deletes a pipeline run from a container registry. +// If the operation fails it returns a generic error. +func (client *PipelineRunsClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, options *PipelineRunsBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, pipelineRunName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("PipelineRunsClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *PipelineRunsClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("PipelineRunsClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a pipeline run from a container registry. +// If the operation fails it returns a generic error. +func (client *PipelineRunsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, options *PipelineRunsBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, pipelineRunName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PipelineRunsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, options *PipelineRunsBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if pipelineRunName == "" { + return nil, errors.New("parameter pipelineRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineRunName}", url.PathEscape(pipelineRunName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PipelineRunsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets the detailed information for a given pipeline run. +// If the operation fails it returns a generic error. +func (client *PipelineRunsClient) Get(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, options *PipelineRunsGetOptions) (PipelineRunResponseType, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, pipelineRunName, options) + if err != nil { + return PipelineRunResponseType{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PipelineRunResponseType{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PipelineRunResponseType{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PipelineRunsClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, pipelineRunName string, options *PipelineRunsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns/{pipelineRunName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if pipelineRunName == "" { + return nil, errors.New("parameter pipelineRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineRunName}", url.PathEscape(pipelineRunName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PipelineRunsClient) getHandleResponse(resp *azcore.Response) (PipelineRunResponseType, error) { + var val *PipelineRun + if err := resp.UnmarshalAsJSON(&val); err != nil { + return PipelineRunResponseType{}, err + } + return PipelineRunResponseType{RawResponse: resp.Response, PipelineRun: val}, nil +} + +// getHandleError handles the Get error response. +func (client *PipelineRunsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// List - Lists all the pipeline runs for the specified container registry. +// If the operation fails it returns a generic error. +func (client *PipelineRunsClient) List(resourceGroupName string, registryName string, options *PipelineRunsListOptions) PipelineRunListResultPager { + return &pipelineRunListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp PipelineRunListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.PipelineRunListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *PipelineRunsClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *PipelineRunsListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/pipelineRuns" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PipelineRunsClient) listHandleResponse(resp *azcore.Response) (PipelineRunListResultResponse, error) { + var val *PipelineRunListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return PipelineRunListResultResponse{}, err + } + return PipelineRunListResultResponse{RawResponse: resp.Response, PipelineRunListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *PipelineRunsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_pollers.go b/sdk/containerregistry/armcontainerregistry/zz_generated_pollers.go new file mode 100644 index 000000000000..c1cabf2a7a4f --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_pollers.go @@ -0,0 +1,724 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "time" +) + +// AgentPoolPoller provides polling facilities until the operation reaches a terminal state. +type AgentPoolPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final AgentPoolResponse will be returned. + FinalResponse(ctx context.Context) (AgentPoolResponse, error) +} + +type agentPoolPoller struct { + pt *armcore.LROPoller +} + +func (p *agentPoolPoller) Done() bool { + return p.pt.Done() +} + +func (p *agentPoolPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *agentPoolPoller) FinalResponse(ctx context.Context) (AgentPoolResponse, error) { + respType := AgentPoolResponse{AgentPool: &AgentPool{}} + resp, err := p.pt.FinalResponse(ctx, respType.AgentPool) + if err != nil { + return AgentPoolResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *agentPoolPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *agentPoolPoller) pollUntilDone(ctx context.Context, freq time.Duration) (AgentPoolResponse, error) { + respType := AgentPoolResponse{AgentPool: &AgentPool{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.AgentPool) + if err != nil { + return AgentPoolResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ConnectedRegistryPoller provides polling facilities until the operation reaches a terminal state. +type ConnectedRegistryPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ConnectedRegistryResponse will be returned. + FinalResponse(ctx context.Context) (ConnectedRegistryResponse, error) +} + +type connectedRegistryPoller struct { + pt *armcore.LROPoller +} + +func (p *connectedRegistryPoller) Done() bool { + return p.pt.Done() +} + +func (p *connectedRegistryPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *connectedRegistryPoller) FinalResponse(ctx context.Context) (ConnectedRegistryResponse, error) { + respType := ConnectedRegistryResponse{ConnectedRegistry: &ConnectedRegistry{}} + resp, err := p.pt.FinalResponse(ctx, respType.ConnectedRegistry) + if err != nil { + return ConnectedRegistryResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *connectedRegistryPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *connectedRegistryPoller) pollUntilDone(ctx context.Context, freq time.Duration) (ConnectedRegistryResponse, error) { + respType := ConnectedRegistryResponse{ConnectedRegistry: &ConnectedRegistry{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.ConnectedRegistry) + if err != nil { + return ConnectedRegistryResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ExportPipelinePoller provides polling facilities until the operation reaches a terminal state. +type ExportPipelinePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ExportPipelineResponse will be returned. + FinalResponse(ctx context.Context) (ExportPipelineResponse, error) +} + +type exportPipelinePoller struct { + pt *armcore.LROPoller +} + +func (p *exportPipelinePoller) Done() bool { + return p.pt.Done() +} + +func (p *exportPipelinePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *exportPipelinePoller) FinalResponse(ctx context.Context) (ExportPipelineResponse, error) { + respType := ExportPipelineResponse{ExportPipeline: &ExportPipeline{}} + resp, err := p.pt.FinalResponse(ctx, respType.ExportPipeline) + if err != nil { + return ExportPipelineResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *exportPipelinePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *exportPipelinePoller) pollUntilDone(ctx context.Context, freq time.Duration) (ExportPipelineResponse, error) { + respType := ExportPipelineResponse{ExportPipeline: &ExportPipeline{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.ExportPipeline) + if err != nil { + return ExportPipelineResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// GenerateCredentialsResultPoller provides polling facilities until the operation reaches a terminal state. +type GenerateCredentialsResultPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final GenerateCredentialsResultResponse will be returned. + FinalResponse(ctx context.Context) (GenerateCredentialsResultResponse, error) +} + +type generateCredentialsResultPoller struct { + pt *armcore.LROPoller +} + +func (p *generateCredentialsResultPoller) Done() bool { + return p.pt.Done() +} + +func (p *generateCredentialsResultPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *generateCredentialsResultPoller) FinalResponse(ctx context.Context) (GenerateCredentialsResultResponse, error) { + respType := GenerateCredentialsResultResponse{GenerateCredentialsResult: &GenerateCredentialsResult{}} + resp, err := p.pt.FinalResponse(ctx, respType.GenerateCredentialsResult) + if err != nil { + return GenerateCredentialsResultResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *generateCredentialsResultPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *generateCredentialsResultPoller) pollUntilDone(ctx context.Context, freq time.Duration) (GenerateCredentialsResultResponse, error) { + respType := GenerateCredentialsResultResponse{GenerateCredentialsResult: &GenerateCredentialsResult{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.GenerateCredentialsResult) + if err != nil { + return GenerateCredentialsResultResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// HTTPPoller provides polling facilities until the operation reaches a terminal state. +type HTTPPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final *http.Response will be returned. + FinalResponse(ctx context.Context) (*http.Response, error) +} + +type httpPoller struct { + pt *armcore.LROPoller +} + +func (p *httpPoller) Done() bool { + return p.pt.Done() +} + +func (p *httpPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *httpPoller) FinalResponse(ctx context.Context) (*http.Response, error) { + return p.pt.FinalResponse(ctx, nil) +} + +func (p *httpPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *httpPoller) pollUntilDone(ctx context.Context, freq time.Duration) (*http.Response, error) { + return p.pt.PollUntilDone(ctx, freq, nil) +} + +// ImportPipelinePoller provides polling facilities until the operation reaches a terminal state. +type ImportPipelinePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ImportPipelineResponse will be returned. + FinalResponse(ctx context.Context) (ImportPipelineResponse, error) +} + +type importPipelinePoller struct { + pt *armcore.LROPoller +} + +func (p *importPipelinePoller) Done() bool { + return p.pt.Done() +} + +func (p *importPipelinePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *importPipelinePoller) FinalResponse(ctx context.Context) (ImportPipelineResponse, error) { + respType := ImportPipelineResponse{ImportPipeline: &ImportPipeline{}} + resp, err := p.pt.FinalResponse(ctx, respType.ImportPipeline) + if err != nil { + return ImportPipelineResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *importPipelinePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *importPipelinePoller) pollUntilDone(ctx context.Context, freq time.Duration) (ImportPipelineResponse, error) { + respType := ImportPipelineResponse{ImportPipeline: &ImportPipeline{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.ImportPipeline) + if err != nil { + return ImportPipelineResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// PipelineRunPoller provides polling facilities until the operation reaches a terminal state. +type PipelineRunPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final PipelineRunResponseType will be returned. + FinalResponse(ctx context.Context) (PipelineRunResponseType, error) +} + +type pipelineRunPoller struct { + pt *armcore.LROPoller +} + +func (p *pipelineRunPoller) Done() bool { + return p.pt.Done() +} + +func (p *pipelineRunPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *pipelineRunPoller) FinalResponse(ctx context.Context) (PipelineRunResponseType, error) { + respType := PipelineRunResponseType{PipelineRun: &PipelineRun{}} + resp, err := p.pt.FinalResponse(ctx, respType.PipelineRun) + if err != nil { + return PipelineRunResponseType{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *pipelineRunPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *pipelineRunPoller) pollUntilDone(ctx context.Context, freq time.Duration) (PipelineRunResponseType, error) { + respType := PipelineRunResponseType{PipelineRun: &PipelineRun{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.PipelineRun) + if err != nil { + return PipelineRunResponseType{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// PrivateEndpointConnectionPoller provides polling facilities until the operation reaches a terminal state. +type PrivateEndpointConnectionPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final PrivateEndpointConnectionResponse will be returned. + FinalResponse(ctx context.Context) (PrivateEndpointConnectionResponse, error) +} + +type privateEndpointConnectionPoller struct { + pt *armcore.LROPoller +} + +func (p *privateEndpointConnectionPoller) Done() bool { + return p.pt.Done() +} + +func (p *privateEndpointConnectionPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *privateEndpointConnectionPoller) FinalResponse(ctx context.Context) (PrivateEndpointConnectionResponse, error) { + respType := PrivateEndpointConnectionResponse{PrivateEndpointConnection: &PrivateEndpointConnection{}} + resp, err := p.pt.FinalResponse(ctx, respType.PrivateEndpointConnection) + if err != nil { + return PrivateEndpointConnectionResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *privateEndpointConnectionPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *privateEndpointConnectionPoller) pollUntilDone(ctx context.Context, freq time.Duration) (PrivateEndpointConnectionResponse, error) { + respType := PrivateEndpointConnectionResponse{PrivateEndpointConnection: &PrivateEndpointConnection{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.PrivateEndpointConnection) + if err != nil { + return PrivateEndpointConnectionResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// RegistryPoller provides polling facilities until the operation reaches a terminal state. +type RegistryPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final RegistryResponse will be returned. + FinalResponse(ctx context.Context) (RegistryResponse, error) +} + +type registryPoller struct { + pt *armcore.LROPoller +} + +func (p *registryPoller) Done() bool { + return p.pt.Done() +} + +func (p *registryPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *registryPoller) FinalResponse(ctx context.Context) (RegistryResponse, error) { + respType := RegistryResponse{Registry: &Registry{}} + resp, err := p.pt.FinalResponse(ctx, respType.Registry) + if err != nil { + return RegistryResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *registryPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *registryPoller) pollUntilDone(ctx context.Context, freq time.Duration) (RegistryResponse, error) { + respType := RegistryResponse{Registry: &Registry{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.Registry) + if err != nil { + return RegistryResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ReplicationPoller provides polling facilities until the operation reaches a terminal state. +type ReplicationPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ReplicationResponse will be returned. + FinalResponse(ctx context.Context) (ReplicationResponse, error) +} + +type replicationPoller struct { + pt *armcore.LROPoller +} + +func (p *replicationPoller) Done() bool { + return p.pt.Done() +} + +func (p *replicationPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *replicationPoller) FinalResponse(ctx context.Context) (ReplicationResponse, error) { + respType := ReplicationResponse{Replication: &Replication{}} + resp, err := p.pt.FinalResponse(ctx, respType.Replication) + if err != nil { + return ReplicationResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *replicationPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *replicationPoller) pollUntilDone(ctx context.Context, freq time.Duration) (ReplicationResponse, error) { + respType := ReplicationResponse{Replication: &Replication{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.Replication) + if err != nil { + return ReplicationResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// RunPoller provides polling facilities until the operation reaches a terminal state. +type RunPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final RunResponse will be returned. + FinalResponse(ctx context.Context) (RunResponse, error) +} + +type runPoller struct { + pt *armcore.LROPoller +} + +func (p *runPoller) Done() bool { + return p.pt.Done() +} + +func (p *runPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *runPoller) FinalResponse(ctx context.Context) (RunResponse, error) { + respType := RunResponse{Run: &Run{}} + resp, err := p.pt.FinalResponse(ctx, respType.Run) + if err != nil { + return RunResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *runPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *runPoller) pollUntilDone(ctx context.Context, freq time.Duration) (RunResponse, error) { + respType := RunResponse{Run: &Run{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.Run) + if err != nil { + return RunResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ScopeMapPoller provides polling facilities until the operation reaches a terminal state. +type ScopeMapPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final ScopeMapResponse will be returned. + FinalResponse(ctx context.Context) (ScopeMapResponse, error) +} + +type scopeMapPoller struct { + pt *armcore.LROPoller +} + +func (p *scopeMapPoller) Done() bool { + return p.pt.Done() +} + +func (p *scopeMapPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *scopeMapPoller) FinalResponse(ctx context.Context) (ScopeMapResponse, error) { + respType := ScopeMapResponse{ScopeMap: &ScopeMap{}} + resp, err := p.pt.FinalResponse(ctx, respType.ScopeMap) + if err != nil { + return ScopeMapResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *scopeMapPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *scopeMapPoller) pollUntilDone(ctx context.Context, freq time.Duration) (ScopeMapResponse, error) { + respType := ScopeMapResponse{ScopeMap: &ScopeMap{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.ScopeMap) + if err != nil { + return ScopeMapResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// TaskPoller provides polling facilities until the operation reaches a terminal state. +type TaskPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final TaskResponse will be returned. + FinalResponse(ctx context.Context) (TaskResponse, error) +} + +type taskPoller struct { + pt *armcore.LROPoller +} + +func (p *taskPoller) Done() bool { + return p.pt.Done() +} + +func (p *taskPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *taskPoller) FinalResponse(ctx context.Context) (TaskResponse, error) { + respType := TaskResponse{Task: &Task{}} + resp, err := p.pt.FinalResponse(ctx, respType.Task) + if err != nil { + return TaskResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *taskPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *taskPoller) pollUntilDone(ctx context.Context, freq time.Duration) (TaskResponse, error) { + respType := TaskResponse{Task: &Task{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.Task) + if err != nil { + return TaskResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// TaskRunPoller provides polling facilities until the operation reaches a terminal state. +type TaskRunPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final TaskRunResponse will be returned. + FinalResponse(ctx context.Context) (TaskRunResponse, error) +} + +type taskRunPoller struct { + pt *armcore.LROPoller +} + +func (p *taskRunPoller) Done() bool { + return p.pt.Done() +} + +func (p *taskRunPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *taskRunPoller) FinalResponse(ctx context.Context) (TaskRunResponse, error) { + respType := TaskRunResponse{TaskRun: &TaskRun{}} + resp, err := p.pt.FinalResponse(ctx, respType.TaskRun) + if err != nil { + return TaskRunResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *taskRunPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *taskRunPoller) pollUntilDone(ctx context.Context, freq time.Duration) (TaskRunResponse, error) { + respType := TaskRunResponse{TaskRun: &TaskRun{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.TaskRun) + if err != nil { + return TaskRunResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// TokenPoller provides polling facilities until the operation reaches a terminal state. +type TokenPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final TokenResponse will be returned. + FinalResponse(ctx context.Context) (TokenResponse, error) +} + +type tokenPoller struct { + pt *armcore.LROPoller +} + +func (p *tokenPoller) Done() bool { + return p.pt.Done() +} + +func (p *tokenPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *tokenPoller) FinalResponse(ctx context.Context) (TokenResponse, error) { + respType := TokenResponse{Token: &Token{}} + resp, err := p.pt.FinalResponse(ctx, respType.Token) + if err != nil { + return TokenResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *tokenPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *tokenPoller) pollUntilDone(ctx context.Context, freq time.Duration) (TokenResponse, error) { + respType := TokenResponse{Token: &Token{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.Token) + if err != nil { + return TokenResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// WebhookPoller provides polling facilities until the operation reaches a terminal state. +type WebhookPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final WebhookResponse will be returned. + FinalResponse(ctx context.Context) (WebhookResponse, error) +} + +type webhookPoller struct { + pt *armcore.LROPoller +} + +func (p *webhookPoller) Done() bool { + return p.pt.Done() +} + +func (p *webhookPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *webhookPoller) FinalResponse(ctx context.Context) (WebhookResponse, error) { + respType := WebhookResponse{Webhook: &Webhook{}} + resp, err := p.pt.FinalResponse(ctx, respType.Webhook) + if err != nil { + return WebhookResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *webhookPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *webhookPoller) pollUntilDone(ctx context.Context, freq time.Duration) (WebhookResponse, error) { + respType := WebhookResponse{Webhook: &Webhook{}} + resp, err := p.pt.PollUntilDone(ctx, freq, respType.Webhook) + if err != nil { + return WebhookResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_polymorphic_helpers.go b/sdk/containerregistry/armcontainerregistry/zz_generated_polymorphic_helpers.go new file mode 100644 index 000000000000..e8ba47351648 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_polymorphic_helpers.go @@ -0,0 +1,135 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import "encoding/json" + +func unmarshalRunRequestClassification(rawMsg json.RawMessage) (RunRequestClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b RunRequestClassification + switch m["type"] { + case "DockerBuildRequest": + b = &DockerBuildRequest{} + case "EncodedTaskRunRequest": + b = &EncodedTaskRunRequest{} + case "FileTaskRunRequest": + b = &FileTaskRunRequest{} + case "TaskRunRequest": + b = &TaskRunRequest{} + default: + b = &RunRequest{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalRunRequestClassificationArray(rawMsg json.RawMessage) ([]RunRequestClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]RunRequestClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalRunRequestClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalTaskStepPropertiesClassification(rawMsg json.RawMessage) (TaskStepPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b TaskStepPropertiesClassification + switch m["type"] { + case string(StepTypeDocker): + b = &DockerBuildStep{} + case string(StepTypeEncodedTask): + b = &EncodedTaskStep{} + case string(StepTypeFileTask): + b = &FileTaskStep{} + default: + b = &TaskStepProperties{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalTaskStepPropertiesClassificationArray(rawMsg json.RawMessage) ([]TaskStepPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]TaskStepPropertiesClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalTaskStepPropertiesClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} + +func unmarshalTaskStepUpdateParametersClassification(rawMsg json.RawMessage) (TaskStepUpdateParametersClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b TaskStepUpdateParametersClassification + switch m["type"] { + case string(StepTypeDocker): + b = &DockerBuildStepUpdateParameters{} + case string(StepTypeEncodedTask): + b = &EncodedTaskStepUpdateParameters{} + case string(StepTypeFileTask): + b = &FileTaskStepUpdateParameters{} + default: + b = &TaskStepUpdateParameters{} + } + return b, json.Unmarshal(rawMsg, b) +} + +func unmarshalTaskStepUpdateParametersClassificationArray(rawMsg json.RawMessage) ([]TaskStepUpdateParametersClassification, error) { + if rawMsg == nil { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]TaskStepUpdateParametersClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalTaskStepUpdateParametersClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_privateendpointconnections_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_privateendpointconnections_client.go new file mode 100644 index 000000000000..4e0f5094ff6d --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_privateendpointconnections_client.go @@ -0,0 +1,380 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// PrivateEndpointConnectionsClient contains the methods for the PrivateEndpointConnections group. +// Don't use this type directly, use NewPrivateEndpointConnectionsClient() instead. +type PrivateEndpointConnectionsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. +func NewPrivateEndpointConnectionsClient(con *armcore.Connection, subscriptionID string) *PrivateEndpointConnectionsClient { + return &PrivateEndpointConnectionsClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreateOrUpdate - Update the state of specified private endpoint connection associated with the container registry. +// If the operation fails it returns a generic error. +func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, registryName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOrUpdateOptions) (PrivateEndpointConnectionPollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, registryName, privateEndpointConnectionName, privateEndpointConnection, options) + if err != nil { + return PrivateEndpointConnectionPollerResponse{}, err + } + result := PrivateEndpointConnectionPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("PrivateEndpointConnectionsClient.CreateOrUpdate", "", resp, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return PrivateEndpointConnectionPollerResponse{}, err + } + poller := &privateEndpointConnectionPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (PrivateEndpointConnectionResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreateOrUpdate creates a new PrivateEndpointConnectionPoller from the specified resume token. +// token - The value must come from a previous call to PrivateEndpointConnectionPoller.ResumeToken(). +func (client *PrivateEndpointConnectionsClient) ResumeCreateOrUpdate(ctx context.Context, token string) (PrivateEndpointConnectionPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("PrivateEndpointConnectionsClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return PrivateEndpointConnectionPollerResponse{}, err + } + poller := &privateEndpointConnectionPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return PrivateEndpointConnectionPollerResponse{}, err + } + result := PrivateEndpointConnectionPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (PrivateEndpointConnectionResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// CreateOrUpdate - Update the state of specified private endpoint connection associated with the container registry. +// If the operation fails it returns a generic error. +func (client *PrivateEndpointConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, registryName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOrUpdateOptions) (*azcore.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, registryName, privateEndpointConnectionName, privateEndpointConnection, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *PrivateEndpointConnectionsBeginCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(privateEndpointConnection) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PrivateEndpointConnectionsClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginDelete - Deletes the specified private endpoint connection associated with the container registry. +// If the operation fails it returns a generic error. +func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, privateEndpointConnectionName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("PrivateEndpointConnectionsClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *PrivateEndpointConnectionsClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("PrivateEndpointConnectionsClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes the specified private endpoint connection associated with the container registry. +// If the operation fails it returns a generic error. +func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, privateEndpointConnectionName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PrivateEndpointConnectionsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Get the specified private endpoint connection associated with the container registry. +// If the operation fails it returns a generic error. +func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, registryName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (PrivateEndpointConnectionResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, privateEndpointConnectionName, options) + if err != nil { + return PrivateEndpointConnectionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PrivateEndpointConnectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PrivateEndpointConnectionResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections/{privateEndpointConnectionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if privateEndpointConnectionName == "" { + return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *azcore.Response) (PrivateEndpointConnectionResponse, error) { + var val *PrivateEndpointConnection + if err := resp.UnmarshalAsJSON(&val); err != nil { + return PrivateEndpointConnectionResponse{}, err + } + return PrivateEndpointConnectionResponse{RawResponse: resp.Response, PrivateEndpointConnection: val}, nil +} + +// getHandleError handles the Get error response. +func (client *PrivateEndpointConnectionsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// List - List all private endpoint connections in a container registry. +// If the operation fails it returns a generic error. +func (client *PrivateEndpointConnectionsClient) List(resourceGroupName string, registryName string, options *PrivateEndpointConnectionsListOptions) PrivateEndpointConnectionListResultPager { + return &privateEndpointConnectionListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp PrivateEndpointConnectionListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.PrivateEndpointConnectionListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *PrivateEndpointConnectionsListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateEndpointConnections" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PrivateEndpointConnectionsClient) listHandleResponse(resp *azcore.Response) (PrivateEndpointConnectionListResultResponse, error) { + var val *PrivateEndpointConnectionListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return PrivateEndpointConnectionListResultResponse{}, err + } + return PrivateEndpointConnectionListResultResponse{RawResponse: resp.Response, PrivateEndpointConnectionListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *PrivateEndpointConnectionsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_registries_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_registries_client.go new file mode 100644 index 000000000000..6b75c97f355a --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_registries_client.go @@ -0,0 +1,1222 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// RegistriesClient contains the methods for the Registries group. +// Don't use this type directly, use NewRegistriesClient() instead. +type RegistriesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewRegistriesClient creates a new instance of RegistriesClient with the specified values. +func NewRegistriesClient(con *armcore.Connection, subscriptionID string) *RegistriesClient { + return &RegistriesClient{con: con, subscriptionID: subscriptionID} +} + +// CheckNameAvailability - Checks whether the container registry name is available for use. The name must contain only alphanumeric characters, be globally +// unique, and between 5 and 50 characters in length. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) CheckNameAvailability(ctx context.Context, registryNameCheckRequest RegistryNameCheckRequest, options *RegistriesCheckNameAvailabilityOptions) (RegistryNameStatusResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, registryNameCheckRequest, options) + if err != nil { + return RegistryNameStatusResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return RegistryNameStatusResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return RegistryNameStatusResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *RegistriesClient) checkNameAvailabilityCreateRequest(ctx context.Context, registryNameCheckRequest RegistryNameCheckRequest, options *RegistriesCheckNameAvailabilityOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(registryNameCheckRequest) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *RegistriesClient) checkNameAvailabilityHandleResponse(resp *azcore.Response) (RegistryNameStatusResponse, error) { + var val *RegistryNameStatus + if err := resp.UnmarshalAsJSON(&val); err != nil { + return RegistryNameStatusResponse{}, err + } + return RegistryNameStatusResponse{RawResponse: resp.Response, RegistryNameStatus: val}, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *RegistriesClient) checkNameAvailabilityHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginCreate - Creates a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, registry Registry, options *RegistriesBeginCreateOptions) (RegistryPollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, registryName, registry, options) + if err != nil { + return RegistryPollerResponse{}, err + } + result := RegistryPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("RegistriesClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return RegistryPollerResponse{}, err + } + poller := ®istryPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RegistryResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new RegistryPoller from the specified resume token. +// token - The value must come from a previous call to RegistryPoller.ResumeToken(). +func (client *RegistriesClient) ResumeCreate(ctx context.Context, token string) (RegistryPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("RegistriesClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return RegistryPollerResponse{}, err + } + poller := ®istryPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return RegistryPollerResponse{}, err + } + result := RegistryPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RegistryResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) create(ctx context.Context, resourceGroupName string, registryName string, registry Registry, options *RegistriesBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, registry, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *RegistriesClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, registry Registry, options *RegistriesBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(registry) +} + +// createHandleError handles the Create error response. +func (client *RegistriesClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginDelete - Deletes a container registry. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("RegistriesClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *RegistriesClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("RegistriesClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a container registry. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *RegistriesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *RegistriesClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginGenerateCredentials - Generate keys for a token of a specified container registry. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) BeginGenerateCredentials(ctx context.Context, resourceGroupName string, registryName string, generateCredentialsParameters GenerateCredentialsParameters, options *RegistriesBeginGenerateCredentialsOptions) (GenerateCredentialsResultPollerResponse, error) { + resp, err := client.generateCredentials(ctx, resourceGroupName, registryName, generateCredentialsParameters, options) + if err != nil { + return GenerateCredentialsResultPollerResponse{}, err + } + result := GenerateCredentialsResultPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("RegistriesClient.GenerateCredentials", "", resp, client.con.Pipeline(), client.generateCredentialsHandleError) + if err != nil { + return GenerateCredentialsResultPollerResponse{}, err + } + poller := &generateCredentialsResultPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (GenerateCredentialsResultResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeGenerateCredentials creates a new GenerateCredentialsResultPoller from the specified resume token. +// token - The value must come from a previous call to GenerateCredentialsResultPoller.ResumeToken(). +func (client *RegistriesClient) ResumeGenerateCredentials(ctx context.Context, token string) (GenerateCredentialsResultPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("RegistriesClient.GenerateCredentials", token, client.con.Pipeline(), client.generateCredentialsHandleError) + if err != nil { + return GenerateCredentialsResultPollerResponse{}, err + } + poller := &generateCredentialsResultPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return GenerateCredentialsResultPollerResponse{}, err + } + result := GenerateCredentialsResultPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (GenerateCredentialsResultResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// GenerateCredentials - Generate keys for a token of a specified container registry. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) generateCredentials(ctx context.Context, resourceGroupName string, registryName string, generateCredentialsParameters GenerateCredentialsParameters, options *RegistriesBeginGenerateCredentialsOptions) (*azcore.Response, error) { + req, err := client.generateCredentialsCreateRequest(ctx, resourceGroupName, registryName, generateCredentialsParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.generateCredentialsHandleError(resp) + } + return resp, nil +} + +// generateCredentialsCreateRequest creates the GenerateCredentials request. +func (client *RegistriesClient) generateCredentialsCreateRequest(ctx context.Context, resourceGroupName string, registryName string, generateCredentialsParameters GenerateCredentialsParameters, options *RegistriesBeginGenerateCredentialsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(generateCredentialsParameters) +} + +// generateCredentialsHandleError handles the GenerateCredentials error response. +func (client *RegistriesClient) generateCredentialsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets the properties of the specified container registry. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) Get(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesGetOptions) (RegistryResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, options) + if err != nil { + return RegistryResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return RegistryResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return RegistryResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *RegistriesClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RegistriesClient) getHandleResponse(resp *azcore.Response) (RegistryResponse, error) { + var val *Registry + if err := resp.UnmarshalAsJSON(&val); err != nil { + return RegistryResponse{}, err + } + return RegistryResponse{RawResponse: resp.Response, Registry: val}, nil +} + +// getHandleError handles the Get error response. +func (client *RegistriesClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// GetBuildSourceUploadURL - Get the upload location for the user to be able to upload the source. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistriesClient) GetBuildSourceUploadURL(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesGetBuildSourceUploadURLOptions) (SourceUploadDefinitionResponse, error) { + req, err := client.getBuildSourceUploadURLCreateRequest(ctx, resourceGroupName, registryName, options) + if err != nil { + return SourceUploadDefinitionResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SourceUploadDefinitionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SourceUploadDefinitionResponse{}, client.getBuildSourceUploadURLHandleError(resp) + } + return client.getBuildSourceUploadURLHandleResponse(resp) +} + +// getBuildSourceUploadURLCreateRequest creates the GetBuildSourceUploadURL request. +func (client *RegistriesClient) getBuildSourceUploadURLCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesGetBuildSourceUploadURLOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getBuildSourceUploadURLHandleResponse handles the GetBuildSourceUploadURL response. +func (client *RegistriesClient) getBuildSourceUploadURLHandleResponse(resp *azcore.Response) (SourceUploadDefinitionResponse, error) { + var val *SourceUploadDefinition + if err := resp.UnmarshalAsJSON(&val); err != nil { + return SourceUploadDefinitionResponse{}, err + } + return SourceUploadDefinitionResponse{RawResponse: resp.Response, SourceUploadDefinition: val}, nil +} + +// getBuildSourceUploadURLHandleError handles the GetBuildSourceUploadURL error response. +func (client *RegistriesClient) getBuildSourceUploadURLHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginImportImage - Copies an image to this container registry from the specified container registry. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) BeginImportImage(ctx context.Context, resourceGroupName string, registryName string, parameters ImportImageParameters, options *RegistriesBeginImportImageOptions) (HTTPPollerResponse, error) { + resp, err := client.importImage(ctx, resourceGroupName, registryName, parameters, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("RegistriesClient.ImportImage", "", resp, client.con.Pipeline(), client.importImageHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeImportImage creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *RegistriesClient) ResumeImportImage(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("RegistriesClient.ImportImage", token, client.con.Pipeline(), client.importImageHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ImportImage - Copies an image to this container registry from the specified container registry. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) importImage(ctx context.Context, resourceGroupName string, registryName string, parameters ImportImageParameters, options *RegistriesBeginImportImageOptions) (*azcore.Response, error) { + req, err := client.importImageCreateRequest(ctx, resourceGroupName, registryName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.importImageHandleError(resp) + } + return resp, nil +} + +// importImageCreateRequest creates the ImportImage request. +func (client *RegistriesClient) importImageCreateRequest(ctx context.Context, resourceGroupName string, registryName string, parameters ImportImageParameters, options *RegistriesBeginImportImageOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + return req, req.MarshalAsJSON(parameters) +} + +// importImageHandleError handles the ImportImage error response. +func (client *RegistriesClient) importImageHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// List - Lists all the container registries under the specified subscription. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) List(options *RegistriesListOptions) RegistryListResultPager { + return ®istryListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp RegistryListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.RegistryListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *RegistriesClient) listCreateRequest(ctx context.Context, options *RegistriesListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *RegistriesClient) listHandleResponse(resp *azcore.Response) (RegistryListResultResponse, error) { + var val *RegistryListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return RegistryListResultResponse{}, err + } + return RegistryListResultResponse{RawResponse: resp.Response, RegistryListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *RegistriesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListByResourceGroup - Lists all the container registries under the specified resource group. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) ListByResourceGroup(resourceGroupName string, options *RegistriesListByResourceGroupOptions) RegistryListResultPager { + return ®istryListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + responder: client.listByResourceGroupHandleResponse, + errorer: client.listByResourceGroupHandleError, + advancer: func(ctx context.Context, resp RegistryListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.RegistryListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *RegistriesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *RegistriesListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *RegistriesClient) listByResourceGroupHandleResponse(resp *azcore.Response) (RegistryListResultResponse, error) { + var val *RegistryListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return RegistryListResultResponse{}, err + } + return RegistryListResultResponse{RawResponse: resp.Response, RegistryListResult: val}, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *RegistriesClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListCredentials - Lists the login credentials for the specified container registry. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) ListCredentials(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesListCredentialsOptions) (RegistryListCredentialsResultResponse, error) { + req, err := client.listCredentialsCreateRequest(ctx, resourceGroupName, registryName, options) + if err != nil { + return RegistryListCredentialsResultResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return RegistryListCredentialsResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return RegistryListCredentialsResultResponse{}, client.listCredentialsHandleError(resp) + } + return client.listCredentialsHandleResponse(resp) +} + +// listCredentialsCreateRequest creates the ListCredentials request. +func (client *RegistriesClient) listCredentialsCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesListCredentialsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listCredentialsHandleResponse handles the ListCredentials response. +func (client *RegistriesClient) listCredentialsHandleResponse(resp *azcore.Response) (RegistryListCredentialsResultResponse, error) { + var val *RegistryListCredentialsResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return RegistryListCredentialsResultResponse{}, err + } + return RegistryListCredentialsResultResponse{RawResponse: resp.Response, RegistryListCredentialsResult: val}, nil +} + +// listCredentialsHandleError handles the ListCredentials error response. +func (client *RegistriesClient) listCredentialsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListPrivateLinkResources - Lists the private link resources for a container registry. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) ListPrivateLinkResources(resourceGroupName string, registryName string, options *RegistriesListPrivateLinkResourcesOptions) PrivateLinkResourceListResultPager { + return &privateLinkResourceListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listPrivateLinkResourcesCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listPrivateLinkResourcesHandleResponse, + errorer: client.listPrivateLinkResourcesHandleError, + advancer: func(ctx context.Context, resp PrivateLinkResourceListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.PrivateLinkResourceListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listPrivateLinkResourcesCreateRequest creates the ListPrivateLinkResources request. +func (client *RegistriesClient) listPrivateLinkResourcesCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesListPrivateLinkResourcesOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/privateLinkResources" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listPrivateLinkResourcesHandleResponse handles the ListPrivateLinkResources response. +func (client *RegistriesClient) listPrivateLinkResourcesHandleResponse(resp *azcore.Response) (PrivateLinkResourceListResultResponse, error) { + var val *PrivateLinkResourceListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return PrivateLinkResourceListResultResponse{}, err + } + return PrivateLinkResourceListResultResponse{RawResponse: resp.Response, PrivateLinkResourceListResult: val}, nil +} + +// listPrivateLinkResourcesHandleError handles the ListPrivateLinkResources error response. +func (client *RegistriesClient) listPrivateLinkResourcesHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListUsages - Gets the quota usages for the specified container registry. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) ListUsages(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesListUsagesOptions) (RegistryUsageListResultResponse, error) { + req, err := client.listUsagesCreateRequest(ctx, resourceGroupName, registryName, options) + if err != nil { + return RegistryUsageListResultResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return RegistryUsageListResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return RegistryUsageListResultResponse{}, client.listUsagesHandleError(resp) + } + return client.listUsagesHandleResponse(resp) +} + +// listUsagesCreateRequest creates the ListUsages request. +func (client *RegistriesClient) listUsagesCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesListUsagesOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listUsagesHandleResponse handles the ListUsages response. +func (client *RegistriesClient) listUsagesHandleResponse(resp *azcore.Response) (RegistryUsageListResultResponse, error) { + var val *RegistryUsageListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return RegistryUsageListResultResponse{}, err + } + return RegistryUsageListResultResponse{RawResponse: resp.Response, RegistryUsageListResult: val}, nil +} + +// listUsagesHandleError handles the ListUsages error response. +func (client *RegistriesClient) listUsagesHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// RegenerateCredential - Regenerates one of the login credentials for the specified container registry. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) RegenerateCredential(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters, options *RegistriesRegenerateCredentialOptions) (RegistryListCredentialsResultResponse, error) { + req, err := client.regenerateCredentialCreateRequest(ctx, resourceGroupName, registryName, regenerateCredentialParameters, options) + if err != nil { + return RegistryListCredentialsResultResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return RegistryListCredentialsResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return RegistryListCredentialsResultResponse{}, client.regenerateCredentialHandleError(resp) + } + return client.regenerateCredentialHandleResponse(resp) +} + +// regenerateCredentialCreateRequest creates the RegenerateCredential request. +func (client *RegistriesClient) regenerateCredentialCreateRequest(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters, options *RegistriesRegenerateCredentialOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(regenerateCredentialParameters) +} + +// regenerateCredentialHandleResponse handles the RegenerateCredential response. +func (client *RegistriesClient) regenerateCredentialHandleResponse(resp *azcore.Response) (RegistryListCredentialsResultResponse, error) { + var val *RegistryListCredentialsResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return RegistryListCredentialsResultResponse{}, err + } + return RegistryListCredentialsResultResponse{RawResponse: resp.Response, RegistryListCredentialsResult: val}, nil +} + +// regenerateCredentialHandleError handles the RegenerateCredential error response. +func (client *RegistriesClient) regenerateCredentialHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginScheduleRun - Schedules a new run based on the request parameters and add it to the run queue. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistriesClient) BeginScheduleRun(ctx context.Context, resourceGroupName string, registryName string, runRequest RunRequestClassification, options *RegistriesBeginScheduleRunOptions) (RunPollerResponse, error) { + resp, err := client.scheduleRun(ctx, resourceGroupName, registryName, runRequest, options) + if err != nil { + return RunPollerResponse{}, err + } + result := RunPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("RegistriesClient.ScheduleRun", "", resp, client.con.Pipeline(), client.scheduleRunHandleError) + if err != nil { + return RunPollerResponse{}, err + } + poller := &runPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RunResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeScheduleRun creates a new RunPoller from the specified resume token. +// token - The value must come from a previous call to RunPoller.ResumeToken(). +func (client *RegistriesClient) ResumeScheduleRun(ctx context.Context, token string) (RunPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("RegistriesClient.ScheduleRun", token, client.con.Pipeline(), client.scheduleRunHandleError) + if err != nil { + return RunPollerResponse{}, err + } + poller := &runPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return RunPollerResponse{}, err + } + result := RunPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RunResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ScheduleRun - Schedules a new run based on the request parameters and add it to the run queue. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegistriesClient) scheduleRun(ctx context.Context, resourceGroupName string, registryName string, runRequest RunRequestClassification, options *RegistriesBeginScheduleRunOptions) (*azcore.Response, error) { + req, err := client.scheduleRunCreateRequest(ctx, resourceGroupName, registryName, runRequest, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.scheduleRunHandleError(resp) + } + return resp, nil +} + +// scheduleRunCreateRequest creates the ScheduleRun request. +func (client *RegistriesClient) scheduleRunCreateRequest(ctx context.Context, resourceGroupName string, registryName string, runRequest RunRequestClassification, options *RegistriesBeginScheduleRunOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(runRequest) +} + +// scheduleRunHandleError handles the ScheduleRun error response. +func (client *RegistriesClient) scheduleRunHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginUpdate - Updates a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) BeginUpdate(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters, options *RegistriesBeginUpdateOptions) (RegistryPollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, registryName, registryUpdateParameters, options) + if err != nil { + return RegistryPollerResponse{}, err + } + result := RegistryPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("RegistriesClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return RegistryPollerResponse{}, err + } + poller := ®istryPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RegistryResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new RegistryPoller from the specified resume token. +// token - The value must come from a previous call to RegistryPoller.ResumeToken(). +func (client *RegistriesClient) ResumeUpdate(ctx context.Context, token string) (RegistryPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("RegistriesClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return RegistryPollerResponse{}, err + } + poller := ®istryPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return RegistryPollerResponse{}, err + } + result := RegistryPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RegistryResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *RegistriesClient) update(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters, options *RegistriesBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, registryUpdateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *RegistriesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters, options *RegistriesBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(registryUpdateParameters) +} + +// updateHandleError handles the Update error response. +func (client *RegistriesClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_replications_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_replications_client.go new file mode 100644 index 000000000000..c2f0968b032d --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_replications_client.go @@ -0,0 +1,488 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// ReplicationsClient contains the methods for the Replications group. +// Don't use this type directly, use NewReplicationsClient() instead. +type ReplicationsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewReplicationsClient creates a new instance of ReplicationsClient with the specified values. +func NewReplicationsClient(con *armcore.Connection, subscriptionID string) *ReplicationsClient { + return &ReplicationsClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Creates a replication for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *ReplicationsClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replication Replication, options *ReplicationsBeginCreateOptions) (ReplicationPollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, registryName, replicationName, replication, options) + if err != nil { + return ReplicationPollerResponse{}, err + } + result := ReplicationPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ReplicationsClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return ReplicationPollerResponse{}, err + } + poller := &replicationPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ReplicationResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new ReplicationPoller from the specified resume token. +// token - The value must come from a previous call to ReplicationPoller.ResumeToken(). +func (client *ReplicationsClient) ResumeCreate(ctx context.Context, token string) (ReplicationPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ReplicationsClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return ReplicationPollerResponse{}, err + } + poller := &replicationPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ReplicationPollerResponse{}, err + } + result := ReplicationPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ReplicationResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates a replication for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *ReplicationsClient) create(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replication Replication, options *ReplicationsBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, replicationName, replication, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *ReplicationsClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replication Replication, options *ReplicationsBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if replicationName == "" { + return nil, errors.New("parameter replicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{replicationName}", url.PathEscape(replicationName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(replication) +} + +// createHandleError handles the Create error response. +func (client *ReplicationsClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginDelete - Deletes a replication from a container registry. +// If the operation fails it returns a generic error. +func (client *ReplicationsClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, replicationName string, options *ReplicationsBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, replicationName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ReplicationsClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *ReplicationsClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ReplicationsClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a replication from a container registry. +// If the operation fails it returns a generic error. +func (client *ReplicationsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, replicationName string, options *ReplicationsBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, replicationName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ReplicationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, replicationName string, options *ReplicationsBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if replicationName == "" { + return nil, errors.New("parameter replicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{replicationName}", url.PathEscape(replicationName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ReplicationsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets the properties of the specified replication. +// If the operation fails it returns a generic error. +func (client *ReplicationsClient) Get(ctx context.Context, resourceGroupName string, registryName string, replicationName string, options *ReplicationsGetOptions) (ReplicationResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, replicationName, options) + if err != nil { + return ReplicationResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ReplicationResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ReplicationResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ReplicationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, replicationName string, options *ReplicationsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if replicationName == "" { + return nil, errors.New("parameter replicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{replicationName}", url.PathEscape(replicationName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ReplicationsClient) getHandleResponse(resp *azcore.Response) (ReplicationResponse, error) { + var val *Replication + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ReplicationResponse{}, err + } + return ReplicationResponse{RawResponse: resp.Response, Replication: val}, nil +} + +// getHandleError handles the Get error response. +func (client *ReplicationsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// List - Lists all the replications for the specified container registry. +// If the operation fails it returns a generic error. +func (client *ReplicationsClient) List(resourceGroupName string, registryName string, options *ReplicationsListOptions) ReplicationListResultPager { + return &replicationListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp ReplicationListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ReplicationListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *ReplicationsClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *ReplicationsListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ReplicationsClient) listHandleResponse(resp *azcore.Response) (ReplicationListResultResponse, error) { + var val *ReplicationListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ReplicationListResultResponse{}, err + } + return ReplicationListResultResponse{RawResponse: resp.Response, ReplicationListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *ReplicationsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginUpdate - Updates a replication for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *ReplicationsClient) BeginUpdate(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replicationUpdateParameters ReplicationUpdateParameters, options *ReplicationsBeginUpdateOptions) (ReplicationPollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, registryName, replicationName, replicationUpdateParameters, options) + if err != nil { + return ReplicationPollerResponse{}, err + } + result := ReplicationPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ReplicationsClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return ReplicationPollerResponse{}, err + } + poller := &replicationPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ReplicationResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new ReplicationPoller from the specified resume token. +// token - The value must come from a previous call to ReplicationPoller.ResumeToken(). +func (client *ReplicationsClient) ResumeUpdate(ctx context.Context, token string) (ReplicationPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ReplicationsClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return ReplicationPollerResponse{}, err + } + poller := &replicationPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ReplicationPollerResponse{}, err + } + result := ReplicationPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ReplicationResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates a replication for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *ReplicationsClient) update(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replicationUpdateParameters ReplicationUpdateParameters, options *ReplicationsBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, replicationName, replicationUpdateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ReplicationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replicationUpdateParameters ReplicationUpdateParameters, options *ReplicationsBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if replicationName == "" { + return nil, errors.New("parameter replicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{replicationName}", url.PathEscape(replicationName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(replicationUpdateParameters) +} + +// updateHandleError handles the Update error response. +func (client *ReplicationsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_response_types.go b/sdk/containerregistry/armcontainerregistry/zz_generated_response_types.go new file mode 100644 index 000000000000..aa00e8388af9 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_response_types.go @@ -0,0 +1,569 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "net/http" + "time" +) + +// AgentPoolListResultResponse is the response envelope for operations that return a AgentPoolListResult type. +type AgentPoolListResultResponse struct { + // The collection of agent pools. + AgentPoolListResult *AgentPoolListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AgentPoolPollerResponse is the response envelope for operations that asynchronously return a AgentPool type. +type AgentPoolPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (AgentPoolResponse, error) + + // Poller contains an initialized poller. + Poller AgentPoolPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AgentPoolQueueStatusResponse is the response envelope for operations that return a AgentPoolQueueStatus type. +type AgentPoolQueueStatusResponse struct { + // The QueueStatus of Agent Pool + AgentPoolQueueStatus *AgentPoolQueueStatus + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AgentPoolResponse is the response envelope for operations that return a AgentPool type. +type AgentPoolResponse struct { + // The agentpool that has the ARM resource and properties. + // The agentpool will have all information to create an agent pool. + AgentPool *AgentPool + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CallbackConfigResponse is the response envelope for operations that return a CallbackConfig type. +type CallbackConfigResponse struct { + // The configuration of service URI and custom headers for the webhook. + CallbackConfig *CallbackConfig + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConnectedRegistryListResultResponse is the response envelope for operations that return a ConnectedRegistryListResult type. +type ConnectedRegistryListResultResponse struct { + // The result of a request to list connected registries for a container registry. + ConnectedRegistryListResult *ConnectedRegistryListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConnectedRegistryPollerResponse is the response envelope for operations that asynchronously return a ConnectedRegistry type. +type ConnectedRegistryPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ConnectedRegistryResponse, error) + + // Poller contains an initialized poller. + Poller ConnectedRegistryPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ConnectedRegistryResponse is the response envelope for operations that return a ConnectedRegistry type. +type ConnectedRegistryResponse struct { + // An object that represents a connected registry for a container registry. + ConnectedRegistry *ConnectedRegistry + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EventInfoResponse is the response envelope for operations that return a EventInfo type. +type EventInfoResponse struct { + // The basic information of an event. + EventInfo *EventInfo + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EventListResultResponse is the response envelope for operations that return a EventListResult type. +type EventListResultResponse struct { + // The result of a request to list events for a webhook. + EventListResult *EventListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExportPipelineListResultResponse is the response envelope for operations that return a ExportPipelineListResult type. +type ExportPipelineListResultResponse struct { + // The result of a request to list export pipelines for a container registry. + ExportPipelineListResult *ExportPipelineListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExportPipelinePollerResponse is the response envelope for operations that asynchronously return a ExportPipeline type. +type ExportPipelinePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ExportPipelineResponse, error) + + // Poller contains an initialized poller. + Poller ExportPipelinePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExportPipelineResponse is the response envelope for operations that return a ExportPipeline type. +type ExportPipelineResponse struct { + // An object that represents an export pipeline for a container registry. + ExportPipeline *ExportPipeline + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GenerateCredentialsResultPollerResponse is the response envelope for operations that asynchronously return a GenerateCredentialsResult type. +type GenerateCredentialsResultPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (GenerateCredentialsResultResponse, error) + + // Poller contains an initialized poller. + Poller GenerateCredentialsResultPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GenerateCredentialsResultResponse is the response envelope for operations that return a GenerateCredentialsResult type. +type GenerateCredentialsResultResponse struct { + // The response from the GenerateCredentials operation. + GenerateCredentialsResult *GenerateCredentialsResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// HTTPPollerResponse contains the asynchronous HTTP response from the call to the service endpoint. +type HTTPPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (*http.Response, error) + + // Poller contains an initialized poller. + Poller HTTPPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ImportPipelineListResultResponse is the response envelope for operations that return a ImportPipelineListResult type. +type ImportPipelineListResultResponse struct { + // The result of a request to list import pipelines for a container registry. + ImportPipelineListResult *ImportPipelineListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ImportPipelinePollerResponse is the response envelope for operations that asynchronously return a ImportPipeline type. +type ImportPipelinePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ImportPipelineResponse, error) + + // Poller contains an initialized poller. + Poller ImportPipelinePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ImportPipelineResponse is the response envelope for operations that return a ImportPipeline type. +type ImportPipelineResponse struct { + // An object that represents an import pipeline for a container registry. + ImportPipeline *ImportPipeline + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationListResultResponse is the response envelope for operations that return a OperationListResult type. +type OperationListResultResponse struct { + // The result of a request to list container registry operations. + OperationListResult *OperationListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineRunListResultResponse is the response envelope for operations that return a PipelineRunListResult type. +type PipelineRunListResultResponse struct { + // The result of a request to list pipeline runs for a container registry. + PipelineRunListResult *PipelineRunListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineRunPollerResponse is the response envelope for operations that asynchronously return a PipelineRun type. +type PipelineRunPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (PipelineRunResponseType, error) + + // Poller contains an initialized poller. + Poller PipelineRunPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PipelineRunResponseType is the response envelope for operations that return a PipelineRun type. +type PipelineRunResponseType struct { + // An object that represents a pipeline run for a container registry. + PipelineRun *PipelineRun + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionListResultResponse is the response envelope for operations that return a PrivateEndpointConnectionListResult type. +type PrivateEndpointConnectionListResultResponse struct { + // The result of a request to list private endpoint connections for a container registry. + PrivateEndpointConnectionListResult *PrivateEndpointConnectionListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionPollerResponse is the response envelope for operations that asynchronously return a PrivateEndpointConnection type. +type PrivateEndpointConnectionPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (PrivateEndpointConnectionResponse, error) + + // Poller contains an initialized poller. + Poller PrivateEndpointConnectionPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionResponse is the response envelope for operations that return a PrivateEndpointConnection type. +type PrivateEndpointConnectionResponse struct { + // An object that represents a private endpoint connection for a container registry. + PrivateEndpointConnection *PrivateEndpointConnection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateLinkResourceListResultResponse is the response envelope for operations that return a PrivateLinkResourceListResult type. +type PrivateLinkResourceListResultResponse struct { + // The result of a request to list private link resources for a container registry. + PrivateLinkResourceListResult *PrivateLinkResourceListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RegistryListCredentialsResultResponse is the response envelope for operations that return a RegistryListCredentialsResult type. +type RegistryListCredentialsResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The response from the ListCredentials operation. + RegistryListCredentialsResult *RegistryListCredentialsResult +} + +// RegistryListResultResponse is the response envelope for operations that return a RegistryListResult type. +type RegistryListResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The result of a request to list container registries. + RegistryListResult *RegistryListResult +} + +// RegistryNameStatusResponse is the response envelope for operations that return a RegistryNameStatus type. +type RegistryNameStatusResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The result of a request to check the availability of a container registry name. + RegistryNameStatus *RegistryNameStatus +} + +// RegistryPollerResponse is the response envelope for operations that asynchronously return a Registry type. +type RegistryPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (RegistryResponse, error) + + // Poller contains an initialized poller. + Poller RegistryPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RegistryResponse is the response envelope for operations that return a Registry type. +type RegistryResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // An object that represents a container registry. + Registry *Registry +} + +// RegistryUsageListResultResponse is the response envelope for operations that return a RegistryUsageListResult type. +type RegistryUsageListResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The result of a request to get container registry quota usages. + RegistryUsageListResult *RegistryUsageListResult +} + +// ReplicationListResultResponse is the response envelope for operations that return a ReplicationListResult type. +type ReplicationListResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The result of a request to list replications for a container registry. + ReplicationListResult *ReplicationListResult +} + +// ReplicationPollerResponse is the response envelope for operations that asynchronously return a Replication type. +type ReplicationPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ReplicationResponse, error) + + // Poller contains an initialized poller. + Poller ReplicationPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReplicationResponse is the response envelope for operations that return a Replication type. +type ReplicationResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // An object that represents a replication for a container registry. + Replication *Replication +} + +// RunGetLogResultResponse is the response envelope for operations that return a RunGetLogResult type. +type RunGetLogResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The result of get log link operation. + RunGetLogResult *RunGetLogResult +} + +// RunListResultResponse is the response envelope for operations that return a RunListResult type. +type RunListResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // Collection of runs. + RunListResult *RunListResult +} + +// RunPollerResponse is the response envelope for operations that asynchronously return a Run type. +type RunPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (RunResponse, error) + + // Poller contains an initialized poller. + Poller RunPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RunResponse is the response envelope for operations that return a Run type. +type RunResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // Run resource properties + Run *Run +} + +// ScopeMapListResultResponse is the response envelope for operations that return a ScopeMapListResult type. +type ScopeMapListResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The result of a request to list scope maps for a container registry. + ScopeMapListResult *ScopeMapListResult +} + +// ScopeMapPollerResponse is the response envelope for operations that asynchronously return a ScopeMap type. +type ScopeMapPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (ScopeMapResponse, error) + + // Poller contains an initialized poller. + Poller ScopeMapPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ScopeMapResponse is the response envelope for operations that return a ScopeMap type. +type ScopeMapResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // An object that represents a scope map for a container registry. + ScopeMap *ScopeMap +} + +// SourceUploadDefinitionResponse is the response envelope for operations that return a SourceUploadDefinition type. +type SourceUploadDefinitionResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The properties of a response to source upload request. + SourceUploadDefinition *SourceUploadDefinition +} + +// TaskListResultResponse is the response envelope for operations that return a TaskListResult type. +type TaskListResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The collection of tasks. + TaskListResult *TaskListResult +} + +// TaskPollerResponse is the response envelope for operations that asynchronously return a Task type. +type TaskPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (TaskResponse, error) + + // Poller contains an initialized poller. + Poller TaskPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TaskResponse is the response envelope for operations that return a Task type. +type TaskResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The task that has the ARM resource and task properties. + // The task will have all information to schedule a run against it. + Task *Task +} + +// TaskRunListResultResponse is the response envelope for operations that return a TaskRunListResult type. +type TaskRunListResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The collection of task runs. + TaskRunListResult *TaskRunListResult +} + +// TaskRunPollerResponse is the response envelope for operations that asynchronously return a TaskRun type. +type TaskRunPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (TaskRunResponse, error) + + // Poller contains an initialized poller. + Poller TaskRunPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TaskRunResponse is the response envelope for operations that return a TaskRun type. +type TaskRunResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The task run that has the ARM resource and properties. + // The task run will have the information of request and result of a run. + TaskRun *TaskRun +} + +// TokenListResultResponse is the response envelope for operations that return a TokenListResult type. +type TokenListResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The result of a request to list tokens for a container registry. + TokenListResult *TokenListResult +} + +// TokenPollerResponse is the response envelope for operations that asynchronously return a Token type. +type TokenPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (TokenResponse, error) + + // Poller contains an initialized poller. + Poller TokenPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TokenResponse is the response envelope for operations that return a Token type. +type TokenResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // An object that represents a token for a container registry. + Token *Token +} + +// WebhookListResultResponse is the response envelope for operations that return a WebhookListResult type. +type WebhookListResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The result of a request to list webhooks for a container registry. + WebhookListResult *WebhookListResult +} + +// WebhookPollerResponse is the response envelope for operations that asynchronously return a Webhook type. +type WebhookPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (WebhookResponse, error) + + // Poller contains an initialized poller. + Poller WebhookPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// WebhookResponse is the response envelope for operations that return a Webhook type. +type WebhookResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // An object that represents a webhook for a container registry. + Webhook *Webhook +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_runs_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_runs_client.go new file mode 100644 index 000000000000..64cdf1505938 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_runs_client.go @@ -0,0 +1,463 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// RunsClient contains the methods for the Runs group. +// Don't use this type directly, use NewRunsClient() instead. +type RunsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewRunsClient creates a new instance of RunsClient with the specified values. +func NewRunsClient(con *armcore.Connection, subscriptionID string) *RunsClient { + return &RunsClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCancel - Cancel an existing run. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RunsClient) BeginCancel(ctx context.Context, resourceGroupName string, registryName string, runID string, options *RunsBeginCancelOptions) (HTTPPollerResponse, error) { + resp, err := client.cancel(ctx, resourceGroupName, registryName, runID, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("RunsClient.Cancel", "", resp, client.con.Pipeline(), client.cancelHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCancel creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *RunsClient) ResumeCancel(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("RunsClient.Cancel", token, client.con.Pipeline(), client.cancelHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Cancel - Cancel an existing run. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RunsClient) cancel(ctx context.Context, resourceGroupName string, registryName string, runID string, options *RunsBeginCancelOptions) (*azcore.Response, error) { + req, err := client.cancelCreateRequest(ctx, resourceGroupName, registryName, runID, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.cancelHandleError(resp) + } + return resp, nil +} + +// cancelCreateRequest creates the Cancel request. +func (client *RunsClient) cancelCreateRequest(ctx context.Context, resourceGroupName string, registryName string, runID string, options *RunsBeginCancelOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if runID == "" { + return nil, errors.New("parameter runID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{runId}", url.PathEscape(runID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// cancelHandleError handles the Cancel error response. +func (client *RunsClient) cancelHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the detailed information for a given run. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RunsClient) Get(ctx context.Context, resourceGroupName string, registryName string, runID string, options *RunsGetOptions) (RunResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, runID, options) + if err != nil { + return RunResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return RunResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return RunResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *RunsClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, runID string, options *RunsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if runID == "" { + return nil, errors.New("parameter runID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{runId}", url.PathEscape(runID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RunsClient) getHandleResponse(resp *azcore.Response) (RunResponse, error) { + var val *Run + if err := resp.UnmarshalAsJSON(&val); err != nil { + return RunResponse{}, err + } + return RunResponse{RawResponse: resp.Response, Run: val}, nil +} + +// getHandleError handles the Get error response. +func (client *RunsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetLogSasURL - Gets a link to download the run logs. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RunsClient) GetLogSasURL(ctx context.Context, resourceGroupName string, registryName string, runID string, options *RunsGetLogSasURLOptions) (RunGetLogResultResponse, error) { + req, err := client.getLogSasURLCreateRequest(ctx, resourceGroupName, registryName, runID, options) + if err != nil { + return RunGetLogResultResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return RunGetLogResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return RunGetLogResultResponse{}, client.getLogSasURLHandleError(resp) + } + return client.getLogSasURLHandleResponse(resp) +} + +// getLogSasURLCreateRequest creates the GetLogSasURL request. +func (client *RunsClient) getLogSasURLCreateRequest(ctx context.Context, resourceGroupName string, registryName string, runID string, options *RunsGetLogSasURLOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/listLogSasUrl" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if runID == "" { + return nil, errors.New("parameter runID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{runId}", url.PathEscape(runID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getLogSasURLHandleResponse handles the GetLogSasURL response. +func (client *RunsClient) getLogSasURLHandleResponse(resp *azcore.Response) (RunGetLogResultResponse, error) { + var val *RunGetLogResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return RunGetLogResultResponse{}, err + } + return RunGetLogResultResponse{RawResponse: resp.Response, RunGetLogResult: val}, nil +} + +// getLogSasURLHandleError handles the GetLogSasURL error response. +func (client *RunsClient) getLogSasURLHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Gets all the runs for a registry. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RunsClient) List(resourceGroupName string, registryName string, options *RunsListOptions) RunListResultPager { + return &runListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp RunListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.RunListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *RunsClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *RunsListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *RunsClient) listHandleResponse(resp *azcore.Response) (RunListResultResponse, error) { + var val *RunListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return RunListResultResponse{}, err + } + return RunListResultResponse{RawResponse: resp.Response, RunListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *RunsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginUpdate - Patch the run properties. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RunsClient) BeginUpdate(ctx context.Context, resourceGroupName string, registryName string, runID string, runUpdateParameters RunUpdateParameters, options *RunsBeginUpdateOptions) (RunPollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, registryName, runID, runUpdateParameters, options) + if err != nil { + return RunPollerResponse{}, err + } + result := RunPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("RunsClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return RunPollerResponse{}, err + } + poller := &runPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RunResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new RunPoller from the specified resume token. +// token - The value must come from a previous call to RunPoller.ResumeToken(). +func (client *RunsClient) ResumeUpdate(ctx context.Context, token string) (RunPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("RunsClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return RunPollerResponse{}, err + } + poller := &runPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return RunPollerResponse{}, err + } + result := RunPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (RunResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Patch the run properties. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RunsClient) update(ctx context.Context, resourceGroupName string, registryName string, runID string, runUpdateParameters RunUpdateParameters, options *RunsBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, runID, runUpdateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *RunsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, runID string, runUpdateParameters RunUpdateParameters, options *RunsBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if runID == "" { + return nil, errors.New("parameter runID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{runId}", url.PathEscape(runID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(runUpdateParameters) +} + +// updateHandleError handles the Update error response. +func (client *RunsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_scopemaps_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_scopemaps_client.go new file mode 100644 index 000000000000..d25397ad0215 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_scopemaps_client.go @@ -0,0 +1,488 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// ScopeMapsClient contains the methods for the ScopeMaps group. +// Don't use this type directly, use NewScopeMapsClient() instead. +type ScopeMapsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewScopeMapsClient creates a new instance of ScopeMapsClient with the specified values. +func NewScopeMapsClient(con *armcore.Connection, subscriptionID string) *ScopeMapsClient { + return &ScopeMapsClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Creates a scope map for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *ScopeMapsClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, scopeMapCreateParameters ScopeMap, options *ScopeMapsBeginCreateOptions) (ScopeMapPollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, registryName, scopeMapName, scopeMapCreateParameters, options) + if err != nil { + return ScopeMapPollerResponse{}, err + } + result := ScopeMapPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ScopeMapsClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return ScopeMapPollerResponse{}, err + } + poller := &scopeMapPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ScopeMapResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new ScopeMapPoller from the specified resume token. +// token - The value must come from a previous call to ScopeMapPoller.ResumeToken(). +func (client *ScopeMapsClient) ResumeCreate(ctx context.Context, token string) (ScopeMapPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ScopeMapsClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return ScopeMapPollerResponse{}, err + } + poller := &scopeMapPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ScopeMapPollerResponse{}, err + } + result := ScopeMapPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ScopeMapResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates a scope map for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *ScopeMapsClient) create(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, scopeMapCreateParameters ScopeMap, options *ScopeMapsBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, scopeMapName, scopeMapCreateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *ScopeMapsClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, scopeMapCreateParameters ScopeMap, options *ScopeMapsBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if scopeMapName == "" { + return nil, errors.New("parameter scopeMapName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeMapName}", url.PathEscape(scopeMapName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(scopeMapCreateParameters) +} + +// createHandleError handles the Create error response. +func (client *ScopeMapsClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginDelete - Deletes a scope map from a container registry. +// If the operation fails it returns a generic error. +func (client *ScopeMapsClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, options *ScopeMapsBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, scopeMapName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ScopeMapsClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *ScopeMapsClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ScopeMapsClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a scope map from a container registry. +// If the operation fails it returns a generic error. +func (client *ScopeMapsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, options *ScopeMapsBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, scopeMapName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ScopeMapsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, options *ScopeMapsBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if scopeMapName == "" { + return nil, errors.New("parameter scopeMapName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeMapName}", url.PathEscape(scopeMapName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ScopeMapsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets the properties of the specified scope map. +// If the operation fails it returns a generic error. +func (client *ScopeMapsClient) Get(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, options *ScopeMapsGetOptions) (ScopeMapResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, scopeMapName, options) + if err != nil { + return ScopeMapResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ScopeMapResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ScopeMapResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ScopeMapsClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, options *ScopeMapsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if scopeMapName == "" { + return nil, errors.New("parameter scopeMapName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeMapName}", url.PathEscape(scopeMapName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ScopeMapsClient) getHandleResponse(resp *azcore.Response) (ScopeMapResponse, error) { + var val *ScopeMap + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ScopeMapResponse{}, err + } + return ScopeMapResponse{RawResponse: resp.Response, ScopeMap: val}, nil +} + +// getHandleError handles the Get error response. +func (client *ScopeMapsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// List - Lists all the scope maps for the specified container registry. +// If the operation fails it returns a generic error. +func (client *ScopeMapsClient) List(resourceGroupName string, registryName string, options *ScopeMapsListOptions) ScopeMapListResultPager { + return &scopeMapListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp ScopeMapListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ScopeMapListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *ScopeMapsClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *ScopeMapsListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ScopeMapsClient) listHandleResponse(resp *azcore.Response) (ScopeMapListResultResponse, error) { + var val *ScopeMapListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return ScopeMapListResultResponse{}, err + } + return ScopeMapListResultResponse{RawResponse: resp.Response, ScopeMapListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *ScopeMapsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginUpdate - Updates a scope map with the specified parameters. +// If the operation fails it returns a generic error. +func (client *ScopeMapsClient) BeginUpdate(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, scopeMapUpdateParameters ScopeMapUpdateParameters, options *ScopeMapsBeginUpdateOptions) (ScopeMapPollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, registryName, scopeMapName, scopeMapUpdateParameters, options) + if err != nil { + return ScopeMapPollerResponse{}, err + } + result := ScopeMapPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("ScopeMapsClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return ScopeMapPollerResponse{}, err + } + poller := &scopeMapPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ScopeMapResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new ScopeMapPoller from the specified resume token. +// token - The value must come from a previous call to ScopeMapPoller.ResumeToken(). +func (client *ScopeMapsClient) ResumeUpdate(ctx context.Context, token string) (ScopeMapPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("ScopeMapsClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return ScopeMapPollerResponse{}, err + } + poller := &scopeMapPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return ScopeMapPollerResponse{}, err + } + result := ScopeMapPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (ScopeMapResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates a scope map with the specified parameters. +// If the operation fails it returns a generic error. +func (client *ScopeMapsClient) update(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, scopeMapUpdateParameters ScopeMapUpdateParameters, options *ScopeMapsBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, scopeMapName, scopeMapUpdateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ScopeMapsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, scopeMapName string, scopeMapUpdateParameters ScopeMapUpdateParameters, options *ScopeMapsBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scopeMaps/{scopeMapName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if scopeMapName == "" { + return nil, errors.New("parameter scopeMapName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scopeMapName}", url.PathEscape(scopeMapName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(scopeMapUpdateParameters) +} + +// updateHandleError handles the Update error response. +func (client *ScopeMapsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_taskruns_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_taskruns_client.go new file mode 100644 index 000000000000..1e6863f593e5 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_taskruns_client.go @@ -0,0 +1,565 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// TaskRunsClient contains the methods for the TaskRuns group. +// Don't use this type directly, use NewTaskRunsClient() instead. +type TaskRunsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewTaskRunsClient creates a new instance of TaskRunsClient with the specified values. +func NewTaskRunsClient(con *armcore.Connection, subscriptionID string) *TaskRunsClient { + return &TaskRunsClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Creates a task run for a container registry with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TaskRunsClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, taskRun TaskRun, options *TaskRunsBeginCreateOptions) (TaskRunPollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, registryName, taskRunName, taskRun, options) + if err != nil { + return TaskRunPollerResponse{}, err + } + result := TaskRunPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("TaskRunsClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return TaskRunPollerResponse{}, err + } + poller := &taskRunPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TaskRunResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new TaskRunPoller from the specified resume token. +// token - The value must come from a previous call to TaskRunPoller.ResumeToken(). +func (client *TaskRunsClient) ResumeCreate(ctx context.Context, token string) (TaskRunPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("TaskRunsClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return TaskRunPollerResponse{}, err + } + poller := &taskRunPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return TaskRunPollerResponse{}, err + } + result := TaskRunPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TaskRunResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates a task run for a container registry with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TaskRunsClient) create(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, taskRun TaskRun, options *TaskRunsBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, taskRunName, taskRun, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *TaskRunsClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, taskRun TaskRun, options *TaskRunsBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if taskRunName == "" { + return nil, errors.New("parameter taskRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{taskRunName}", url.PathEscape(taskRunName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(taskRun) +} + +// createHandleError handles the Create error response. +func (client *TaskRunsClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginDelete - Deletes a specified task run resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TaskRunsClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, taskRunName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("TaskRunsClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *TaskRunsClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("TaskRunsClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a specified task run resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TaskRunsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, taskRunName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TaskRunsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if taskRunName == "" { + return nil, errors.New("parameter taskRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{taskRunName}", url.PathEscape(taskRunName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *TaskRunsClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the detailed information for a given task run. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TaskRunsClient) Get(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsGetOptions) (TaskRunResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, taskRunName, options) + if err != nil { + return TaskRunResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TaskRunResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TaskRunResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *TaskRunsClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if taskRunName == "" { + return nil, errors.New("parameter taskRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{taskRunName}", url.PathEscape(taskRunName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TaskRunsClient) getHandleResponse(resp *azcore.Response) (TaskRunResponse, error) { + var val *TaskRun + if err := resp.UnmarshalAsJSON(&val); err != nil { + return TaskRunResponse{}, err + } + return TaskRunResponse{RawResponse: resp.Response, TaskRun: val}, nil +} + +// getHandleError handles the Get error response. +func (client *TaskRunsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetDetails - Gets the detailed information for a given task run that includes all secrets. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TaskRunsClient) GetDetails(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsGetDetailsOptions) (TaskRunResponse, error) { + req, err := client.getDetailsCreateRequest(ctx, resourceGroupName, registryName, taskRunName, options) + if err != nil { + return TaskRunResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TaskRunResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TaskRunResponse{}, client.getDetailsHandleError(resp) + } + return client.getDetailsHandleResponse(resp) +} + +// getDetailsCreateRequest creates the GetDetails request. +func (client *TaskRunsClient) getDetailsCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsGetDetailsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}/listDetails" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if taskRunName == "" { + return nil, errors.New("parameter taskRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{taskRunName}", url.PathEscape(taskRunName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getDetailsHandleResponse handles the GetDetails response. +func (client *TaskRunsClient) getDetailsHandleResponse(resp *azcore.Response) (TaskRunResponse, error) { + var val *TaskRun + if err := resp.UnmarshalAsJSON(&val); err != nil { + return TaskRunResponse{}, err + } + return TaskRunResponse{RawResponse: resp.Response, TaskRun: val}, nil +} + +// getDetailsHandleError handles the GetDetails error response. +func (client *TaskRunsClient) getDetailsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Lists all the task runs for a specified container registry. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TaskRunsClient) List(resourceGroupName string, registryName string, options *TaskRunsListOptions) TaskRunListResultPager { + return &taskRunListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp TaskRunListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.TaskRunListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *TaskRunsClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *TaskRunsListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *TaskRunsClient) listHandleResponse(resp *azcore.Response) (TaskRunListResultResponse, error) { + var val *TaskRunListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return TaskRunListResultResponse{}, err + } + return TaskRunListResultResponse{RawResponse: resp.Response, TaskRunListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *TaskRunsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginUpdate - Updates a task run with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TaskRunsClient) BeginUpdate(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, updateParameters TaskRunUpdateParameters, options *TaskRunsBeginUpdateOptions) (TaskRunPollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, registryName, taskRunName, updateParameters, options) + if err != nil { + return TaskRunPollerResponse{}, err + } + result := TaskRunPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("TaskRunsClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return TaskRunPollerResponse{}, err + } + poller := &taskRunPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TaskRunResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new TaskRunPoller from the specified resume token. +// token - The value must come from a previous call to TaskRunPoller.ResumeToken(). +func (client *TaskRunsClient) ResumeUpdate(ctx context.Context, token string) (TaskRunPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("TaskRunsClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return TaskRunPollerResponse{}, err + } + poller := &taskRunPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return TaskRunPollerResponse{}, err + } + result := TaskRunPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TaskRunResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates a task run with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TaskRunsClient) update(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, updateParameters TaskRunUpdateParameters, options *TaskRunsBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, taskRunName, updateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *TaskRunsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, updateParameters TaskRunUpdateParameters, options *TaskRunsBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if taskRunName == "" { + return nil, errors.New("parameter taskRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{taskRunName}", url.PathEscape(taskRunName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(updateParameters) +} + +// updateHandleError handles the Update error response. +func (client *TaskRunsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_tasks_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_tasks_client.go new file mode 100644 index 000000000000..69ad7c542463 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_tasks_client.go @@ -0,0 +1,565 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// TasksClient contains the methods for the Tasks group. +// Don't use this type directly, use NewTasksClient() instead. +type TasksClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewTasksClient creates a new instance of TasksClient with the specified values. +func NewTasksClient(con *armcore.Connection, subscriptionID string) *TasksClient { + return &TasksClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Creates a task for a container registry with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TasksClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskCreateParameters Task, options *TasksBeginCreateOptions) (TaskPollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, registryName, taskName, taskCreateParameters, options) + if err != nil { + return TaskPollerResponse{}, err + } + result := TaskPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("TasksClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return TaskPollerResponse{}, err + } + poller := &taskPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TaskResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new TaskPoller from the specified resume token. +// token - The value must come from a previous call to TaskPoller.ResumeToken(). +func (client *TasksClient) ResumeCreate(ctx context.Context, token string) (TaskPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("TasksClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return TaskPollerResponse{}, err + } + poller := &taskPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return TaskPollerResponse{}, err + } + result := TaskPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TaskResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates a task for a container registry with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TasksClient) create(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskCreateParameters Task, options *TasksBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, taskName, taskCreateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *TasksClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskCreateParameters Task, options *TasksBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if taskName == "" { + return nil, errors.New("parameter taskName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{taskName}", url.PathEscape(taskName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(taskCreateParameters) +} + +// createHandleError handles the Create error response. +func (client *TasksClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginDelete - Deletes a specified task. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TasksClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *TasksBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, taskName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("TasksClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *TasksClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("TasksClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a specified task. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TasksClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *TasksBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, taskName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TasksClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *TasksBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if taskName == "" { + return nil, errors.New("parameter taskName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{taskName}", url.PathEscape(taskName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *TasksClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get the properties of a specified task. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TasksClient) Get(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *TasksGetOptions) (TaskResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, taskName, options) + if err != nil { + return TaskResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TaskResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TaskResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *TasksClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *TasksGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if taskName == "" { + return nil, errors.New("parameter taskName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{taskName}", url.PathEscape(taskName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TasksClient) getHandleResponse(resp *azcore.Response) (TaskResponse, error) { + var val *Task + if err := resp.UnmarshalAsJSON(&val); err != nil { + return TaskResponse{}, err + } + return TaskResponse{RawResponse: resp.Response, Task: val}, nil +} + +// getHandleError handles the Get error response. +func (client *TasksClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetDetails - Returns a task with extended information that includes all secrets. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TasksClient) GetDetails(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *TasksGetDetailsOptions) (TaskResponse, error) { + req, err := client.getDetailsCreateRequest(ctx, resourceGroupName, registryName, taskName, options) + if err != nil { + return TaskResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TaskResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TaskResponse{}, client.getDetailsHandleError(resp) + } + return client.getDetailsHandleResponse(resp) +} + +// getDetailsCreateRequest creates the GetDetails request. +func (client *TasksClient) getDetailsCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *TasksGetDetailsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}/listDetails" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if taskName == "" { + return nil, errors.New("parameter taskName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{taskName}", url.PathEscape(taskName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getDetailsHandleResponse handles the GetDetails response. +func (client *TasksClient) getDetailsHandleResponse(resp *azcore.Response) (TaskResponse, error) { + var val *Task + if err := resp.UnmarshalAsJSON(&val); err != nil { + return TaskResponse{}, err + } + return TaskResponse{RawResponse: resp.Response, Task: val}, nil +} + +// getDetailsHandleError handles the GetDetails error response. +func (client *TasksClient) getDetailsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Lists all the tasks for a specified container registry. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TasksClient) List(resourceGroupName string, registryName string, options *TasksListOptions) TaskListResultPager { + return &taskListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp TaskListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.TaskListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *TasksClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *TasksListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *TasksClient) listHandleResponse(resp *azcore.Response) (TaskListResultResponse, error) { + var val *TaskListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return TaskListResultResponse{}, err + } + return TaskListResultResponse{RawResponse: resp.Response, TaskListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *TasksClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginUpdate - Updates a task with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TasksClient) BeginUpdate(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskUpdateParameters TaskUpdateParameters, options *TasksBeginUpdateOptions) (TaskPollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, registryName, taskName, taskUpdateParameters, options) + if err != nil { + return TaskPollerResponse{}, err + } + result := TaskPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("TasksClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return TaskPollerResponse{}, err + } + poller := &taskPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TaskResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new TaskPoller from the specified resume token. +// token - The value must come from a previous call to TaskPoller.ResumeToken(). +func (client *TasksClient) ResumeUpdate(ctx context.Context, token string) (TaskPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("TasksClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return TaskPollerResponse{}, err + } + poller := &taskPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return TaskPollerResponse{}, err + } + result := TaskPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TaskResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates a task with the specified parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TasksClient) update(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskUpdateParameters TaskUpdateParameters, options *TasksBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, taskName, taskUpdateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *TasksClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskUpdateParameters TaskUpdateParameters, options *TasksBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tasks/{taskName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if taskName == "" { + return nil, errors.New("parameter taskName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{taskName}", url.PathEscape(taskName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2019-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(taskUpdateParameters) +} + +// updateHandleError handles the Update error response. +func (client *TasksClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_time_rfc3339.go b/sdk/containerregistry/armcontainerregistry/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..a492d36be257 --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_time_rfc3339.go @@ -0,0 +1,57 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_tokens_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_tokens_client.go new file mode 100644 index 000000000000..3e33fc0f1aeb --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_tokens_client.go @@ -0,0 +1,488 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// TokensClient contains the methods for the Tokens group. +// Don't use this type directly, use NewTokensClient() instead. +type TokensClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewTokensClient creates a new instance of TokensClient with the specified values. +func NewTokensClient(con *armcore.Connection, subscriptionID string) *TokensClient { + return &TokensClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Creates a token for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *TokensClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, tokenName string, tokenCreateParameters Token, options *TokensBeginCreateOptions) (TokenPollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, registryName, tokenName, tokenCreateParameters, options) + if err != nil { + return TokenPollerResponse{}, err + } + result := TokenPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("TokensClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return TokenPollerResponse{}, err + } + poller := &tokenPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TokenResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new TokenPoller from the specified resume token. +// token - The value must come from a previous call to TokenPoller.ResumeToken(). +func (client *TokensClient) ResumeCreate(ctx context.Context, token string) (TokenPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("TokensClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return TokenPollerResponse{}, err + } + poller := &tokenPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return TokenPollerResponse{}, err + } + result := TokenPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TokenResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates a token for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *TokensClient) create(ctx context.Context, resourceGroupName string, registryName string, tokenName string, tokenCreateParameters Token, options *TokensBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, tokenName, tokenCreateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *TokensClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, tokenName string, tokenCreateParameters Token, options *TokensBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if tokenName == "" { + return nil, errors.New("parameter tokenName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tokenName}", url.PathEscape(tokenName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(tokenCreateParameters) +} + +// createHandleError handles the Create error response. +func (client *TokensClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginDelete - Deletes a token from a container registry. +// If the operation fails it returns a generic error. +func (client *TokensClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, tokenName string, options *TokensBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, tokenName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("TokensClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *TokensClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("TokensClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a token from a container registry. +// If the operation fails it returns a generic error. +func (client *TokensClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, tokenName string, options *TokensBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, tokenName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TokensClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, tokenName string, options *TokensBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if tokenName == "" { + return nil, errors.New("parameter tokenName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tokenName}", url.PathEscape(tokenName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *TokensClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets the properties of the specified token. +// If the operation fails it returns a generic error. +func (client *TokensClient) Get(ctx context.Context, resourceGroupName string, registryName string, tokenName string, options *TokensGetOptions) (TokenResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, tokenName, options) + if err != nil { + return TokenResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TokenResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TokenResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *TokensClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, tokenName string, options *TokensGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if tokenName == "" { + return nil, errors.New("parameter tokenName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tokenName}", url.PathEscape(tokenName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TokensClient) getHandleResponse(resp *azcore.Response) (TokenResponse, error) { + var val *Token + if err := resp.UnmarshalAsJSON(&val); err != nil { + return TokenResponse{}, err + } + return TokenResponse{RawResponse: resp.Response, Token: val}, nil +} + +// getHandleError handles the Get error response. +func (client *TokensClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// List - Lists all the tokens for the specified container registry. +// If the operation fails it returns a generic error. +func (client *TokensClient) List(resourceGroupName string, registryName string, options *TokensListOptions) TokenListResultPager { + return &tokenListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp TokenListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.TokenListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *TokensClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *TokensListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *TokensClient) listHandleResponse(resp *azcore.Response) (TokenListResultResponse, error) { + var val *TokenListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return TokenListResultResponse{}, err + } + return TokenListResultResponse{RawResponse: resp.Response, TokenListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *TokensClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginUpdate - Updates a token with the specified parameters. +// If the operation fails it returns a generic error. +func (client *TokensClient) BeginUpdate(ctx context.Context, resourceGroupName string, registryName string, tokenName string, tokenUpdateParameters TokenUpdateParameters, options *TokensBeginUpdateOptions) (TokenPollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, registryName, tokenName, tokenUpdateParameters, options) + if err != nil { + return TokenPollerResponse{}, err + } + result := TokenPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("TokensClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return TokenPollerResponse{}, err + } + poller := &tokenPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TokenResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new TokenPoller from the specified resume token. +// token - The value must come from a previous call to TokenPoller.ResumeToken(). +func (client *TokensClient) ResumeUpdate(ctx context.Context, token string) (TokenPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("TokensClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return TokenPollerResponse{}, err + } + poller := &tokenPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return TokenPollerResponse{}, err + } + result := TokenPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TokenResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates a token with the specified parameters. +// If the operation fails it returns a generic error. +func (client *TokensClient) update(ctx context.Context, resourceGroupName string, registryName string, tokenName string, tokenUpdateParameters TokenUpdateParameters, options *TokensBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, tokenName, tokenUpdateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *TokensClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, tokenName string, tokenUpdateParameters TokenUpdateParameters, options *TokensBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/tokens/{tokenName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if tokenName == "" { + return nil, errors.New("parameter tokenName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tokenName}", url.PathEscape(tokenName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(tokenUpdateParameters) +} + +// updateHandleError handles the Update error response. +func (client *TokensClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} diff --git a/sdk/containerregistry/armcontainerregistry/zz_generated_webhooks_client.go b/sdk/containerregistry/armcontainerregistry/zz_generated_webhooks_client.go new file mode 100644 index 000000000000..dca702a50a3e --- /dev/null +++ b/sdk/containerregistry/armcontainerregistry/zz_generated_webhooks_client.go @@ -0,0 +1,695 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcontainerregistry + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// WebhooksClient contains the methods for the Webhooks group. +// Don't use this type directly, use NewWebhooksClient() instead. +type WebhooksClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewWebhooksClient creates a new instance of WebhooksClient with the specified values. +func NewWebhooksClient(con *armcore.Connection, subscriptionID string) *WebhooksClient { + return &WebhooksClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreate - Creates a webhook for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *WebhooksClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookCreateParameters WebhookCreateParameters, options *WebhooksBeginCreateOptions) (WebhookPollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, registryName, webhookName, webhookCreateParameters, options) + if err != nil { + return WebhookPollerResponse{}, err + } + result := WebhookPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("WebhooksClient.Create", "", resp, client.con.Pipeline(), client.createHandleError) + if err != nil { + return WebhookPollerResponse{}, err + } + poller := &webhookPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (WebhookResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreate creates a new WebhookPoller from the specified resume token. +// token - The value must come from a previous call to WebhookPoller.ResumeToken(). +func (client *WebhooksClient) ResumeCreate(ctx context.Context, token string) (WebhookPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("WebhooksClient.Create", token, client.con.Pipeline(), client.createHandleError) + if err != nil { + return WebhookPollerResponse{}, err + } + poller := &webhookPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return WebhookPollerResponse{}, err + } + result := WebhookPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (WebhookResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Create - Creates a webhook for a container registry with the specified parameters. +// If the operation fails it returns a generic error. +func (client *WebhooksClient) create(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookCreateParameters WebhookCreateParameters, options *WebhooksBeginCreateOptions) (*azcore.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, webhookName, webhookCreateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *WebhooksClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookCreateParameters WebhookCreateParameters, options *WebhooksBeginCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if webhookName == "" { + return nil, errors.New("parameter webhookName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{webhookName}", url.PathEscape(webhookName)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(webhookCreateParameters) +} + +// createHandleError handles the Create error response. +func (client *WebhooksClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginDelete - Deletes a webhook from a container registry. +// If the operation fails it returns a generic error. +func (client *WebhooksClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksBeginDeleteOptions) (HTTPPollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, webhookName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("WebhooksClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *WebhooksClient) ResumeDelete(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("WebhooksClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes a webhook from a container registry. +// If the operation fails it returns a generic error. +func (client *WebhooksClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, webhookName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WebhooksClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if webhookName == "" { + return nil, errors.New("parameter webhookName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{webhookName}", url.PathEscape(webhookName)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *WebhooksClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Get - Gets the properties of the specified webhook. +// If the operation fails it returns a generic error. +func (client *WebhooksClient) Get(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksGetOptions) (WebhookResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, webhookName, options) + if err != nil { + return WebhookResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return WebhookResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return WebhookResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *WebhooksClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if webhookName == "" { + return nil, errors.New("parameter webhookName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{webhookName}", url.PathEscape(webhookName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WebhooksClient) getHandleResponse(resp *azcore.Response) (WebhookResponse, error) { + var val *Webhook + if err := resp.UnmarshalAsJSON(&val); err != nil { + return WebhookResponse{}, err + } + return WebhookResponse{RawResponse: resp.Response, Webhook: val}, nil +} + +// getHandleError handles the Get error response. +func (client *WebhooksClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// GetCallbackConfig - Gets the configuration of service URI and custom headers for the webhook. +// If the operation fails it returns a generic error. +func (client *WebhooksClient) GetCallbackConfig(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksGetCallbackConfigOptions) (CallbackConfigResponse, error) { + req, err := client.getCallbackConfigCreateRequest(ctx, resourceGroupName, registryName, webhookName, options) + if err != nil { + return CallbackConfigResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return CallbackConfigResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return CallbackConfigResponse{}, client.getCallbackConfigHandleError(resp) + } + return client.getCallbackConfigHandleResponse(resp) +} + +// getCallbackConfigCreateRequest creates the GetCallbackConfig request. +func (client *WebhooksClient) getCallbackConfigCreateRequest(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksGetCallbackConfigOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if webhookName == "" { + return nil, errors.New("parameter webhookName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{webhookName}", url.PathEscape(webhookName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getCallbackConfigHandleResponse handles the GetCallbackConfig response. +func (client *WebhooksClient) getCallbackConfigHandleResponse(resp *azcore.Response) (CallbackConfigResponse, error) { + var val *CallbackConfig + if err := resp.UnmarshalAsJSON(&val); err != nil { + return CallbackConfigResponse{}, err + } + return CallbackConfigResponse{RawResponse: resp.Response, CallbackConfig: val}, nil +} + +// getCallbackConfigHandleError handles the GetCallbackConfig error response. +func (client *WebhooksClient) getCallbackConfigHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// List - Lists all the webhooks for the specified container registry. +// If the operation fails it returns a generic error. +func (client *WebhooksClient) List(resourceGroupName string, registryName string, options *WebhooksListOptions) WebhookListResultPager { + return &webhookListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, + responder: client.listHandleResponse, + errorer: client.listHandleError, + advancer: func(ctx context.Context, resp WebhookListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.WebhookListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listCreateRequest creates the List request. +func (client *WebhooksClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *WebhooksListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *WebhooksClient) listHandleResponse(resp *azcore.Response) (WebhookListResultResponse, error) { + var val *WebhookListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return WebhookListResultResponse{}, err + } + return WebhookListResultResponse{RawResponse: resp.Response, WebhookListResult: val}, nil +} + +// listHandleError handles the List error response. +func (client *WebhooksClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// ListEvents - Lists recent events for the specified webhook. +// If the operation fails it returns a generic error. +func (client *WebhooksClient) ListEvents(resourceGroupName string, registryName string, webhookName string, options *WebhooksListEventsOptions) EventListResultPager { + return &eventListResultPager{ + pipeline: client.con.Pipeline(), + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listEventsCreateRequest(ctx, resourceGroupName, registryName, webhookName, options) + }, + responder: client.listEventsHandleResponse, + errorer: client.listEventsHandleError, + advancer: func(ctx context.Context, resp EventListResultResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.EventListResult.NextLink) + }, + statusCodes: []int{http.StatusOK}, + } +} + +// listEventsCreateRequest creates the ListEvents request. +func (client *WebhooksClient) listEventsCreateRequest(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksListEventsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if webhookName == "" { + return nil, errors.New("parameter webhookName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{webhookName}", url.PathEscape(webhookName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listEventsHandleResponse handles the ListEvents response. +func (client *WebhooksClient) listEventsHandleResponse(resp *azcore.Response) (EventListResultResponse, error) { + var val *EventListResult + if err := resp.UnmarshalAsJSON(&val); err != nil { + return EventListResultResponse{}, err + } + return EventListResultResponse{RawResponse: resp.Response, EventListResult: val}, nil +} + +// listEventsHandleError handles the ListEvents error response. +func (client *WebhooksClient) listEventsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// Ping - Triggers a ping event to be sent to the webhook. +// If the operation fails it returns a generic error. +func (client *WebhooksClient) Ping(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksPingOptions) (EventInfoResponse, error) { + req, err := client.pingCreateRequest(ctx, resourceGroupName, registryName, webhookName, options) + if err != nil { + return EventInfoResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return EventInfoResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return EventInfoResponse{}, client.pingHandleError(resp) + } + return client.pingHandleResponse(resp) +} + +// pingCreateRequest creates the Ping request. +func (client *WebhooksClient) pingCreateRequest(ctx context.Context, resourceGroupName string, registryName string, webhookName string, options *WebhooksPingOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if webhookName == "" { + return nil, errors.New("parameter webhookName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{webhookName}", url.PathEscape(webhookName)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// pingHandleResponse handles the Ping response. +func (client *WebhooksClient) pingHandleResponse(resp *azcore.Response) (EventInfoResponse, error) { + var val *EventInfo + if err := resp.UnmarshalAsJSON(&val); err != nil { + return EventInfoResponse{}, err + } + return EventInfoResponse{RawResponse: resp.Response, EventInfo: val}, nil +} + +// pingHandleError handles the Ping error response. +func (client *WebhooksClient) pingHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +} + +// BeginUpdate - Updates a webhook with the specified parameters. +// If the operation fails it returns a generic error. +func (client *WebhooksClient) BeginUpdate(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookUpdateParameters WebhookUpdateParameters, options *WebhooksBeginUpdateOptions) (WebhookPollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, registryName, webhookName, webhookUpdateParameters, options) + if err != nil { + return WebhookPollerResponse{}, err + } + result := WebhookPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("WebhooksClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return WebhookPollerResponse{}, err + } + poller := &webhookPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (WebhookResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new WebhookPoller from the specified resume token. +// token - The value must come from a previous call to WebhookPoller.ResumeToken(). +func (client *WebhooksClient) ResumeUpdate(ctx context.Context, token string) (WebhookPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("WebhooksClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return WebhookPollerResponse{}, err + } + poller := &webhookPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return WebhookPollerResponse{}, err + } + result := WebhookPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (WebhookResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates a webhook with the specified parameters. +// If the operation fails it returns a generic error. +func (client *WebhooksClient) update(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookUpdateParameters WebhookUpdateParameters, options *WebhooksBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, webhookName, webhookUpdateParameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *WebhooksClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookUpdateParameters WebhookUpdateParameters, options *WebhooksBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if registryName == "" { + return nil, errors.New("parameter registryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registryName}", url.PathEscape(registryName)) + if webhookName == "" { + return nil, errors.New("parameter webhookName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{webhookName}", url.PathEscape(webhookName)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-06-01-preview") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(webhookUpdateParameters) +} + +// updateHandleError handles the Update error response. +func (client *WebhooksClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + if len(body) == 0 { + return azcore.NewResponseError(errors.New(resp.Status), resp.Response) + } + return azcore.NewResponseError(errors.New(string(body)), resp.Response) +}