diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/CHANGELOG.md b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/CHANGELOG.md new file mode 100644 index 000000000000..922700586ded --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2026-01-21) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/LICENSE.txt b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/README.md b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/README.md new file mode 100644 index 000000000000..4d5068320795 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/README.md @@ -0,0 +1,90 @@ +# Azure Containerregistry Module for Go + +The `armcontainerregistrytasks` module provides operations for working with Azure Containerregistry. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/containerregistry/armcontainerregistrytasks) + +# Getting started + +## Prerequisites + +- An [Azure subscription](https://azure.microsoft.com/free/) +- [Supported](https://aka.ms/azsdk/go/supported-versions) version of Go (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Containerregistry module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Containerregistry. 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). + +## Client Factory + +Azure Containerregistry module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armcontainerregistrytasks.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armcontainerregistrytasks.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewAgentPoolsClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## 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. \ No newline at end of file diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/agentpools_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/agentpools_client.go new file mode 100644 index 000000000000..01f01f2dde79 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/agentpools_client.go @@ -0,0 +1,492 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AgentPoolsClient contains the methods for the AgentPools group. +// Don't use this type directly, use NewAgentPoolsClient() instead. +type AgentPoolsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAgentPoolsClient creates a new instance of AgentPoolsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - Contains optional client configuration. Pass nil to accept the default values. +func NewAgentPoolsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AgentPoolsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AgentPoolsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Creates an agent pool for a container registry with the specified parameters. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - agentPoolName - The name of the agent pool. +// - agentPool - The parameters of an agent pool that needs to scheduled. +// - options - AgentPoolsClientBeginCreateOptions contains the optional parameters for the AgentPoolsClient.BeginCreate method. +func (client *AgentPoolsClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, agentPool AgentPool, options *AgentPoolsClientBeginCreateOptions) (*runtime.Poller[AgentPoolsClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, registryName, agentPoolName, agentPool, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AgentPoolsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AgentPoolsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Creates an agent pool for a container registry with the specified parameters. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +func (client *AgentPoolsClient) create(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, agentPool AgentPool, options *AgentPoolsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "AgentPoolsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, agentPoolName, agentPool, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *AgentPoolsClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, agentPool AgentPool, _ *AgentPoolsClientBeginCreateOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, agentPool); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Deletes a specified agent pool resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - agentPoolName - The name of the agent pool. +// - options - AgentPoolsClientBeginDeleteOptions contains the optional parameters for the AgentPoolsClient.BeginDelete method. +func (client *AgentPoolsClient) BeginDelete(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsClientBeginDeleteOptions) (*runtime.Poller[AgentPoolsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, registryName, agentPoolName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AgentPoolsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AgentPoolsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes a specified agent pool resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +func (client *AgentPoolsClient) deleteOperation(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "AgentPoolsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, agentPoolName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AgentPoolsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, _ *AgentPoolsClientBeginDeleteOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Gets the detailed information for a given agent pool. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - agentPoolName - The name of the agent pool. +// - options - AgentPoolsClientGetOptions contains the optional parameters for the AgentPoolsClient.Get method. +func (client *AgentPoolsClient) Get(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsClientGetOptions) (AgentPoolsClientGetResponse, error) { + var err error + const operationName = "AgentPoolsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, agentPoolName, options) + if err != nil { + return AgentPoolsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AgentPoolsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AgentPoolsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *AgentPoolsClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, _ *AgentPoolsClientGetOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AgentPoolsClient) getHandleResponse(resp *http.Response) (AgentPoolsClientGetResponse, error) { + result := AgentPoolsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AgentPool); err != nil { + return AgentPoolsClientGetResponse{}, err + } + return result, nil +} + +// GetQueueStatus - Gets the count of queued runs for a given agent pool. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - agentPoolName - The name of the agent pool. +// - options - AgentPoolsClientGetQueueStatusOptions contains the optional parameters for the AgentPoolsClient.GetQueueStatus +// method. +func (client *AgentPoolsClient) GetQueueStatus(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *AgentPoolsClientGetQueueStatusOptions) (AgentPoolsClientGetQueueStatusResponse, error) { + var err error + const operationName = "AgentPoolsClient.GetQueueStatus" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getQueueStatusCreateRequest(ctx, resourceGroupName, registryName, agentPoolName, options) + if err != nil { + return AgentPoolsClientGetQueueStatusResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AgentPoolsClientGetQueueStatusResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AgentPoolsClientGetQueueStatusResponse{}, err + } + resp, err := client.getQueueStatusHandleResponse(httpResp) + return resp, err +} + +// getQueueStatusCreateRequest creates the GetQueueStatus request. +func (client *AgentPoolsClient) getQueueStatusCreateRequest(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, _ *AgentPoolsClientGetQueueStatusOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getQueueStatusHandleResponse handles the GetQueueStatus response. +func (client *AgentPoolsClient) getQueueStatusHandleResponse(resp *http.Response) (AgentPoolsClientGetQueueStatusResponse, error) { + result := AgentPoolsClientGetQueueStatusResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AgentPoolQueueStatus); err != nil { + return AgentPoolsClientGetQueueStatusResponse{}, err + } + return result, nil +} + +// NewListPager - Lists all the agent pools for a specified container registry. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - options - AgentPoolsClientListOptions contains the optional parameters for the AgentPoolsClient.NewListPager method. +func (client *AgentPoolsClient) NewListPager(resourceGroupName string, registryName string, options *AgentPoolsClientListOptions) *runtime.Pager[AgentPoolsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[AgentPoolsClientListResponse]{ + More: func(page AgentPoolsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AgentPoolsClientListResponse) (AgentPoolsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AgentPoolsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, nil) + if err != nil { + return AgentPoolsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *AgentPoolsClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, _ *AgentPoolsClientListOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *AgentPoolsClient) listHandleResponse(resp *http.Response) (AgentPoolsClientListResponse, error) { + result := AgentPoolsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AgentPoolListResult); err != nil { + return AgentPoolsClientListResponse{}, err + } + return result, nil +} + +// BeginUpdate - Updates an agent pool with the specified parameters. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - agentPoolName - The name of the agent pool. +// - updateParameters - The parameters for updating an agent pool. +// - options - AgentPoolsClientBeginUpdateOptions contains the optional parameters for the AgentPoolsClient.BeginUpdate method. +func (client *AgentPoolsClient) BeginUpdate(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, updateParameters AgentPoolUpdateParameters, options *AgentPoolsClientBeginUpdateOptions) (*runtime.Poller[AgentPoolsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, registryName, agentPoolName, updateParameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AgentPoolsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AgentPoolsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Updates an agent pool with the specified parameters. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +func (client *AgentPoolsClient) update(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, updateParameters AgentPoolUpdateParameters, options *AgentPoolsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "AgentPoolsClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, agentPoolName, updateParameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *AgentPoolsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, updateParameters AgentPoolUpdateParameters, _ *AgentPoolsClientBeginUpdateOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, updateParameters); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/agentpools_client_example_test.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/agentpools_client_example_test.go new file mode 100644 index 000000000000..403d7b4d5183 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/agentpools_client_example_test.go @@ -0,0 +1,226 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks" + "log" +) + +// Generated from example definition: 2025-03-01-preview/AgentPoolsCreate.json +func ExampleAgentPoolsClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAgentPoolsClient().BeginCreate(ctx, "myResourceGroup", "myRegistry", "myAgentPool", armcontainerregistrytasks.AgentPool{ + Location: to.Ptr("WESTUS"), + Properties: &armcontainerregistrytasks.AgentPoolProperties{ + Count: to.Ptr[int32](1), + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + Tier: to.Ptr("S1"), + }, + Tags: map[string]*string{ + "key": to.Ptr("value"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.AgentPoolsClientCreateResponse{ + // AgentPool: &armcontainerregistrytasks.AgentPool{ + // Name: to.Ptr("myAgentPool"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/agentPools"), + // ID: to.Ptr("/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourceGroups/huanwudfwestgroup/providers/Microsoft.ContainerRegistry/registries/huanglidfwest01/agentPools/testagent26"), + // Location: to.Ptr("WESTUS"), + // Properties: &armcontainerregistrytasks.AgentPoolProperties{ + // Count: to.Ptr[int32](1), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Tier: to.Ptr("S1"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/AgentPoolsDelete.json +func ExampleAgentPoolsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAgentPoolsClient().BeginDelete(ctx, "myResourceGroup", "myRegistry", "myAgentPool", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2025-03-01-preview/AgentPoolsGet.json +func ExampleAgentPoolsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAgentPoolsClient().Get(ctx, "myResourceGroup", "myRegistry", "myAgentPool", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.AgentPoolsClientGetResponse{ + // AgentPool: &armcontainerregistrytasks.AgentPool{ + // Name: to.Ptr("myAgentPool"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/agentPools"), + // ID: to.Ptr("/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourceGroups/huanwudfwestgroup/providers/Microsoft.ContainerRegistry/registries/huanglidfwest01/agentPools/testagent26"), + // Location: to.Ptr("WESTUS"), + // Properties: &armcontainerregistrytasks.AgentPoolProperties{ + // Count: to.Ptr[int32](1), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Tier: to.Ptr("S1"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/AgentPoolsGetQueueStatus.json +func ExampleAgentPoolsClient_GetQueueStatus() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAgentPoolsClient().GetQueueStatus(ctx, "myResourceGroup", "myRegistry", "myAgentPool", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.AgentPoolsClientGetQueueStatusResponse{ + // AgentPoolQueueStatus: &armcontainerregistrytasks.AgentPoolQueueStatus{ + // Count: to.Ptr[int32](10), + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/AgentPoolsList.json +func ExampleAgentPoolsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAgentPoolsClient().NewListPager("myResourceGroup", "myRegistry", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcontainerregistrytasks.AgentPoolsClientListResponse{ + // AgentPoolListResult: armcontainerregistrytasks.AgentPoolListResult{ + // Value: []*armcontainerregistrytasks.AgentPool{ + // { + // Name: to.Ptr("myAgentPool"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/agentPools"), + // ID: to.Ptr("/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourceGroups/huanwudfwestgroup/providers/Microsoft.ContainerRegistry/registries/huanglidfwest01/agentPools/testagent26"), + // Location: to.Ptr("WESTUS"), + // Properties: &armcontainerregistrytasks.AgentPoolProperties{ + // Count: to.Ptr[int32](1), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Tier: to.Ptr("S1"), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01-preview/AgentPoolsUpdate.json +func ExampleAgentPoolsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAgentPoolsClient().BeginUpdate(ctx, "myResourceGroup", "myRegistry", "myAgentPool", armcontainerregistrytasks.AgentPoolUpdateParameters{ + Properties: &armcontainerregistrytasks.AgentPoolPropertiesUpdateParameters{ + Count: to.Ptr[int32](1), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.AgentPoolsClientUpdateResponse{ + // AgentPool: &armcontainerregistrytasks.AgentPool{ + // Name: to.Ptr("myAgentPool"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/agentPools"), + // ID: to.Ptr("/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourceGroups/huanwudfwestgroup/providers/Microsoft.ContainerRegistry/registries/huanglidfwest01/agentPools/testagent26"), + // Location: to.Ptr("WESTUS"), + // Properties: &armcontainerregistrytasks.AgentPoolProperties{ + // Count: to.Ptr[int32](1), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Tier: to.Ptr("S1"), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/ci.yml b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/ci.yml new file mode 100644 index 000000000000..fdcc65600ddb --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/containerregistry/armcontainerregistrytasks/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/containerregistry/armcontainerregistrytasks/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/containerregistry/armcontainerregistrytasks' diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/client_factory.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/client_factory.go new file mode 100644 index 000000000000..74fe184528c5 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/client_factory.go @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewAgentPoolsClient creates a new instance of AgentPoolsClient. +func (c *ClientFactory) NewAgentPoolsClient() *AgentPoolsClient { + return &AgentPoolsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewRegistriesClient creates a new instance of RegistriesClient. +func (c *ClientFactory) NewRegistriesClient() *RegistriesClient { + return &RegistriesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewRunsClient creates a new instance of RunsClient. +func (c *ClientFactory) NewRunsClient() *RunsClient { + return &RunsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewTaskRunsClient creates a new instance of TaskRunsClient. +func (c *ClientFactory) NewTaskRunsClient() *TaskRunsClient { + return &TaskRunsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewTasksClient creates a new instance of TasksClient. +func (c *ClientFactory) NewTasksClient() *TasksClient { + return &TasksClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/constants.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/constants.go new file mode 100644 index 000000000000..4a14ff4fcdcd --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/constants.go @@ -0,0 +1,358 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks + +// 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, + } +} + +// 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, + } +} + +// 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, + } +} + +// CreatedByType - The kind of entity that created the resource. +type CreatedByType string + +const ( + // CreatedByTypeApplication - The entity was created by an application. + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey - The entity was created by a key. + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity - The entity was created by a managed identity. + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser - The entity was created by a user. + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// 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, + } +} + +// 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, + } +} + +// ResourceIdentityType - The identity type. +type ResourceIdentityType string + +const ( + ResourceIdentityTypeNone ResourceIdentityType = "None" + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" + ResourceIdentityTypeSystemAssignedUserAssigned ResourceIdentityType = "SystemAssigned, UserAssigned" + ResourceIdentityTypeUserAssigned ResourceIdentityType = "UserAssigned" +) + +// PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ + ResourceIdentityTypeNone, + ResourceIdentityTypeSystemAssigned, + ResourceIdentityTypeSystemAssignedUserAssigned, + ResourceIdentityTypeUserAssigned, + } +} + +// 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, + } +} + +// 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, + } +} + +// 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, + } +} + +// 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, + } +} + +// 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, + } +} + +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, + } +} + +// 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, + } +} + +// 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, + } +} + +// 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, + } +} + +// 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, + } +} + +// 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, + } +} + +// 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, + } +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/agentpools_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/agentpools_server.go new file mode 100644 index 000000000000..5a25a29534c2 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/agentpools_server.go @@ -0,0 +1,396 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks" + "net/http" + "net/url" + "regexp" +) + +// AgentPoolsServer is a fake server for instances of the armcontainerregistrytasks.AgentPoolsClient type. +type AgentPoolsServer struct { + // BeginCreate is the fake for method AgentPoolsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, agentPool armcontainerregistrytasks.AgentPool, options *armcontainerregistrytasks.AgentPoolsClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistrytasks.AgentPoolsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method AgentPoolsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *armcontainerregistrytasks.AgentPoolsClientBeginDeleteOptions) (resp azfake.PollerResponder[armcontainerregistrytasks.AgentPoolsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method AgentPoolsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *armcontainerregistrytasks.AgentPoolsClientGetOptions) (resp azfake.Responder[armcontainerregistrytasks.AgentPoolsClientGetResponse], errResp azfake.ErrorResponder) + + // GetQueueStatus is the fake for method AgentPoolsClient.GetQueueStatus + // HTTP status codes to indicate success: http.StatusOK + GetQueueStatus func(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, options *armcontainerregistrytasks.AgentPoolsClientGetQueueStatusOptions) (resp azfake.Responder[armcontainerregistrytasks.AgentPoolsClientGetQueueStatusResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method AgentPoolsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistrytasks.AgentPoolsClientListOptions) (resp azfake.PagerResponder[armcontainerregistrytasks.AgentPoolsClientListResponse]) + + // BeginUpdate is the fake for method AgentPoolsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, agentPoolName string, updateParameters armcontainerregistrytasks.AgentPoolUpdateParameters, options *armcontainerregistrytasks.AgentPoolsClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistrytasks.AgentPoolsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewAgentPoolsServerTransport creates a new instance of AgentPoolsServerTransport with the provided implementation. +// The returned AgentPoolsServerTransport instance is connected to an instance of armcontainerregistrytasks.AgentPoolsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAgentPoolsServerTransport(srv *AgentPoolsServer) *AgentPoolsServerTransport { + return &AgentPoolsServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armcontainerregistrytasks.AgentPoolsClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armcontainerregistrytasks.AgentPoolsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armcontainerregistrytasks.AgentPoolsClientListResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armcontainerregistrytasks.AgentPoolsClientUpdateResponse]](), + } +} + +// AgentPoolsServerTransport connects instances of armcontainerregistrytasks.AgentPoolsClient to instances of AgentPoolsServer. +// Don't use this type directly, use NewAgentPoolsServerTransport instead. +type AgentPoolsServerTransport struct { + srv *AgentPoolsServer + beginCreate *tracker[azfake.PollerResponder[armcontainerregistrytasks.AgentPoolsClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armcontainerregistrytasks.AgentPoolsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armcontainerregistrytasks.AgentPoolsClientListResponse]] + beginUpdate *tracker[azfake.PollerResponder[armcontainerregistrytasks.AgentPoolsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for AgentPoolsServerTransport. +func (a *AgentPoolsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return a.dispatchToMethodFake(req, method) +} + +func (a *AgentPoolsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if agentPoolsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = agentPoolsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AgentPoolsClient.BeginCreate": + res.resp, res.err = a.dispatchBeginCreate(req) + case "AgentPoolsClient.BeginDelete": + res.resp, res.err = a.dispatchBeginDelete(req) + case "AgentPoolsClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "AgentPoolsClient.GetQueueStatus": + res.resp, res.err = a.dispatchGetQueueStatus(req) + case "AgentPoolsClient.NewListPager": + res.resp, res.err = a.dispatchNewListPager(req) + case "AgentPoolsClient.BeginUpdate": + res.resp, res.err = a.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (a *AgentPoolsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if a.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := a.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agentPools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistrytasks.AgentPool](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + agentPoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("agentPoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginCreate(req.Context(), resourceGroupNameParam, registryNameParam, agentPoolNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + a.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + a.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + a.beginCreate.remove(req) + } + + return resp, nil +} + +func (a *AgentPoolsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if a.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := a.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agentPools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + agentPoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("agentPoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginDelete(req.Context(), resourceGroupNameParam, registryNameParam, agentPoolNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + a.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + a.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + a.beginDelete.remove(req) + } + + return resp, nil +} + +func (a *AgentPoolsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agentPools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + agentPoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("agentPoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, registryNameParam, agentPoolNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AgentPool, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AgentPoolsServerTransport) dispatchGetQueueStatus(req *http.Request) (*http.Response, error) { + if a.srv.GetQueueStatus == nil { + return nil, &nonRetriableError{errors.New("fake for method GetQueueStatus not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agentPools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listQueueStatus` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + agentPoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("agentPoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.GetQueueStatus(req.Context(), resourceGroupNameParam, registryNameParam, agentPoolNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AgentPoolQueueStatus, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AgentPoolsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := a.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agentPools` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListPager(resourceGroupNameParam, registryNameParam, nil) + newListPager = &resp + a.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcontainerregistrytasks.AgentPoolsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + a.newListPager.remove(req) + } + return resp, nil +} + +func (a *AgentPoolsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if a.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := a.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agentPools/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistrytasks.AgentPoolUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + agentPoolNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("agentPoolName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginUpdate(req.Context(), resourceGroupNameParam, registryNameParam, agentPoolNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + a.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + a.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + a.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to AgentPoolsServerTransport +var agentPoolsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/internal.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/internal.go new file mode 100644 index 000000000000..dcd0cea7728b --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/internal.go @@ -0,0 +1,97 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "io" + "net/http" + "reflect" + "sync" +) + +type result struct { + resp *http.Response + err error +} + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { + if v == "" { + return nil, nil + } + t, err := parse(v) + if err != nil { + return nil, err + } + return &t, err +} + +func readRequestBody(req *http.Request) ([]byte, error) { + if req.Body == nil { + return nil, nil + } + body, err := io.ReadAll(req.Body) + if err != nil { + return nil, err + } + req.Body.Close() + return body, nil +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/polymorphic_helpers.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/polymorphic_helpers.go new file mode 100644 index 000000000000..9605fdf09219 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/polymorphic_helpers.go @@ -0,0 +1,37 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks" +) + +func unmarshalRunRequestClassification(rawMsg json.RawMessage) (armcontainerregistrytasks.RunRequestClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b armcontainerregistrytasks.RunRequestClassification + switch m["type"] { + case "DockerBuildRequest": + b = &armcontainerregistrytasks.DockerBuildRequest{} + case "EncodedTaskRunRequest": + b = &armcontainerregistrytasks.EncodedTaskRunRequest{} + case "FileTaskRunRequest": + b = &armcontainerregistrytasks.FileTaskRunRequest{} + case "TaskRunRequest": + b = &armcontainerregistrytasks.TaskRunRequest{} + default: + b = &armcontainerregistrytasks.RunRequest{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/registries_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/registries_server.go new file mode 100644 index 000000000000..0bd92d60ce61 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/registries_server.go @@ -0,0 +1,168 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks" + "net/http" + "net/url" + "regexp" +) + +// RegistriesServer is a fake server for instances of the armcontainerregistrytasks.RegistriesClient type. +type RegistriesServer struct { + // GetBuildSourceUploadURL is the fake for method RegistriesClient.GetBuildSourceUploadURL + // HTTP status codes to indicate success: http.StatusOK + GetBuildSourceUploadURL func(ctx context.Context, resourceGroupName string, registryName string, options *armcontainerregistrytasks.RegistriesClientGetBuildSourceUploadURLOptions) (resp azfake.Responder[armcontainerregistrytasks.RegistriesClientGetBuildSourceUploadURLResponse], errResp azfake.ErrorResponder) + + // ScheduleRun is the fake for method RegistriesClient.ScheduleRun + // HTTP status codes to indicate success: http.StatusOK + ScheduleRun func(ctx context.Context, resourceGroupName string, registryName string, runRequest armcontainerregistrytasks.RunRequestClassification, options *armcontainerregistrytasks.RegistriesClientScheduleRunOptions) (resp azfake.Responder[armcontainerregistrytasks.RegistriesClientScheduleRunResponse], errResp azfake.ErrorResponder) +} + +// NewRegistriesServerTransport creates a new instance of RegistriesServerTransport with the provided implementation. +// The returned RegistriesServerTransport instance is connected to an instance of armcontainerregistrytasks.RegistriesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewRegistriesServerTransport(srv *RegistriesServer) *RegistriesServerTransport { + return &RegistriesServerTransport{srv: srv} +} + +// RegistriesServerTransport connects instances of armcontainerregistrytasks.RegistriesClient to instances of RegistriesServer. +// Don't use this type directly, use NewRegistriesServerTransport instead. +type RegistriesServerTransport struct { + srv *RegistriesServer +} + +// Do implements the policy.Transporter interface for RegistriesServerTransport. +func (r *RegistriesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return r.dispatchToMethodFake(req, method) +} + +func (r *RegistriesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if registriesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = registriesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "RegistriesClient.GetBuildSourceUploadURL": + res.resp, res.err = r.dispatchGetBuildSourceUploadURL(req) + case "RegistriesClient.ScheduleRun": + res.resp, res.err = r.dispatchScheduleRun(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (r *RegistriesServerTransport) dispatchGetBuildSourceUploadURL(req *http.Request) (*http.Response, error) { + if r.srv.GetBuildSourceUploadURL == nil { + return nil, &nonRetriableError{errors.New("fake for method GetBuildSourceUploadURL not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listBuildSourceUploadUrl` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetBuildSourceUploadURL(req.Context(), resourceGroupNameParam, registryNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SourceUploadDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RegistriesServerTransport) dispatchScheduleRun(req *http.Request) (*http.Response, error) { + if r.srv.ScheduleRun == nil { + return nil, &nonRetriableError{errors.New("fake for method ScheduleRun not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scheduleRun` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + raw, err := readRequestBody(req) + if err != nil { + return nil, err + } + body, err := unmarshalRunRequestClassification(raw) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.ScheduleRun(req.Context(), resourceGroupNameParam, registryNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Run, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to RegistriesServerTransport +var registriesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/runs_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/runs_server.go new file mode 100644 index 000000000000..f3ae951d8d83 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/runs_server.go @@ -0,0 +1,338 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// RunsServer is a fake server for instances of the armcontainerregistrytasks.RunsClient type. +type RunsServer struct { + // Cancel is the fake for method RunsClient.Cancel + // HTTP status codes to indicate success: http.StatusOK + Cancel func(ctx context.Context, resourceGroupName string, registryName string, runID string, options *armcontainerregistrytasks.RunsClientCancelOptions) (resp azfake.Responder[armcontainerregistrytasks.RunsClientCancelResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method RunsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, runID string, options *armcontainerregistrytasks.RunsClientGetOptions) (resp azfake.Responder[armcontainerregistrytasks.RunsClientGetResponse], errResp azfake.ErrorResponder) + + // GetLogSasURL is the fake for method RunsClient.GetLogSasURL + // HTTP status codes to indicate success: http.StatusOK + GetLogSasURL func(ctx context.Context, resourceGroupName string, registryName string, runID string, options *armcontainerregistrytasks.RunsClientGetLogSasURLOptions) (resp azfake.Responder[armcontainerregistrytasks.RunsClientGetLogSasURLResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method RunsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistrytasks.RunsClientListOptions) (resp azfake.PagerResponder[armcontainerregistrytasks.RunsClientListResponse]) + + // Update is the fake for method RunsClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, registryName string, runID string, runUpdateParameters armcontainerregistrytasks.RunUpdateParameters, options *armcontainerregistrytasks.RunsClientUpdateOptions) (resp azfake.Responder[armcontainerregistrytasks.RunsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewRunsServerTransport creates a new instance of RunsServerTransport with the provided implementation. +// The returned RunsServerTransport instance is connected to an instance of armcontainerregistrytasks.RunsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewRunsServerTransport(srv *RunsServer) *RunsServerTransport { + return &RunsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcontainerregistrytasks.RunsClientListResponse]](), + } +} + +// RunsServerTransport connects instances of armcontainerregistrytasks.RunsClient to instances of RunsServer. +// Don't use this type directly, use NewRunsServerTransport instead. +type RunsServerTransport struct { + srv *RunsServer + newListPager *tracker[azfake.PagerResponder[armcontainerregistrytasks.RunsClientListResponse]] +} + +// Do implements the policy.Transporter interface for RunsServerTransport. +func (r *RunsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return r.dispatchToMethodFake(req, method) +} + +func (r *RunsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if runsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = runsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "RunsClient.Cancel": + res.resp, res.err = r.dispatchCancel(req) + case "RunsClient.Get": + res.resp, res.err = r.dispatchGet(req) + case "RunsClient.GetLogSasURL": + res.resp, res.err = r.dispatchGetLogSasURL(req) + case "RunsClient.NewListPager": + res.resp, res.err = r.dispatchNewListPager(req) + case "RunsClient.Update": + res.resp, res.err = r.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (r *RunsServerTransport) dispatchCancel(req *http.Request) (*http.Response, error) { + if r.srv.Cancel == nil { + return nil, &nonRetriableError{errors.New("fake for method Cancel not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancel` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + runIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("runId")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Cancel(req.Context(), resourceGroupNameParam, registryNameParam, runIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RunsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + runIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("runId")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), resourceGroupNameParam, registryNameParam, runIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Run, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RunsServerTransport) dispatchGetLogSasURL(req *http.Request) (*http.Response, error) { + if r.srv.GetLogSasURL == nil { + return nil, &nonRetriableError{errors.New("fake for method GetLogSasURL not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listLogSasUrl` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + runIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("runId")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetLogSasURL(req.Context(), resourceGroupNameParam, registryNameParam, runIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RunGetLogResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RunsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := r.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armcontainerregistrytasks.RunsClientListOptions + if filterParam != nil || topParam != nil { + options = &armcontainerregistrytasks.RunsClientListOptions{ + Filter: filterParam, + Top: topParam, + } + } + resp := r.srv.NewListPager(resourceGroupNameParam, registryNameParam, options) + newListPager = &resp + r.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcontainerregistrytasks.RunsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + r.newListPager.remove(req) + } + return resp, nil +} + +func (r *RunsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if r.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistrytasks.RunUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + runIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("runId")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Update(req.Context(), resourceGroupNameParam, registryNameParam, runIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Run, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to RunsServerTransport +var runsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/server_factory.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/server_factory.go new file mode 100644 index 000000000000..439cd63e5df0 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/server_factory.go @@ -0,0 +1,100 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armcontainerregistrytasks.ClientFactory type. +type ServerFactory struct { + // AgentPoolsServer contains the fakes for client AgentPoolsClient + AgentPoolsServer AgentPoolsServer + + // RegistriesServer contains the fakes for client RegistriesClient + RegistriesServer RegistriesServer + + // RunsServer contains the fakes for client RunsClient + RunsServer RunsServer + + // TaskRunsServer contains the fakes for client TaskRunsClient + TaskRunsServer TaskRunsServer + + // TasksServer contains the fakes for client TasksClient + TasksServer TasksServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armcontainerregistrytasks.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armcontainerregistrytasks.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trAgentPoolsServer *AgentPoolsServerTransport + trRegistriesServer *RegistriesServerTransport + trRunsServer *RunsServerTransport + trTaskRunsServer *TaskRunsServerTransport + trTasksServer *TasksServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "AgentPoolsClient": + initServer(s, &s.trAgentPoolsServer, func() *AgentPoolsServerTransport { return NewAgentPoolsServerTransport(&s.srv.AgentPoolsServer) }) + resp, err = s.trAgentPoolsServer.Do(req) + case "RegistriesClient": + initServer(s, &s.trRegistriesServer, func() *RegistriesServerTransport { return NewRegistriesServerTransport(&s.srv.RegistriesServer) }) + resp, err = s.trRegistriesServer.Do(req) + case "RunsClient": + initServer(s, &s.trRunsServer, func() *RunsServerTransport { return NewRunsServerTransport(&s.srv.RunsServer) }) + resp, err = s.trRunsServer.Do(req) + case "TaskRunsClient": + initServer(s, &s.trTaskRunsServer, func() *TaskRunsServerTransport { return NewTaskRunsServerTransport(&s.srv.TaskRunsServer) }) + resp, err = s.trTaskRunsServer.Do(req) + case "TasksClient": + initServer(s, &s.trTasksServer, func() *TasksServerTransport { return NewTasksServerTransport(&s.srv.TasksServer) }) + resp, err = s.trTasksServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/taskruns_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/taskruns_server.go new file mode 100644 index 000000000000..351cff2d3dd8 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/taskruns_server.go @@ -0,0 +1,383 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks" + "net/http" + "net/url" + "regexp" +) + +// TaskRunsServer is a fake server for instances of the armcontainerregistrytasks.TaskRunsClient type. +type TaskRunsServer struct { + // BeginCreate is the fake for method TaskRunsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, taskRun armcontainerregistrytasks.TaskRun, options *armcontainerregistrytasks.TaskRunsClientBeginCreateOptions) (resp azfake.PollerResponder[armcontainerregistrytasks.TaskRunsClientCreateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method TaskRunsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *armcontainerregistrytasks.TaskRunsClientDeleteOptions) (resp azfake.Responder[armcontainerregistrytasks.TaskRunsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TaskRunsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *armcontainerregistrytasks.TaskRunsClientGetOptions) (resp azfake.Responder[armcontainerregistrytasks.TaskRunsClientGetResponse], errResp azfake.ErrorResponder) + + // GetDetails is the fake for method TaskRunsClient.GetDetails + // HTTP status codes to indicate success: http.StatusOK + GetDetails func(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *armcontainerregistrytasks.TaskRunsClientGetDetailsOptions) (resp azfake.Responder[armcontainerregistrytasks.TaskRunsClientGetDetailsResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method TaskRunsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistrytasks.TaskRunsClientListOptions) (resp azfake.PagerResponder[armcontainerregistrytasks.TaskRunsClientListResponse]) + + // BeginUpdate is the fake for method TaskRunsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, updateParameters armcontainerregistrytasks.TaskRunUpdateParameters, options *armcontainerregistrytasks.TaskRunsClientBeginUpdateOptions) (resp azfake.PollerResponder[armcontainerregistrytasks.TaskRunsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewTaskRunsServerTransport creates a new instance of TaskRunsServerTransport with the provided implementation. +// The returned TaskRunsServerTransport instance is connected to an instance of armcontainerregistrytasks.TaskRunsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTaskRunsServerTransport(srv *TaskRunsServer) *TaskRunsServerTransport { + return &TaskRunsServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armcontainerregistrytasks.TaskRunsClientCreateResponse]](), + newListPager: newTracker[azfake.PagerResponder[armcontainerregistrytasks.TaskRunsClientListResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armcontainerregistrytasks.TaskRunsClientUpdateResponse]](), + } +} + +// TaskRunsServerTransport connects instances of armcontainerregistrytasks.TaskRunsClient to instances of TaskRunsServer. +// Don't use this type directly, use NewTaskRunsServerTransport instead. +type TaskRunsServerTransport struct { + srv *TaskRunsServer + beginCreate *tracker[azfake.PollerResponder[armcontainerregistrytasks.TaskRunsClientCreateResponse]] + newListPager *tracker[azfake.PagerResponder[armcontainerregistrytasks.TaskRunsClientListResponse]] + beginUpdate *tracker[azfake.PollerResponder[armcontainerregistrytasks.TaskRunsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for TaskRunsServerTransport. +func (t *TaskRunsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return t.dispatchToMethodFake(req, method) +} + +func (t *TaskRunsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if taskRunsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = taskRunsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TaskRunsClient.BeginCreate": + res.resp, res.err = t.dispatchBeginCreate(req) + case "TaskRunsClient.Delete": + res.resp, res.err = t.dispatchDelete(req) + case "TaskRunsClient.Get": + res.resp, res.err = t.dispatchGet(req) + case "TaskRunsClient.GetDetails": + res.resp, res.err = t.dispatchGetDetails(req) + case "TaskRunsClient.NewListPager": + res.resp, res.err = t.dispatchNewListPager(req) + case "TaskRunsClient.BeginUpdate": + res.resp, res.err = t.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (t *TaskRunsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if t.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := t.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/taskRuns/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistrytasks.TaskRun](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskRunNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("taskRunName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginCreate(req.Context(), resourceGroupNameParam, registryNameParam, taskRunNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + t.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + t.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + t.beginCreate.remove(req) + } + + return resp, nil +} + +func (t *TaskRunsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if t.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/taskRuns/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskRunNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("taskRunName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Delete(req.Context(), resourceGroupNameParam, registryNameParam, taskRunNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TaskRunsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/taskRuns/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskRunNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("taskRunName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameParam, registryNameParam, taskRunNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TaskRun, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TaskRunsServerTransport) dispatchGetDetails(req *http.Request) (*http.Response, error) { + if t.srv.GetDetails == nil { + return nil, &nonRetriableError{errors.New("fake for method GetDetails not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/taskRuns/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listDetails` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskRunNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("taskRunName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.GetDetails(req.Context(), resourceGroupNameParam, registryNameParam, taskRunNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).TaskRun, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TaskRunsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := t.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/taskRuns` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := t.srv.NewListPager(resourceGroupNameParam, registryNameParam, nil) + newListPager = &resp + t.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcontainerregistrytasks.TaskRunsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + t.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + t.newListPager.remove(req) + } + return resp, nil +} + +func (t *TaskRunsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if t.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := t.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/taskRuns/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistrytasks.TaskRunUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskRunNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("taskRunName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginUpdate(req.Context(), resourceGroupNameParam, registryNameParam, taskRunNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + t.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + t.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + t.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to TaskRunsServerTransport +var taskRunsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/tasks_server.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/tasks_server.go new file mode 100644 index 000000000000..7ec2c99ec7a1 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/fake/tasks_server.go @@ -0,0 +1,357 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks" + "net/http" + "net/url" + "regexp" +) + +// TasksServer is a fake server for instances of the armcontainerregistrytasks.TasksClient type. +type TasksServer struct { + // Create is the fake for method TasksClient.Create + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + Create func(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskCreateParameters armcontainerregistrytasks.Task, options *armcontainerregistrytasks.TasksClientCreateOptions) (resp azfake.Responder[armcontainerregistrytasks.TasksClientCreateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method TasksClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *armcontainerregistrytasks.TasksClientDeleteOptions) (resp azfake.Responder[armcontainerregistrytasks.TasksClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TasksClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *armcontainerregistrytasks.TasksClientGetOptions) (resp azfake.Responder[armcontainerregistrytasks.TasksClientGetResponse], errResp azfake.ErrorResponder) + + // GetDetails is the fake for method TasksClient.GetDetails + // HTTP status codes to indicate success: http.StatusOK + GetDetails func(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *armcontainerregistrytasks.TasksClientGetDetailsOptions) (resp azfake.Responder[armcontainerregistrytasks.TasksClientGetDetailsResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method TasksClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, registryName string, options *armcontainerregistrytasks.TasksClientListOptions) (resp azfake.PagerResponder[armcontainerregistrytasks.TasksClientListResponse]) + + // Update is the fake for method TasksClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskUpdateParameters armcontainerregistrytasks.TaskUpdateParameters, options *armcontainerregistrytasks.TasksClientUpdateOptions) (resp azfake.Responder[armcontainerregistrytasks.TasksClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewTasksServerTransport creates a new instance of TasksServerTransport with the provided implementation. +// The returned TasksServerTransport instance is connected to an instance of armcontainerregistrytasks.TasksClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTasksServerTransport(srv *TasksServer) *TasksServerTransport { + return &TasksServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcontainerregistrytasks.TasksClientListResponse]](), + } +} + +// TasksServerTransport connects instances of armcontainerregistrytasks.TasksClient to instances of TasksServer. +// Don't use this type directly, use NewTasksServerTransport instead. +type TasksServerTransport struct { + srv *TasksServer + newListPager *tracker[azfake.PagerResponder[armcontainerregistrytasks.TasksClientListResponse]] +} + +// Do implements the policy.Transporter interface for TasksServerTransport. +func (t *TasksServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return t.dispatchToMethodFake(req, method) +} + +func (t *TasksServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if tasksServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tasksServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TasksClient.Create": + res.resp, res.err = t.dispatchCreate(req) + case "TasksClient.Delete": + res.resp, res.err = t.dispatchDelete(req) + case "TasksClient.Get": + res.resp, res.err = t.dispatchGet(req) + case "TasksClient.GetDetails": + res.resp, res.err = t.dispatchGetDetails(req) + case "TasksClient.NewListPager": + res.resp, res.err = t.dispatchNewListPager(req) + case "TasksClient.Update": + res.resp, res.err = t.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (t *TasksServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { + if t.srv.Create == nil { + return nil, &nonRetriableError{errors.New("fake for method Create not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tasks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistrytasks.Task](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("taskName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Create(req.Context(), resourceGroupNameParam, registryNameParam, taskNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Task, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TasksServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if t.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tasks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("taskName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Delete(req.Context(), resourceGroupNameParam, registryNameParam, taskNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TasksServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tasks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("taskName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameParam, registryNameParam, taskNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Task, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TasksServerTransport) dispatchGetDetails(req *http.Request) (*http.Response, error) { + if t.srv.GetDetails == nil { + return nil, &nonRetriableError{errors.New("fake for method GetDetails not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tasks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listDetails` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("taskName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.GetDetails(req.Context(), resourceGroupNameParam, registryNameParam, taskNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Task, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TasksServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := t.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tasks` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + resp := t.srv.NewListPager(resourceGroupNameParam, registryNameParam, nil) + newListPager = &resp + t.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcontainerregistrytasks.TasksClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + t.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + t.newListPager.remove(req) + } + return resp, nil +} + +func (t *TasksServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if t.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ContainerRegistry/registries/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tasks/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcontainerregistrytasks.TaskUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + registryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("registryName")]) + if err != nil { + return nil, err + } + taskNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("taskName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Update(req.Context(), resourceGroupNameParam, registryNameParam, taskNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Task, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to TasksServerTransport +var tasksServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/go.mod b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/go.mod new file mode 100644 index 000000000000..bd670a031b1d --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks + +go 1.24.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0 // indirect + github.com/golang-jwt/jwt/v5 v5.3.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.47.0 // indirect + golang.org/x/net v0.49.0 // indirect + golang.org/x/sys v0.40.0 // indirect + golang.org/x/text v0.33.0 // indirect +) diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/go.sum b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/go.sum new file mode 100644 index 000000000000..668beb5b462e --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/go.sum @@ -0,0 +1,39 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0 h1:fou+2+WFTib47nS+nz/ozhEBnvU96bKHy6LjRsY4E28= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0/go.mod h1:t76Ruy8AHvUAC8GfMWJMa0ElSbuIcO03NLpynfbgsPA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1 h1:Hk5QBxZQC1jb2Fwj6mpzme37xbCDdNTxU7O9eb5+LB4= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1/go.mod h1:IYus9qsFobWIc2YVwe/WPjcnyCkPKtnHAqUYeebc8z0= +github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= +github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 h1:9iefClla7iYpfYWdzPCRDozdmndjTm8DXdpCzPajMgA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2/go.mod h1:XtLgD3ZD34DAaVIIAyG3objl5DynM3CQ/vMcbBNJZGI= +github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= +github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= +github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0 h1:XRzhVemXdgvJqCH0sFfrBUTnUJSBrBf7++ypk+twtRs= +github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0/go.mod h1:HKpQxkWaGLJ+D/5H8QRpyQXA1eKjxkFlOMwck5+33Jk= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= +github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRtuthU= +github.com/keybase/go-keychain v0.0.1/go.mod h1:PdEILRW3i9D8JcdM+FmY6RwkHGnhHxXwkPPMeUgOK1k= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8= +golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A= +golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= +golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= +golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= +golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/interfaces.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/interfaces.go new file mode 100644 index 000000000000..42f6ec28c0d7 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/interfaces.go @@ -0,0 +1,32 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks + +// 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 +} + +// 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 +} + +// 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 +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/models.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/models.go new file mode 100644 index 000000000000..2f9d1a73c605 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/models.go @@ -0,0 +1,1285 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks + +import "time" + +// AgentPool - The agentpool that has the ARM resource and properties. +// The agentpool will have all information to create an agent pool. +type AgentPool struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The properties associated with the agent pool + Properties *AgentPoolProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// 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 + + // The collection value. + Value []*AgentPool +} + +// AgentPoolProperties - The properties of agent pool. +type AgentPoolProperties struct { + // The count of agent machine + Count *int32 + + // The OS of agent machine + OS *OS + + // The Tier of agent machine + Tier *string + + // The Virtual Network Subnet Resource Id of the agent machine + VirtualNetworkSubnetResourceID *string + + // READ-ONLY; The provisioning state of this agent pool + ProvisioningState *ProvisioningState +} + +type AgentPoolPropertiesUpdateParameters struct { + // The count of agent machine + Count *int32 +} + +// AgentPoolQueueStatus - The QueueStatus of Agent Pool +type AgentPoolQueueStatus struct { + // The number of pending runs in the queue + Count *int32 +} + +// AgentPoolUpdateParameters - The parameters for updating an agent pool. +type AgentPoolUpdateParameters struct { + // The properties associated with the agent pool + Properties *AgentPoolPropertiesUpdateParameters + + // The ARM resource tags. + Tags map[string]*string +} + +// 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 +} + +// Argument - The properties of a run argument. +type Argument struct { + // REQUIRED; The name of the argument. + Name *string + + // REQUIRED; The value of the argument. + Value *string + + // Flag to indicate whether the argument represents a secret and want to be removed from build logs. + IsSecret *bool +} + +// 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 + + // REQUIRED; The type of Auth token. + TokenType *TokenType + + // Time in seconds that the token remains valid + ExpiresIn *int32 + + // The refresh token used to refresh the access token. + RefreshToken *string + + // The scope of the access token. + Scope *string +} + +// AuthInfoUpdateParameters - The authorization properties for accessing the source code repository. +type AuthInfoUpdateParameters struct { + // Time in seconds that the token remains valid + ExpiresIn *int32 + + // The refresh token used to refresh the access token. + RefreshToken *string + + // The scope of the access token. + Scope *string + + // The access token used to access the source control provider. + Token *string + + // The type of Auth token. + TokenType *TokenType +} + +// BaseImageDependency - Properties that describe a base image dependency. +type BaseImageDependency struct { + // The sha256-based digest of the image manifest. + Digest *string + + // The registry login server. + Registry *string + + // The repository name. + Repository *string + + // The tag name. + Tag *string + + // The type of the base image dependency. + Type *BaseImageDependencyType +} + +// 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 + + // REQUIRED; The name of the trigger. + Name *string + + // The current status of trigger. + Status *TriggerStatus + + // The endpoint URL for receiving update triggers. + UpdateTriggerEndpoint *string + + // Type of Payload body for Base image update triggers. + UpdateTriggerPayloadType *UpdateTriggerPayloadType +} + +// BaseImageTriggerUpdateParameters - The properties for updating base image dependency trigger. +type BaseImageTriggerUpdateParameters struct { + // REQUIRED; The name of the trigger. + Name *string + + // The type of the auto trigger for base image dependency updates. + BaseImageTriggerType *BaseImageTriggerType + + // The current status of trigger. + Status *TriggerStatus + + // The endpoint URL for receiving update triggers. + UpdateTriggerEndpoint *string + + // Type of Payload body for Base image update triggers. + UpdateTriggerPayloadType *UpdateTriggerPayloadType +} + +// 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 + + // Describes the credential parameters for accessing the source registry. + SourceRegistry *SourceRegistryCredentials +} + +// 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 + + // 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 + + // The username for logging into the custom registry. + UserName *SecretObject +} + +// DockerBuildRequest - The parameters for a docker quick build. +type DockerBuildRequest struct { + // REQUIRED; The Docker file path relative to the source location. + DockerFilePath *string + + // REQUIRED; The platform properties against which the run has to happen. + Platform *PlatformProperties + + // CONSTANT; The type of the run request. + // Field has constant value "DockerBuildRequest", any specified value is ignored. + Type *string + + // The machine configuration of the run agent. + AgentConfiguration *AgentProperties + + // The dedicated agent pool for the run. + AgentPoolName *string + + // The collection of override arguments to be used when executing the run. + Arguments []*Argument + + // The properties that describes a set of credentials that will be used when this run is invoked. + Credentials *Credentials + + // The fully qualified image names including the repository and tag. + ImageNames []*string + + // The value that indicates whether archiving is enabled for the run or not. + IsArchiveEnabled *bool + + // The value of this property indicates whether the image built should be pushed to the registry or not. + IsPushEnabled *bool + + // The template that describes the repository and tag information for run log artifact. + LogTemplate *string + + // The value of this property indicates whether the image cache is enabled or not. + NoCache *bool + + // 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 + + // The name of the target build stage for the docker build. + Target *string + + // Run timeout in seconds. + Timeout *int32 +} + +// GetRunRequest implements the RunRequestClassification interface for type DockerBuildRequest. +func (d *DockerBuildRequest) GetRunRequest() *RunRequest { + return &RunRequest{ + AgentPoolName: d.AgentPoolName, + IsArchiveEnabled: d.IsArchiveEnabled, + LogTemplate: d.LogTemplate, + Type: d.Type, + } +} + +// DockerBuildStep - The Docker build step. +type DockerBuildStep struct { + // REQUIRED; The Docker file path relative to the source context. + DockerFilePath *string + + // CONSTANT; The type of the step. + // Field has constant value StepTypeDocker, any specified value is ignored. + Type *StepType + + // The collection of override arguments to be used when executing this build step. + Arguments []*Argument + + // The token (git PAT or SAS token of storage account blob) associated with the context for a step. + ContextAccessToken *string + + // The URL(absolute or relative) of the source context for the task step. + ContextPath *string + + // The fully qualified image names including the repository and tag. + ImageNames []*string + + // The value of this property indicates whether the image built should be pushed to the registry or not. + IsPushEnabled *bool + + // The value of this property indicates whether the image cache is enabled or not. + NoCache *bool + + // The name of the target build stage for the docker build. + Target *string + + // READ-ONLY; List of base image dependencies for a step. + BaseImageDependencies []*BaseImageDependency +} + +// GetTaskStepProperties implements the TaskStepPropertiesClassification interface for type DockerBuildStep. +func (d *DockerBuildStep) GetTaskStepProperties() *TaskStepProperties { + return &TaskStepProperties{ + BaseImageDependencies: d.BaseImageDependencies, + ContextAccessToken: d.ContextAccessToken, + ContextPath: d.ContextPath, + Type: d.Type, + } +} + +// DockerBuildStepUpdateParameters - The properties for updating a docker build step. +type DockerBuildStepUpdateParameters struct { + // CONSTANT; The type of the step. + // Field has constant value StepTypeDocker, any specified value is ignored. + Type *StepType + + // The collection of override arguments to be used when executing this build step. + Arguments []*Argument + + // The token (git PAT or SAS token of storage account blob) associated with the context for a step. + ContextAccessToken *string + + // The URL(absolute or relative) of the source context for the task step. + ContextPath *string + + // The Docker file path relative to the source context. + DockerFilePath *string + + // The fully qualified image names including the repository and tag. + ImageNames []*string + + // The value of this property indicates whether the image built should be pushed to the registry or not. + IsPushEnabled *bool + + // The value of this property indicates whether the image cache is enabled or not. + NoCache *bool + + // The name of the target build stage for the docker build. + Target *string +} + +// GetTaskStepUpdateParameters implements the TaskStepUpdateParametersClassification interface for type DockerBuildStepUpdateParameters. +func (d *DockerBuildStepUpdateParameters) GetTaskStepUpdateParameters() *TaskStepUpdateParameters { + return &TaskStepUpdateParameters{ + ContextAccessToken: d.ContextAccessToken, + ContextPath: d.ContextPath, + Type: d.Type, + } +} + +// EncodedTaskRunRequest - The parameters for a quick task run request. +type EncodedTaskRunRequest struct { + // REQUIRED; Base64 encoded value of the template/definition file content. + EncodedTaskContent *string + + // REQUIRED; The platform properties against which the run has to happen. + Platform *PlatformProperties + + // CONSTANT; The type of the run request. + // Field has constant value "EncodedTaskRunRequest", any specified value is ignored. + Type *string + + // The machine configuration of the run agent. + AgentConfiguration *AgentProperties + + // The dedicated agent pool for the run. + AgentPoolName *string + + // The properties that describes a set of credentials that will be used when this run is invoked. + Credentials *Credentials + + // Base64 encoded value of the parameters/values file content. + EncodedValuesContent *string + + // The value that indicates whether archiving is enabled for the run or not. + IsArchiveEnabled *bool + + // The template that describes the repository and tag information for run log artifact. + LogTemplate *string + + // 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 + + // Run timeout in seconds. + Timeout *int32 + + // The collection of overridable values that can be passed when running a task. + Values []*SetValue +} + +// GetRunRequest implements the RunRequestClassification interface for type EncodedTaskRunRequest. +func (e *EncodedTaskRunRequest) GetRunRequest() *RunRequest { + return &RunRequest{ + AgentPoolName: e.AgentPoolName, + IsArchiveEnabled: e.IsArchiveEnabled, + LogTemplate: e.LogTemplate, + Type: e.Type, + } +} + +// EncodedTaskStep - The properties of a encoded task step. +type EncodedTaskStep struct { + // REQUIRED; Base64 encoded value of the template/definition file content. + EncodedTaskContent *string + + // CONSTANT; The type of the step. + // Field has constant value StepTypeEncodedTask, any specified value is ignored. + Type *StepType + + // The token (git PAT or SAS token of storage account blob) associated with the context for a step. + ContextAccessToken *string + + // The URL(absolute or relative) of the source context for the task step. + ContextPath *string + + // Base64 encoded value of the parameters/values file content. + EncodedValuesContent *string + + // The collection of overridable values that can be passed when running a task. + Values []*SetValue + + // READ-ONLY; List of base image dependencies for a step. + BaseImageDependencies []*BaseImageDependency +} + +// GetTaskStepProperties implements the TaskStepPropertiesClassification interface for type EncodedTaskStep. +func (e *EncodedTaskStep) GetTaskStepProperties() *TaskStepProperties { + return &TaskStepProperties{ + BaseImageDependencies: e.BaseImageDependencies, + ContextAccessToken: e.ContextAccessToken, + ContextPath: e.ContextPath, + Type: e.Type, + } +} + +// EncodedTaskStepUpdateParameters - The properties for updating encoded task step. +type EncodedTaskStepUpdateParameters struct { + // CONSTANT; The type of the step. + // Field has constant value StepTypeEncodedTask, any specified value is ignored. + Type *StepType + + // The token (git PAT or SAS token of storage account blob) associated with the context for a step. + ContextAccessToken *string + + // The URL(absolute or relative) of the source context for the task step. + ContextPath *string + + // Base64 encoded value of the template/definition file content. + EncodedTaskContent *string + + // Base64 encoded value of the parameters/values file content. + EncodedValuesContent *string + + // The collection of overridable values that can be passed when running a task. + Values []*SetValue +} + +// GetTaskStepUpdateParameters implements the TaskStepUpdateParametersClassification interface for type EncodedTaskStepUpdateParameters. +func (e *EncodedTaskStepUpdateParameters) GetTaskStepUpdateParameters() *TaskStepUpdateParameters { + return &TaskStepUpdateParameters{ + ContextAccessToken: e.ContextAccessToken, + ContextPath: e.ContextPath, + Type: e.Type, + } +} + +// FileTaskRunRequest - The request parameters for a scheduling run against a task file. +type FileTaskRunRequest struct { + // REQUIRED; The platform properties against which the run has to happen. + Platform *PlatformProperties + + // REQUIRED; The template/definition file path relative to the source. + TaskFilePath *string + + // CONSTANT; The type of the run request. + // Field has constant value "FileTaskRunRequest", any specified value is ignored. + Type *string + + // The machine configuration of the run agent. + AgentConfiguration *AgentProperties + + // The dedicated agent pool for the run. + AgentPoolName *string + + // The properties that describes a set of credentials that will be used when this run is invoked. + Credentials *Credentials + + // The value that indicates whether archiving is enabled for the run or not. + IsArchiveEnabled *bool + + // The template that describes the repository and tag information for run log artifact. + LogTemplate *string + + // 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 + + // Run timeout in seconds. + Timeout *int32 + + // The collection of overridable values that can be passed when running a task. + Values []*SetValue + + // The values/parameters file path relative to the source. + ValuesFilePath *string +} + +// GetRunRequest implements the RunRequestClassification interface for type FileTaskRunRequest. +func (f *FileTaskRunRequest) GetRunRequest() *RunRequest { + return &RunRequest{ + AgentPoolName: f.AgentPoolName, + IsArchiveEnabled: f.IsArchiveEnabled, + LogTemplate: f.LogTemplate, + Type: f.Type, + } +} + +// FileTaskStep - The properties of a task step. +type FileTaskStep struct { + // REQUIRED; The task template/definition file path relative to the source context. + TaskFilePath *string + + // CONSTANT; The type of the step. + // Field has constant value StepTypeFileTask, any specified value is ignored. + Type *StepType + + // The token (git PAT or SAS token of storage account blob) associated with the context for a step. + ContextAccessToken *string + + // The URL(absolute or relative) of the source context for the task step. + ContextPath *string + + // The collection of overridable values that can be passed when running a task. + Values []*SetValue + + // The task values/parameters file path relative to the source context. + ValuesFilePath *string + + // READ-ONLY; List of base image dependencies for a step. + BaseImageDependencies []*BaseImageDependency +} + +// GetTaskStepProperties implements the TaskStepPropertiesClassification interface for type FileTaskStep. +func (f *FileTaskStep) GetTaskStepProperties() *TaskStepProperties { + return &TaskStepProperties{ + BaseImageDependencies: f.BaseImageDependencies, + ContextAccessToken: f.ContextAccessToken, + ContextPath: f.ContextPath, + Type: f.Type, + } +} + +// FileTaskStepUpdateParameters - The properties of updating a task step. +type FileTaskStepUpdateParameters struct { + // CONSTANT; The type of the step. + // Field has constant value StepTypeFileTask, any specified value is ignored. + Type *StepType + + // The token (git PAT or SAS token of storage account blob) associated with the context for a step. + ContextAccessToken *string + + // The URL(absolute or relative) of the source context for the task step. + ContextPath *string + + // The task template/definition file path relative to the source context. + TaskFilePath *string + + // The collection of overridable values that can be passed when running a task. + Values []*SetValue + + // The values/parameters file path relative to the source context. + ValuesFilePath *string +} + +// GetTaskStepUpdateParameters implements the TaskStepUpdateParametersClassification interface for type FileTaskStepUpdateParameters. +func (f *FileTaskStepUpdateParameters) GetTaskStepUpdateParameters() *TaskStepUpdateParameters { + return &TaskStepUpdateParameters{ + ContextAccessToken: f.ContextAccessToken, + ContextPath: f.ContextPath, + Type: f.Type, + } +} + +// IdentityProperties - Managed identity for the resource. +type IdentityProperties struct { + // The identity type. + Type *ResourceIdentityType + + // 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 + + // READ-ONLY; The principal ID of resource identity. + PrincipalID *string + + // READ-ONLY; The tenant ID of resource. + TenantID *string +} + +// ImageDescriptor - Properties for a registry image. +type ImageDescriptor struct { + // The sha256-based digest of the image manifest. + Digest *string + + // The registry login server. + Registry *string + + // The repository name. + Repository *string + + // The tag name. + Tag *string +} + +// ImageUpdateTrigger - The image update trigger that caused a build. +type ImageUpdateTrigger struct { + // The unique ID of the trigger. + ID *string + + // The list of image updates that caused the build. + Images []*ImageDescriptor + + // The timestamp when the image update happened. + Timestamp *time.Time +} + +type OverrideTaskStepProperties struct { + // Gets or sets the collection of override arguments to be used when + // executing a build step. + Arguments []*Argument + + // The source context against which run has to be queued. + ContextPath *string + + // The file against which run has to be queued. + File *string + + // The name of the target build stage for the docker build. + Target *string + + // Base64 encoded update trigger token that will be attached with the base image trigger webhook. + UpdateTriggerToken *string + + // The collection of overridable values that can be passed when running a Task. + Values []*SetValue +} + +// 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 + + // The OS architecture. + Architecture *Architecture + + // Variant of the CPU. + Variant *Variant +} + +// PlatformUpdateParameters - The properties for updating the platform configuration. +type PlatformUpdateParameters struct { + // The OS architecture. + Architecture *Architecture + + // The operating system type required for the run. + OS *OS + + // Variant of the CPU. + Variant *Variant +} + +// Run resource properties +type Run struct { + // The properties of a run. + Properties *RunProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// 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 + + // The link to logs for a run on a azure container registry. + LogLink *string +} + +// RunListResult - The collection of runs. +type RunListResult struct { + // The URI that can be used to request the next set of paged results. + NextLink *string + + // The collection value. + Value []*Run +} + +// RunProperties - The properties for a run. +type RunProperties struct { + // The machine configuration of the run agent. + AgentConfiguration *AgentProperties + + // The dedicated agent pool for the run. + AgentPoolName *string + + // The time the run was scheduled. + CreateTime *time.Time + + // The list of custom registries that were logged in during this run. + CustomRegistries []*string + + // The time the run finished. + FinishTime *time.Time + + // The image update trigger that caused the run. This is applicable if the task has base image trigger configured. + ImageUpdateTrigger *ImageUpdateTrigger + + // The value that indicates whether archiving is enabled or not. + IsArchiveEnabled *bool + + // The last updated time for the run. + LastUpdatedTime *time.Time + + // The list of all images that were generated from the run. This is applicable if the run generates base image dependencies. + OutputImages []*ImageDescriptor + + // The platform properties against which the run will happen. + Platform *PlatformProperties + + // The provisioning state of a run. + ProvisioningState *ProvisioningState + + // The unique identifier for the run. + RunID *string + + // The type of run. + RunType *RunType + + // The scope of the credentials that were used to login to the source registry during this run. + SourceRegistryAuth *string + + // The source trigger that caused the run. + SourceTrigger *SourceTriggerDescriptor + + // The time the run started. + StartTime *time.Time + + // The current status of the run. + Status *RunStatus + + // The task against which run was scheduled. + Task *string + + // The timer trigger that caused the run. + TimerTrigger *TimerTriggerDescriptor + + // The update trigger token passed for the Run. + UpdateTriggerToken *string + + // READ-ONLY; The image description for the log artifact. + LogArtifact *ImageDescriptor + + // READ-ONLY; The error message received from backend systems after the run is scheduled. + RunErrorMessage *string +} + +// RunRequest - The request parameters for scheduling a run. +type RunRequest struct { + // REQUIRED; The type of the run request. + Type *string + + // The dedicated agent pool for the run. + AgentPoolName *string + + // The value that indicates whether archiving is enabled for the run or not. + IsArchiveEnabled *bool + + // The template that describes the repository and tag information for run log artifact. + LogTemplate *string +} + +// GetRunRequest implements the RunRequestClassification interface for type RunRequest. +func (r *RunRequest) GetRunRequest() *RunRequest { return r } + +// 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 +} + +// 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 + + // 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 +} + +// 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 + + // REQUIRED; The overridable value. + Value *string + + // Flag to indicate whether the value represents a secret or not. + IsSecret *bool +} + +// SourceProperties - The properties of the source code repository. +type SourceProperties struct { + // REQUIRED; The full URL to the source code repository + RepositoryURL *string + + // REQUIRED; The type of source control service. + SourceControlType *SourceControlType + + // The branch name of the source code. + Branch *string + + // The authorization properties for accessing the source code repository and to set up + // webhooks for notifications. + SourceControlAuthProperties *AuthInfo +} + +// SourceRegistryCredentials - Describes the credential parameters for accessing the source registry. +type SourceRegistryCredentials struct { + // The Entra identity used for source registry login. + // The value is `[system]` for system-assigned managed identity, `[caller]` for caller identity, + // and client ID for user-assigned managed identity. + Identity *string + + // 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 +} + +// SourceTrigger - The properties of a source based trigger. +type SourceTrigger struct { + // REQUIRED; The name of the trigger. + Name *string + + // REQUIRED; The properties that describes the source(code) for the task. + SourceRepository *SourceProperties + + // REQUIRED; The source event corresponding to the trigger. + SourceTriggerEvents []*SourceTriggerEvent + + // The current status of trigger. + Status *TriggerStatus +} + +// SourceTriggerDescriptor - The source trigger that caused a run. +type SourceTriggerDescriptor struct { + // The branch name in the repository. + BranchName *string + + // The unique ID that identifies a commit. + CommitID *string + + // The event type of the trigger. + EventType *string + + // The unique ID of the trigger. + ID *string + + // The source control provider type. + ProviderType *string + + // The unique ID that identifies pull request. + PullRequestID *string + + // The repository URL. + RepositoryURL *string +} + +// SourceTriggerUpdateParameters - The properties for updating a source based trigger. +type SourceTriggerUpdateParameters struct { + // REQUIRED; The name of the trigger. + Name *string + + // The properties that describes the source(code) for the task. + SourceRepository *SourceUpdateParameters + + // The source event corresponding to the trigger. + SourceTriggerEvents []*SourceTriggerEvent + + // The current status of trigger. + Status *TriggerStatus +} + +// SourceUpdateParameters - The properties for updating the source code repository. +type SourceUpdateParameters struct { + // The branch name of the source code. + Branch *string + + // The full URL to the source code repository + RepositoryURL *string + + // The authorization properties for accessing the source code repository and to set up + // webhooks for notifications. + SourceControlAuthProperties *AuthInfoUpdateParameters + + // The type of source control service. + SourceControlType *SourceControlType +} + +// 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 + + // The URL where the client can upload the source. + UploadURL *string +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + +// 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 { + // REQUIRED; The geo-location where the resource lives + Location *string + + // Identity for the resource. + Identity *IdentityProperties + + // The properties of a task. + Properties *TaskProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// TaskListResult - The collection of tasks. +type TaskListResult struct { + // The URI that can be used to request the next set of paged results. + NextLink *string + + // The collection value. + Value []*Task +} + +// TaskProperties - The properties of a task. +type TaskProperties struct { + // The machine configuration of the run agent. + AgentConfiguration *AgentProperties + + // The dedicated agent pool for the task. + AgentPoolName *string + + // The properties that describes a set of credentials that will be used when this run is invoked. + Credentials *Credentials + + // The value of this property indicates whether the task resource is system task or not. + IsSystemTask *bool + + // The template that describes the repository and tag information for run log artifact. + LogTemplate *string + + // The platform properties against which the run has to happen. + Platform *PlatformProperties + + // The current status of task. + Status *TaskStatus + + // The properties of a task step. + Step TaskStepPropertiesClassification + + // Run timeout in seconds. + Timeout *int32 + + // The properties that describe all triggers for the task. + Trigger *TriggerProperties + + // READ-ONLY; The creation date of task. + CreationDate *time.Time + + // READ-ONLY; The provisioning state of the task. + ProvisioningState *ProvisioningState +} + +// TaskPropertiesUpdateParameters - The properties for updating a task. +type TaskPropertiesUpdateParameters struct { + // The machine configuration of the run agent. + AgentConfiguration *AgentProperties + + // The dedicated agent pool for the task. + AgentPoolName *string + + // The parameters that describes a set of credentials that will be used when this run is invoked. + Credentials *Credentials + + // The template that describes the repository and tag information for run log artifact. + LogTemplate *string + + // The platform properties against which the run has to happen. + Platform *PlatformUpdateParameters + + // The current status of task. + Status *TaskStatus + + // The properties for updating a task step. + Step TaskStepUpdateParametersClassification + + // Run timeout in seconds. + Timeout *int32 + + // The properties for updating trigger properties. + Trigger *TriggerUpdateParameters +} + +// 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 { + // Identity for the resource. + Identity *IdentityProperties + + // The location of the resource + Location *string + + // The properties associated with the task run, i.e., request and result of the run + Properties *TaskRunProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// 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 + + // The collection value. + Value []*TaskRun +} + +// 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 + + // The request (parameters) for the run + RunRequest RunRequestClassification + + // READ-ONLY; The provisioning state of this task run + ProvisioningState *ProvisioningState + + // READ-ONLY; The result of this task run + RunResult *Run +} + +// 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 + + // The request (parameters) for the new run + RunRequest RunRequestClassification +} + +// TaskRunRequest - The parameters for a task run request. +type TaskRunRequest struct { + // REQUIRED; The resource ID of task against which run has to be queued. + TaskID *string + + // CONSTANT; The type of the run request. + // Field has constant value "TaskRunRequest", any specified value is ignored. + Type *string + + // The dedicated agent pool for the run. + AgentPoolName *string + + // The value that indicates whether archiving is enabled for the run or not. + IsArchiveEnabled *bool + + // The template that describes the repository and tag information for run log artifact. + LogTemplate *string + + // Set of overridable parameters that can be passed when running a Task. + OverrideTaskStepProperties *OverrideTaskStepProperties +} + +// GetRunRequest implements the RunRequestClassification interface for type TaskRunRequest. +func (t *TaskRunRequest) GetRunRequest() *RunRequest { + return &RunRequest{ + AgentPoolName: t.AgentPoolName, + IsArchiveEnabled: t.IsArchiveEnabled, + LogTemplate: t.LogTemplate, + Type: t.Type, + } +} + +// TaskRunUpdateParameters - The parameters for updating a task run. +type TaskRunUpdateParameters struct { + // Identity for the resource. + Identity *IdentityProperties + + // The location of the resource + Location *string + + // The properties for updating a task run. + Properties *TaskRunPropertiesUpdateParameters + + // The ARM resource tags. + Tags map[string]*string +} + +// TaskStepProperties - Base properties for any task step. +type TaskStepProperties struct { + // REQUIRED; The type of the step. + Type *StepType + + // The token (git PAT or SAS token of storage account blob) associated with the context for a step. + ContextAccessToken *string + + // The URL(absolute or relative) of the source context for the task step. + ContextPath *string + + // READ-ONLY; List of base image dependencies for a step. + BaseImageDependencies []*BaseImageDependency +} + +// GetTaskStepProperties implements the TaskStepPropertiesClassification interface for type TaskStepProperties. +func (t *TaskStepProperties) GetTaskStepProperties() *TaskStepProperties { return t } + +// TaskStepUpdateParameters - Base properties for updating any task step. +type TaskStepUpdateParameters struct { + // REQUIRED; The type of the step. + Type *StepType + + // The token (git PAT or SAS token of storage account blob) associated with the context for a step. + ContextAccessToken *string + + // The URL(absolute or relative) of the source context for the task step. + ContextPath *string +} + +// GetTaskStepUpdateParameters implements the TaskStepUpdateParametersClassification interface for type TaskStepUpdateParameters. +func (t *TaskStepUpdateParameters) GetTaskStepUpdateParameters() *TaskStepUpdateParameters { return t } + +// TaskUpdateParameters - The parameters for updating a task. +type TaskUpdateParameters struct { + // Identity for the resource. + Identity *IdentityProperties + + // The properties for updating a task. + Properties *TaskPropertiesUpdateParameters + + // The ARM resource tags. + Tags map[string]*string +} + +// TimerTrigger - The properties of a timer trigger. +type TimerTrigger struct { + // REQUIRED; The name of the trigger. + Name *string + + // REQUIRED; The CRON expression for the task schedule + Schedule *string + + // The current status of trigger. + Status *TriggerStatus +} + +type TimerTriggerDescriptor struct { + // The occurrence that triggered the run. + ScheduleOccurrence *string + + // The timer trigger name that caused the run. + TimerTriggerName *string +} + +// TimerTriggerUpdateParameters - The properties for updating a timer trigger. +type TimerTriggerUpdateParameters struct { + // REQUIRED; The name of the trigger. + Name *string + + // The CRON expression for the task schedule + Schedule *string + + // The current status of trigger. + Status *TriggerStatus +} + +// TriggerProperties - The properties of a trigger. +type TriggerProperties struct { + // The trigger based on base image dependencies. + BaseImageTrigger *BaseImageTrigger + + // The collection of triggers based on source code repository. + SourceTriggers []*SourceTrigger + + // The collection of timer triggers. + TimerTriggers []*TimerTrigger +} + +// TriggerUpdateParameters - The properties for updating triggers. +type TriggerUpdateParameters struct { + // The trigger based on base image dependencies. + BaseImageTrigger *BaseImageTriggerUpdateParameters + + // The collection of triggers based on source code repository. + SourceTriggers []*SourceTriggerUpdateParameters + + // The collection of timer triggers. + TimerTriggers []*TimerTriggerUpdateParameters +} + +type UserIdentityProperties struct { + // READ-ONLY; The client id of user assigned identity. + ClientID *string + + // READ-ONLY; The principal id of user assigned identity. + PrincipalID *string +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/models_serde.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/models_serde.go new file mode 100644 index 000000000000..ff87fde65783 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/models_serde.go @@ -0,0 +1,2817 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime" + "reflect" + "time" +) + +// MarshalJSON implements the json.Marshaller interface for type AgentPool. +func (a AgentPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPool. +func (a *AgentPool) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPoolListResult. +func (a AgentPoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPoolListResult. +func (a *AgentPoolListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPoolProperties. +func (a AgentPoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", a.Count) + populate(objectMap, "os", a.OS) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "tier", a.Tier) + populate(objectMap, "virtualNetworkSubnetResourceId", a.VirtualNetworkSubnetResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPoolProperties. +func (a *AgentPoolProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "count": + err = unpopulate(val, "Count", &a.Count) + delete(rawMsg, key) + case "os": + err = unpopulate(val, "OS", &a.OS) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &a.Tier) + delete(rawMsg, key) + case "virtualNetworkSubnetResourceId": + err = unpopulate(val, "VirtualNetworkSubnetResourceID", &a.VirtualNetworkSubnetResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPoolPropertiesUpdateParameters. +func (a AgentPoolPropertiesUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", a.Count) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPoolPropertiesUpdateParameters. +func (a *AgentPoolPropertiesUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "count": + err = unpopulate(val, "Count", &a.Count) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPoolQueueStatus. +func (a AgentPoolQueueStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", a.Count) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPoolQueueStatus. +func (a *AgentPoolQueueStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "count": + err = unpopulate(val, "Count", &a.Count) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPoolUpdateParameters. +func (a AgentPoolUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPoolUpdateParameters. +func (a *AgentPoolUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentProperties. +func (a AgentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cpu", a.CPU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentProperties. +func (a *AgentProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cpu": + err = unpopulate(val, "CPU", &a.CPU) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Argument. +func (a Argument) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "isSecret", a.IsSecret) + populate(objectMap, "name", a.Name) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Argument. +func (a *Argument) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "isSecret": + err = unpopulate(val, "IsSecret", &a.IsSecret) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AuthInfo. +func (a AuthInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "expiresIn", a.ExpiresIn) + populate(objectMap, "refreshToken", a.RefreshToken) + populate(objectMap, "scope", a.Scope) + populate(objectMap, "token", a.Token) + populate(objectMap, "tokenType", a.TokenType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AuthInfo. +func (a *AuthInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "expiresIn": + err = unpopulate(val, "ExpiresIn", &a.ExpiresIn) + delete(rawMsg, key) + case "refreshToken": + err = unpopulate(val, "RefreshToken", &a.RefreshToken) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &a.Scope) + delete(rawMsg, key) + case "token": + err = unpopulate(val, "Token", &a.Token) + delete(rawMsg, key) + case "tokenType": + err = unpopulate(val, "TokenType", &a.TokenType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AuthInfoUpdateParameters. +func (a AuthInfoUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "expiresIn", a.ExpiresIn) + populate(objectMap, "refreshToken", a.RefreshToken) + populate(objectMap, "scope", a.Scope) + populate(objectMap, "token", a.Token) + populate(objectMap, "tokenType", a.TokenType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AuthInfoUpdateParameters. +func (a *AuthInfoUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "expiresIn": + err = unpopulate(val, "ExpiresIn", &a.ExpiresIn) + delete(rawMsg, key) + case "refreshToken": + err = unpopulate(val, "RefreshToken", &a.RefreshToken) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &a.Scope) + delete(rawMsg, key) + case "token": + err = unpopulate(val, "Token", &a.Token) + delete(rawMsg, key) + case "tokenType": + err = unpopulate(val, "TokenType", &a.TokenType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BaseImageDependency. +func (b BaseImageDependency) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "digest", b.Digest) + populate(objectMap, "registry", b.Registry) + populate(objectMap, "repository", b.Repository) + populate(objectMap, "tag", b.Tag) + populate(objectMap, "type", b.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BaseImageDependency. +func (b *BaseImageDependency) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "digest": + err = unpopulate(val, "Digest", &b.Digest) + delete(rawMsg, key) + case "registry": + err = unpopulate(val, "Registry", &b.Registry) + delete(rawMsg, key) + case "repository": + err = unpopulate(val, "Repository", &b.Repository) + delete(rawMsg, key) + case "tag": + err = unpopulate(val, "Tag", &b.Tag) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &b.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BaseImageTrigger. +func (b BaseImageTrigger) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "baseImageTriggerType", b.BaseImageTriggerType) + populate(objectMap, "name", b.Name) + populate(objectMap, "status", b.Status) + populate(objectMap, "updateTriggerEndpoint", b.UpdateTriggerEndpoint) + populate(objectMap, "updateTriggerPayloadType", b.UpdateTriggerPayloadType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BaseImageTrigger. +func (b *BaseImageTrigger) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "baseImageTriggerType": + err = unpopulate(val, "BaseImageTriggerType", &b.BaseImageTriggerType) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &b.Status) + delete(rawMsg, key) + case "updateTriggerEndpoint": + err = unpopulate(val, "UpdateTriggerEndpoint", &b.UpdateTriggerEndpoint) + delete(rawMsg, key) + case "updateTriggerPayloadType": + err = unpopulate(val, "UpdateTriggerPayloadType", &b.UpdateTriggerPayloadType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BaseImageTriggerUpdateParameters. +func (b BaseImageTriggerUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "baseImageTriggerType", b.BaseImageTriggerType) + populate(objectMap, "name", b.Name) + populate(objectMap, "status", b.Status) + populate(objectMap, "updateTriggerEndpoint", b.UpdateTriggerEndpoint) + populate(objectMap, "updateTriggerPayloadType", b.UpdateTriggerPayloadType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BaseImageTriggerUpdateParameters. +func (b *BaseImageTriggerUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "baseImageTriggerType": + err = unpopulate(val, "BaseImageTriggerType", &b.BaseImageTriggerType) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &b.Status) + delete(rawMsg, key) + case "updateTriggerEndpoint": + err = unpopulate(val, "UpdateTriggerEndpoint", &b.UpdateTriggerEndpoint) + delete(rawMsg, key) + case "updateTriggerPayloadType": + err = unpopulate(val, "UpdateTriggerPayloadType", &b.UpdateTriggerPayloadType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Credentials. +func (c Credentials) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customRegistries", c.CustomRegistries) + populate(objectMap, "sourceRegistry", c.SourceRegistry) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Credentials. +func (c *Credentials) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "customRegistries": + err = unpopulate(val, "CustomRegistries", &c.CustomRegistries) + delete(rawMsg, key) + case "sourceRegistry": + err = unpopulate(val, "SourceRegistry", &c.SourceRegistry) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CustomRegistryCredentials. +func (c CustomRegistryCredentials) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", c.Identity) + populate(objectMap, "password", c.Password) + populate(objectMap, "userName", c.UserName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomRegistryCredentials. +func (c *CustomRegistryCredentials) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &c.Identity) + delete(rawMsg, key) + case "password": + err = unpopulate(val, "Password", &c.Password) + delete(rawMsg, key) + case "userName": + err = unpopulate(val, "UserName", &c.UserName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DockerBuildRequest. +func (d DockerBuildRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "agentConfiguration", d.AgentConfiguration) + populate(objectMap, "agentPoolName", d.AgentPoolName) + populate(objectMap, "arguments", d.Arguments) + populate(objectMap, "credentials", d.Credentials) + populate(objectMap, "dockerFilePath", d.DockerFilePath) + populate(objectMap, "imageNames", d.ImageNames) + populate(objectMap, "isArchiveEnabled", d.IsArchiveEnabled) + populate(objectMap, "isPushEnabled", d.IsPushEnabled) + populate(objectMap, "logTemplate", d.LogTemplate) + 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) + objectMap["type"] = "DockerBuildRequest" + 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 fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentConfiguration": + err = unpopulate(val, "AgentConfiguration", &d.AgentConfiguration) + delete(rawMsg, key) + case "agentPoolName": + err = unpopulate(val, "AgentPoolName", &d.AgentPoolName) + delete(rawMsg, key) + case "arguments": + err = unpopulate(val, "Arguments", &d.Arguments) + delete(rawMsg, key) + case "credentials": + err = unpopulate(val, "Credentials", &d.Credentials) + delete(rawMsg, key) + case "dockerFilePath": + err = unpopulate(val, "DockerFilePath", &d.DockerFilePath) + delete(rawMsg, key) + case "imageNames": + err = unpopulate(val, "ImageNames", &d.ImageNames) + delete(rawMsg, key) + case "isArchiveEnabled": + err = unpopulate(val, "IsArchiveEnabled", &d.IsArchiveEnabled) + delete(rawMsg, key) + case "isPushEnabled": + err = unpopulate(val, "IsPushEnabled", &d.IsPushEnabled) + delete(rawMsg, key) + case "logTemplate": + err = unpopulate(val, "LogTemplate", &d.LogTemplate) + delete(rawMsg, key) + case "noCache": + err = unpopulate(val, "NoCache", &d.NoCache) + delete(rawMsg, key) + case "platform": + err = unpopulate(val, "Platform", &d.Platform) + delete(rawMsg, key) + case "sourceLocation": + err = unpopulate(val, "SourceLocation", &d.SourceLocation) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &d.Target) + delete(rawMsg, key) + case "timeout": + err = unpopulate(val, "Timeout", &d.Timeout) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DockerBuildStep. +func (d DockerBuildStep) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "arguments", d.Arguments) + populate(objectMap, "baseImageDependencies", d.BaseImageDependencies) + populate(objectMap, "contextAccessToken", d.ContextAccessToken) + populate(objectMap, "contextPath", d.ContextPath) + 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) + objectMap["type"] = StepTypeDocker + 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 fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "arguments": + err = unpopulate(val, "Arguments", &d.Arguments) + delete(rawMsg, key) + case "baseImageDependencies": + err = unpopulate(val, "BaseImageDependencies", &d.BaseImageDependencies) + delete(rawMsg, key) + case "contextAccessToken": + err = unpopulate(val, "ContextAccessToken", &d.ContextAccessToken) + delete(rawMsg, key) + case "contextPath": + err = unpopulate(val, "ContextPath", &d.ContextPath) + delete(rawMsg, key) + case "dockerFilePath": + err = unpopulate(val, "DockerFilePath", &d.DockerFilePath) + delete(rawMsg, key) + case "imageNames": + err = unpopulate(val, "ImageNames", &d.ImageNames) + delete(rawMsg, key) + case "isPushEnabled": + err = unpopulate(val, "IsPushEnabled", &d.IsPushEnabled) + delete(rawMsg, key) + case "noCache": + err = unpopulate(val, "NoCache", &d.NoCache) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &d.Target) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DockerBuildStepUpdateParameters. +func (d DockerBuildStepUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "arguments", d.Arguments) + populate(objectMap, "contextAccessToken", d.ContextAccessToken) + populate(objectMap, "contextPath", d.ContextPath) + 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) + objectMap["type"] = StepTypeDocker + 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 fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "arguments": + err = unpopulate(val, "Arguments", &d.Arguments) + delete(rawMsg, key) + case "contextAccessToken": + err = unpopulate(val, "ContextAccessToken", &d.ContextAccessToken) + delete(rawMsg, key) + case "contextPath": + err = unpopulate(val, "ContextPath", &d.ContextPath) + delete(rawMsg, key) + case "dockerFilePath": + err = unpopulate(val, "DockerFilePath", &d.DockerFilePath) + delete(rawMsg, key) + case "imageNames": + err = unpopulate(val, "ImageNames", &d.ImageNames) + delete(rawMsg, key) + case "isPushEnabled": + err = unpopulate(val, "IsPushEnabled", &d.IsPushEnabled) + delete(rawMsg, key) + case "noCache": + err = unpopulate(val, "NoCache", &d.NoCache) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &d.Target) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EncodedTaskRunRequest. +func (e EncodedTaskRunRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "agentConfiguration", e.AgentConfiguration) + populate(objectMap, "agentPoolName", e.AgentPoolName) + populate(objectMap, "credentials", e.Credentials) + populate(objectMap, "encodedTaskContent", e.EncodedTaskContent) + populate(objectMap, "encodedValuesContent", e.EncodedValuesContent) + populate(objectMap, "isArchiveEnabled", e.IsArchiveEnabled) + populate(objectMap, "logTemplate", e.LogTemplate) + populate(objectMap, "platform", e.Platform) + populate(objectMap, "sourceLocation", e.SourceLocation) + populate(objectMap, "timeout", e.Timeout) + objectMap["type"] = "EncodedTaskRunRequest" + 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 fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentConfiguration": + err = unpopulate(val, "AgentConfiguration", &e.AgentConfiguration) + delete(rawMsg, key) + case "agentPoolName": + err = unpopulate(val, "AgentPoolName", &e.AgentPoolName) + delete(rawMsg, key) + case "credentials": + err = unpopulate(val, "Credentials", &e.Credentials) + delete(rawMsg, key) + case "encodedTaskContent": + err = unpopulate(val, "EncodedTaskContent", &e.EncodedTaskContent) + delete(rawMsg, key) + case "encodedValuesContent": + err = unpopulate(val, "EncodedValuesContent", &e.EncodedValuesContent) + delete(rawMsg, key) + case "isArchiveEnabled": + err = unpopulate(val, "IsArchiveEnabled", &e.IsArchiveEnabled) + delete(rawMsg, key) + case "logTemplate": + err = unpopulate(val, "LogTemplate", &e.LogTemplate) + delete(rawMsg, key) + case "platform": + err = unpopulate(val, "Platform", &e.Platform) + delete(rawMsg, key) + case "sourceLocation": + err = unpopulate(val, "SourceLocation", &e.SourceLocation) + delete(rawMsg, key) + case "timeout": + err = unpopulate(val, "Timeout", &e.Timeout) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &e.Values) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EncodedTaskStep. +func (e EncodedTaskStep) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "baseImageDependencies", e.BaseImageDependencies) + populate(objectMap, "contextAccessToken", e.ContextAccessToken) + populate(objectMap, "contextPath", e.ContextPath) + populate(objectMap, "encodedTaskContent", e.EncodedTaskContent) + populate(objectMap, "encodedValuesContent", e.EncodedValuesContent) + objectMap["type"] = StepTypeEncodedTask + 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 fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "baseImageDependencies": + err = unpopulate(val, "BaseImageDependencies", &e.BaseImageDependencies) + delete(rawMsg, key) + case "contextAccessToken": + err = unpopulate(val, "ContextAccessToken", &e.ContextAccessToken) + delete(rawMsg, key) + case "contextPath": + err = unpopulate(val, "ContextPath", &e.ContextPath) + delete(rawMsg, key) + case "encodedTaskContent": + err = unpopulate(val, "EncodedTaskContent", &e.EncodedTaskContent) + delete(rawMsg, key) + case "encodedValuesContent": + err = unpopulate(val, "EncodedValuesContent", &e.EncodedValuesContent) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &e.Values) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EncodedTaskStepUpdateParameters. +func (e EncodedTaskStepUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contextAccessToken", e.ContextAccessToken) + populate(objectMap, "contextPath", e.ContextPath) + populate(objectMap, "encodedTaskContent", e.EncodedTaskContent) + populate(objectMap, "encodedValuesContent", e.EncodedValuesContent) + objectMap["type"] = StepTypeEncodedTask + 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 fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "contextAccessToken": + err = unpopulate(val, "ContextAccessToken", &e.ContextAccessToken) + delete(rawMsg, key) + case "contextPath": + err = unpopulate(val, "ContextPath", &e.ContextPath) + delete(rawMsg, key) + case "encodedTaskContent": + err = unpopulate(val, "EncodedTaskContent", &e.EncodedTaskContent) + delete(rawMsg, key) + case "encodedValuesContent": + err = unpopulate(val, "EncodedValuesContent", &e.EncodedValuesContent) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &e.Values) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileTaskRunRequest. +func (f FileTaskRunRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "agentConfiguration", f.AgentConfiguration) + populate(objectMap, "agentPoolName", f.AgentPoolName) + populate(objectMap, "credentials", f.Credentials) + populate(objectMap, "isArchiveEnabled", f.IsArchiveEnabled) + populate(objectMap, "logTemplate", f.LogTemplate) + populate(objectMap, "platform", f.Platform) + populate(objectMap, "sourceLocation", f.SourceLocation) + populate(objectMap, "taskFilePath", f.TaskFilePath) + populate(objectMap, "timeout", f.Timeout) + objectMap["type"] = "FileTaskRunRequest" + 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 fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentConfiguration": + err = unpopulate(val, "AgentConfiguration", &f.AgentConfiguration) + delete(rawMsg, key) + case "agentPoolName": + err = unpopulate(val, "AgentPoolName", &f.AgentPoolName) + delete(rawMsg, key) + case "credentials": + err = unpopulate(val, "Credentials", &f.Credentials) + delete(rawMsg, key) + case "isArchiveEnabled": + err = unpopulate(val, "IsArchiveEnabled", &f.IsArchiveEnabled) + delete(rawMsg, key) + case "logTemplate": + err = unpopulate(val, "LogTemplate", &f.LogTemplate) + delete(rawMsg, key) + case "platform": + err = unpopulate(val, "Platform", &f.Platform) + delete(rawMsg, key) + case "sourceLocation": + err = unpopulate(val, "SourceLocation", &f.SourceLocation) + delete(rawMsg, key) + case "taskFilePath": + err = unpopulate(val, "TaskFilePath", &f.TaskFilePath) + delete(rawMsg, key) + case "timeout": + err = unpopulate(val, "Timeout", &f.Timeout) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &f.Values) + delete(rawMsg, key) + case "valuesFilePath": + err = unpopulate(val, "ValuesFilePath", &f.ValuesFilePath) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileTaskStep. +func (f FileTaskStep) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "baseImageDependencies", f.BaseImageDependencies) + populate(objectMap, "contextAccessToken", f.ContextAccessToken) + populate(objectMap, "contextPath", f.ContextPath) + populate(objectMap, "taskFilePath", f.TaskFilePath) + objectMap["type"] = StepTypeFileTask + 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 fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "baseImageDependencies": + err = unpopulate(val, "BaseImageDependencies", &f.BaseImageDependencies) + delete(rawMsg, key) + case "contextAccessToken": + err = unpopulate(val, "ContextAccessToken", &f.ContextAccessToken) + delete(rawMsg, key) + case "contextPath": + err = unpopulate(val, "ContextPath", &f.ContextPath) + delete(rawMsg, key) + case "taskFilePath": + err = unpopulate(val, "TaskFilePath", &f.TaskFilePath) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &f.Values) + delete(rawMsg, key) + case "valuesFilePath": + err = unpopulate(val, "ValuesFilePath", &f.ValuesFilePath) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileTaskStepUpdateParameters. +func (f FileTaskStepUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contextAccessToken", f.ContextAccessToken) + populate(objectMap, "contextPath", f.ContextPath) + populate(objectMap, "taskFilePath", f.TaskFilePath) + objectMap["type"] = StepTypeFileTask + 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 fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "contextAccessToken": + err = unpopulate(val, "ContextAccessToken", &f.ContextAccessToken) + delete(rawMsg, key) + case "contextPath": + err = unpopulate(val, "ContextPath", &f.ContextPath) + delete(rawMsg, key) + case "taskFilePath": + err = unpopulate(val, "TaskFilePath", &f.TaskFilePath) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &f.Values) + delete(rawMsg, key) + case "valuesFilePath": + err = unpopulate(val, "ValuesFilePath", &f.ValuesFilePath) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IdentityProperties. +func (i IdentityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + populate(objectMap, "type", i.Type) + populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IdentityProperties. +func (i *IdentityProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &i.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &i.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &i.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImageDescriptor. +func (i ImageDescriptor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "digest", i.Digest) + populate(objectMap, "registry", i.Registry) + populate(objectMap, "repository", i.Repository) + populate(objectMap, "tag", i.Tag) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageDescriptor. +func (i *ImageDescriptor) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "digest": + err = unpopulate(val, "Digest", &i.Digest) + delete(rawMsg, key) + case "registry": + err = unpopulate(val, "Registry", &i.Registry) + delete(rawMsg, key) + case "repository": + err = unpopulate(val, "Repository", &i.Repository) + delete(rawMsg, key) + case "tag": + err = unpopulate(val, "Tag", &i.Tag) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImageUpdateTrigger. +func (i ImageUpdateTrigger) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", i.ID) + populate(objectMap, "images", i.Images) + populateTime[datetime.RFC3339](objectMap, "timestamp", 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 fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "images": + err = unpopulate(val, "Images", &i.Images) + delete(rawMsg, key) + case "timestamp": + err = unpopulateTime[datetime.RFC3339](val, "Timestamp", &i.Timestamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OverrideTaskStepProperties. +func (o OverrideTaskStepProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OverrideTaskStepProperties. +func (o *OverrideTaskStepProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "arguments": + err = unpopulate(val, "Arguments", &o.Arguments) + delete(rawMsg, key) + case "contextPath": + err = unpopulate(val, "ContextPath", &o.ContextPath) + delete(rawMsg, key) + case "file": + err = unpopulate(val, "File", &o.File) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &o.Target) + delete(rawMsg, key) + case "updateTriggerToken": + err = unpopulate(val, "UpdateTriggerToken", &o.UpdateTriggerToken) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &o.Values) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PlatformProperties. +func (p PlatformProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "architecture", p.Architecture) + populate(objectMap, "os", p.OS) + populate(objectMap, "variant", p.Variant) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlatformProperties. +func (p *PlatformProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "architecture": + err = unpopulate(val, "Architecture", &p.Architecture) + delete(rawMsg, key) + case "os": + err = unpopulate(val, "OS", &p.OS) + delete(rawMsg, key) + case "variant": + err = unpopulate(val, "Variant", &p.Variant) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PlatformUpdateParameters. +func (p PlatformUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "architecture", p.Architecture) + populate(objectMap, "os", p.OS) + populate(objectMap, "variant", p.Variant) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlatformUpdateParameters. +func (p *PlatformUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "architecture": + err = unpopulate(val, "Architecture", &p.Architecture) + delete(rawMsg, key) + case "os": + err = unpopulate(val, "OS", &p.OS) + delete(rawMsg, key) + case "variant": + err = unpopulate(val, "Variant", &p.Variant) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Run. +func (r Run) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Run. +func (r *Run) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RunGetLogResult. +func (r RunGetLogResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "logArtifactLink", r.LogArtifactLink) + populate(objectMap, "logLink", r.LogLink) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RunGetLogResult. +func (r *RunGetLogResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "logArtifactLink": + err = unpopulate(val, "LogArtifactLink", &r.LogArtifactLink) + delete(rawMsg, key) + case "logLink": + err = unpopulate(val, "LogLink", &r.LogLink) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RunListResult. +func (r RunListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RunListResult. +func (r *RunListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RunProperties. +func (r RunProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "agentConfiguration", r.AgentConfiguration) + populate(objectMap, "agentPoolName", r.AgentPoolName) + populateTime[datetime.RFC3339](objectMap, "createTime", r.CreateTime) + populate(objectMap, "customRegistries", r.CustomRegistries) + populateTime[datetime.RFC3339](objectMap, "finishTime", r.FinishTime) + populate(objectMap, "imageUpdateTrigger", r.ImageUpdateTrigger) + populate(objectMap, "isArchiveEnabled", r.IsArchiveEnabled) + populateTime[datetime.RFC3339](objectMap, "lastUpdatedTime", 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) + populateTime[datetime.RFC3339](objectMap, "startTime", 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 fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentConfiguration": + err = unpopulate(val, "AgentConfiguration", &r.AgentConfiguration) + delete(rawMsg, key) + case "agentPoolName": + err = unpopulate(val, "AgentPoolName", &r.AgentPoolName) + delete(rawMsg, key) + case "createTime": + err = unpopulateTime[datetime.RFC3339](val, "CreateTime", &r.CreateTime) + delete(rawMsg, key) + case "customRegistries": + err = unpopulate(val, "CustomRegistries", &r.CustomRegistries) + delete(rawMsg, key) + case "finishTime": + err = unpopulateTime[datetime.RFC3339](val, "FinishTime", &r.FinishTime) + delete(rawMsg, key) + case "imageUpdateTrigger": + err = unpopulate(val, "ImageUpdateTrigger", &r.ImageUpdateTrigger) + delete(rawMsg, key) + case "isArchiveEnabled": + err = unpopulate(val, "IsArchiveEnabled", &r.IsArchiveEnabled) + delete(rawMsg, key) + case "lastUpdatedTime": + err = unpopulateTime[datetime.RFC3339](val, "LastUpdatedTime", &r.LastUpdatedTime) + delete(rawMsg, key) + case "logArtifact": + err = unpopulate(val, "LogArtifact", &r.LogArtifact) + delete(rawMsg, key) + case "outputImages": + err = unpopulate(val, "OutputImages", &r.OutputImages) + delete(rawMsg, key) + case "platform": + err = unpopulate(val, "Platform", &r.Platform) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + delete(rawMsg, key) + case "runErrorMessage": + err = unpopulate(val, "RunErrorMessage", &r.RunErrorMessage) + delete(rawMsg, key) + case "runId": + err = unpopulate(val, "RunID", &r.RunID) + delete(rawMsg, key) + case "runType": + err = unpopulate(val, "RunType", &r.RunType) + delete(rawMsg, key) + case "sourceRegistryAuth": + err = unpopulate(val, "SourceRegistryAuth", &r.SourceRegistryAuth) + delete(rawMsg, key) + case "sourceTrigger": + err = unpopulate(val, "SourceTrigger", &r.SourceTrigger) + delete(rawMsg, key) + case "startTime": + err = unpopulateTime[datetime.RFC3339](val, "StartTime", &r.StartTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &r.Status) + delete(rawMsg, key) + case "task": + err = unpopulate(val, "Task", &r.Task) + delete(rawMsg, key) + case "timerTrigger": + err = unpopulate(val, "TimerTrigger", &r.TimerTrigger) + delete(rawMsg, key) + case "updateTriggerToken": + err = unpopulate(val, "UpdateTriggerToken", &r.UpdateTriggerToken) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RunRequest. +func (r RunRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "agentPoolName", r.AgentPoolName) + populate(objectMap, "isArchiveEnabled", r.IsArchiveEnabled) + populate(objectMap, "logTemplate", r.LogTemplate) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// 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 fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentPoolName": + err = unpopulate(val, "AgentPoolName", &r.AgentPoolName) + delete(rawMsg, key) + case "isArchiveEnabled": + err = unpopulate(val, "IsArchiveEnabled", &r.IsArchiveEnabled) + delete(rawMsg, key) + case "logTemplate": + err = unpopulate(val, "LogTemplate", &r.LogTemplate) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RunUpdateParameters. +func (r RunUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "isArchiveEnabled", r.IsArchiveEnabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RunUpdateParameters. +func (r *RunUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "isArchiveEnabled": + err = unpopulate(val, "IsArchiveEnabled", &r.IsArchiveEnabled) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SecretObject. +func (s SecretObject) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "type", s.Type) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecretObject. +func (s *SecretObject) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SetValue. +func (s SetValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "isSecret", s.IsSecret) + populate(objectMap, "name", s.Name) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SetValue. +func (s *SetValue) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "isSecret": + err = unpopulate(val, "IsSecret", &s.IsSecret) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SourceProperties. +func (s SourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "branch", s.Branch) + populate(objectMap, "repositoryUrl", s.RepositoryURL) + populate(objectMap, "sourceControlAuthProperties", s.SourceControlAuthProperties) + populate(objectMap, "sourceControlType", s.SourceControlType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SourceProperties. +func (s *SourceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "branch": + err = unpopulate(val, "Branch", &s.Branch) + delete(rawMsg, key) + case "repositoryUrl": + err = unpopulate(val, "RepositoryURL", &s.RepositoryURL) + delete(rawMsg, key) + case "sourceControlAuthProperties": + err = unpopulate(val, "SourceControlAuthProperties", &s.SourceControlAuthProperties) + delete(rawMsg, key) + case "sourceControlType": + err = unpopulate(val, "SourceControlType", &s.SourceControlType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SourceRegistryCredentials. +func (s SourceRegistryCredentials) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "loginMode", s.LoginMode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SourceRegistryCredentials. +func (s *SourceRegistryCredentials) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &s.Identity) + delete(rawMsg, key) + case "loginMode": + err = unpopulate(val, "LoginMode", &s.LoginMode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SourceTrigger. +func (s SourceTrigger) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "sourceRepository", s.SourceRepository) + populate(objectMap, "sourceTriggerEvents", s.SourceTriggerEvents) + populate(objectMap, "status", s.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SourceTrigger. +func (s *SourceTrigger) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "sourceRepository": + err = unpopulate(val, "SourceRepository", &s.SourceRepository) + delete(rawMsg, key) + case "sourceTriggerEvents": + err = unpopulate(val, "SourceTriggerEvents", &s.SourceTriggerEvents) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SourceTriggerDescriptor. +func (s SourceTriggerDescriptor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "branchName", s.BranchName) + populate(objectMap, "commitId", s.CommitID) + populate(objectMap, "eventType", s.EventType) + populate(objectMap, "id", s.ID) + populate(objectMap, "providerType", s.ProviderType) + populate(objectMap, "pullRequestId", s.PullRequestID) + populate(objectMap, "repositoryUrl", s.RepositoryURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SourceTriggerDescriptor. +func (s *SourceTriggerDescriptor) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "branchName": + err = unpopulate(val, "BranchName", &s.BranchName) + delete(rawMsg, key) + case "commitId": + err = unpopulate(val, "CommitID", &s.CommitID) + delete(rawMsg, key) + case "eventType": + err = unpopulate(val, "EventType", &s.EventType) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "providerType": + err = unpopulate(val, "ProviderType", &s.ProviderType) + delete(rawMsg, key) + case "pullRequestId": + err = unpopulate(val, "PullRequestID", &s.PullRequestID) + delete(rawMsg, key) + case "repositoryUrl": + err = unpopulate(val, "RepositoryURL", &s.RepositoryURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SourceTriggerUpdateParameters. +func (s SourceTriggerUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "sourceRepository", s.SourceRepository) + populate(objectMap, "sourceTriggerEvents", s.SourceTriggerEvents) + populate(objectMap, "status", s.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SourceTriggerUpdateParameters. +func (s *SourceTriggerUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "sourceRepository": + err = unpopulate(val, "SourceRepository", &s.SourceRepository) + delete(rawMsg, key) + case "sourceTriggerEvents": + err = unpopulate(val, "SourceTriggerEvents", &s.SourceTriggerEvents) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SourceUpdateParameters. +func (s SourceUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "branch", s.Branch) + populate(objectMap, "repositoryUrl", s.RepositoryURL) + populate(objectMap, "sourceControlAuthProperties", s.SourceControlAuthProperties) + populate(objectMap, "sourceControlType", s.SourceControlType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SourceUpdateParameters. +func (s *SourceUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "branch": + err = unpopulate(val, "Branch", &s.Branch) + delete(rawMsg, key) + case "repositoryUrl": + err = unpopulate(val, "RepositoryURL", &s.RepositoryURL) + delete(rawMsg, key) + case "sourceControlAuthProperties": + err = unpopulate(val, "SourceControlAuthProperties", &s.SourceControlAuthProperties) + delete(rawMsg, key) + case "sourceControlType": + err = unpopulate(val, "SourceControlType", &s.SourceControlType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SourceUploadDefinition. +func (s SourceUploadDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "relativePath", s.RelativePath) + populate(objectMap, "uploadUrl", s.UploadURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SourceUploadDefinition. +func (s *SourceUploadDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "relativePath": + err = unpopulate(val, "RelativePath", &s.RelativePath) + delete(rawMsg, key) + case "uploadUrl": + err = unpopulate(val, "UploadURL", &s.UploadURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTime[datetime.RFC3339](objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTime[datetime.RFC3339](objectMap, "lastModifiedAt", 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 fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTime[datetime.RFC3339](val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTime[datetime.RFC3339](val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Task. +func (t Task) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "identity", t.Identity) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Task. +func (t *Task) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &t.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TaskListResult. +func (t TaskListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskListResult. +func (t *TaskListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TaskProperties. +func (t TaskProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "agentConfiguration", t.AgentConfiguration) + populate(objectMap, "agentPoolName", t.AgentPoolName) + populateTime[datetime.RFC3339](objectMap, "creationDate", 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 fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentConfiguration": + err = unpopulate(val, "AgentConfiguration", &t.AgentConfiguration) + delete(rawMsg, key) + case "agentPoolName": + err = unpopulate(val, "AgentPoolName", &t.AgentPoolName) + delete(rawMsg, key) + case "creationDate": + err = unpopulateTime[datetime.RFC3339](val, "CreationDate", &t.CreationDate) + delete(rawMsg, key) + case "credentials": + err = unpopulate(val, "Credentials", &t.Credentials) + delete(rawMsg, key) + case "isSystemTask": + err = unpopulate(val, "IsSystemTask", &t.IsSystemTask) + delete(rawMsg, key) + case "logTemplate": + err = unpopulate(val, "LogTemplate", &t.LogTemplate) + delete(rawMsg, key) + case "platform": + err = unpopulate(val, "Platform", &t.Platform) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &t.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &t.Status) + delete(rawMsg, key) + case "step": + t.Step, err = unmarshalTaskStepPropertiesClassification(val) + delete(rawMsg, key) + case "timeout": + err = unpopulate(val, "Timeout", &t.Timeout) + delete(rawMsg, key) + case "trigger": + err = unpopulate(val, "Trigger", &t.Trigger) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TaskPropertiesUpdateParameters. +func (t TaskPropertiesUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentConfiguration": + err = unpopulate(val, "AgentConfiguration", &t.AgentConfiguration) + delete(rawMsg, key) + case "agentPoolName": + err = unpopulate(val, "AgentPoolName", &t.AgentPoolName) + delete(rawMsg, key) + case "credentials": + err = unpopulate(val, "Credentials", &t.Credentials) + delete(rawMsg, key) + case "logTemplate": + err = unpopulate(val, "LogTemplate", &t.LogTemplate) + delete(rawMsg, key) + case "platform": + err = unpopulate(val, "Platform", &t.Platform) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &t.Status) + delete(rawMsg, key) + case "step": + t.Step, err = unmarshalTaskStepUpdateParametersClassification(val) + delete(rawMsg, key) + case "timeout": + err = unpopulate(val, "Timeout", &t.Timeout) + delete(rawMsg, key) + case "trigger": + err = unpopulate(val, "Trigger", &t.Trigger) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TaskRun. +func (t TaskRun) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "identity", t.Identity) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskRun. +func (t *TaskRun) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &t.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TaskRunListResult. +func (t TaskRunListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskRunListResult. +func (t *TaskRunListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TaskRunProperties. +func (t TaskRunProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "forceUpdateTag": + err = unpopulate(val, "ForceUpdateTag", &t.ForceUpdateTag) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &t.ProvisioningState) + delete(rawMsg, key) + case "runRequest": + t.RunRequest, err = unmarshalRunRequestClassification(val) + delete(rawMsg, key) + case "runResult": + err = unpopulate(val, "RunResult", &t.RunResult) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TaskRunPropertiesUpdateParameters. +func (t TaskRunPropertiesUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "forceUpdateTag": + err = unpopulate(val, "ForceUpdateTag", &t.ForceUpdateTag) + delete(rawMsg, key) + case "runRequest": + t.RunRequest, err = unmarshalRunRequestClassification(val) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TaskRunRequest. +func (t TaskRunRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "agentPoolName", t.AgentPoolName) + populate(objectMap, "isArchiveEnabled", t.IsArchiveEnabled) + populate(objectMap, "logTemplate", t.LogTemplate) + populate(objectMap, "overrideTaskStepProperties", t.OverrideTaskStepProperties) + populate(objectMap, "taskId", t.TaskID) + objectMap["type"] = "TaskRunRequest" + 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 fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentPoolName": + err = unpopulate(val, "AgentPoolName", &t.AgentPoolName) + delete(rawMsg, key) + case "isArchiveEnabled": + err = unpopulate(val, "IsArchiveEnabled", &t.IsArchiveEnabled) + delete(rawMsg, key) + case "logTemplate": + err = unpopulate(val, "LogTemplate", &t.LogTemplate) + delete(rawMsg, key) + case "overrideTaskStepProperties": + err = unpopulate(val, "OverrideTaskStepProperties", &t.OverrideTaskStepProperties) + delete(rawMsg, key) + case "taskId": + err = unpopulate(val, "TaskID", &t.TaskID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TaskRunUpdateParameters. +func (t TaskRunUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", t.Identity) + populate(objectMap, "location", t.Location) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskRunUpdateParameters. +func (t *TaskRunUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &t.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TaskStepProperties. +func (t TaskStepProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "baseImageDependencies", t.BaseImageDependencies) + populate(objectMap, "contextAccessToken", t.ContextAccessToken) + populate(objectMap, "contextPath", t.ContextPath) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// 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 fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "baseImageDependencies": + err = unpopulate(val, "BaseImageDependencies", &t.BaseImageDependencies) + delete(rawMsg, key) + case "contextAccessToken": + err = unpopulate(val, "ContextAccessToken", &t.ContextAccessToken) + delete(rawMsg, key) + case "contextPath": + err = unpopulate(val, "ContextPath", &t.ContextPath) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TaskStepUpdateParameters. +func (t TaskStepUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contextAccessToken", t.ContextAccessToken) + populate(objectMap, "contextPath", t.ContextPath) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// 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 fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "contextAccessToken": + err = unpopulate(val, "ContextAccessToken", &t.ContextAccessToken) + delete(rawMsg, key) + case "contextPath": + err = unpopulate(val, "ContextPath", &t.ContextPath) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TaskUpdateParameters. +func (t TaskUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", t.Identity) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskUpdateParameters. +func (t *TaskUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &t.Identity) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TimerTrigger. +func (t TimerTrigger) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", t.Name) + populate(objectMap, "schedule", t.Schedule) + populate(objectMap, "status", t.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TimerTrigger. +func (t *TimerTrigger) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "schedule": + err = unpopulate(val, "Schedule", &t.Schedule) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &t.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TimerTriggerDescriptor. +func (t TimerTriggerDescriptor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "scheduleOccurrence", t.ScheduleOccurrence) + populate(objectMap, "timerTriggerName", t.TimerTriggerName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TimerTriggerDescriptor. +func (t *TimerTriggerDescriptor) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "scheduleOccurrence": + err = unpopulate(val, "ScheduleOccurrence", &t.ScheduleOccurrence) + delete(rawMsg, key) + case "timerTriggerName": + err = unpopulate(val, "TimerTriggerName", &t.TimerTriggerName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TimerTriggerUpdateParameters. +func (t TimerTriggerUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", t.Name) + populate(objectMap, "schedule", t.Schedule) + populate(objectMap, "status", t.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TimerTriggerUpdateParameters. +func (t *TimerTriggerUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "schedule": + err = unpopulate(val, "Schedule", &t.Schedule) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &t.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TriggerProperties. +func (t TriggerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "baseImageTrigger", t.BaseImageTrigger) + populate(objectMap, "sourceTriggers", t.SourceTriggers) + populate(objectMap, "timerTriggers", t.TimerTriggers) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TriggerProperties. +func (t *TriggerProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "baseImageTrigger": + err = unpopulate(val, "BaseImageTrigger", &t.BaseImageTrigger) + delete(rawMsg, key) + case "sourceTriggers": + err = unpopulate(val, "SourceTriggers", &t.SourceTriggers) + delete(rawMsg, key) + case "timerTriggers": + err = unpopulate(val, "TimerTriggers", &t.TimerTriggers) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TriggerUpdateParameters. +func (t TriggerUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "baseImageTrigger", t.BaseImageTrigger) + populate(objectMap, "sourceTriggers", t.SourceTriggers) + populate(objectMap, "timerTriggers", t.TimerTriggers) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TriggerUpdateParameters. +func (t *TriggerUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "baseImageTrigger": + err = unpopulate(val, "BaseImageTrigger", &t.BaseImageTrigger) + delete(rawMsg, key) + case "sourceTriggers": + err = unpopulate(val, "SourceTriggers", &t.SourceTriggers) + delete(rawMsg, key) + case "timerTriggers": + err = unpopulate(val, "TimerTriggers", &t.TimerTriggers) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserIdentityProperties. +func (u UserIdentityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserIdentityProperties. +func (u *UserIdentityProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func populateTime[T dateTimeConstraints](m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + } else if !reflect.ValueOf(t).IsNil() { + newTime := T(*t) + m[k] = (*T)(&newTime) + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} + +func unpopulateTime[T dateTimeConstraints](data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux T + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + newTime := time.Time(aux) + *t = &newTime + return nil +} + +type dateTimeConstraints interface { + datetime.PlainDate | datetime.PlainTime | datetime.RFC1123 | datetime.RFC3339 | datetime.Unix +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/options.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/options.go new file mode 100644 index 000000000000..40a56eb0fd4d --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/options.go @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks + +// AgentPoolsClientBeginCreateOptions contains the optional parameters for the AgentPoolsClient.BeginCreate method. +type AgentPoolsClientBeginCreateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// AgentPoolsClientBeginDeleteOptions contains the optional parameters for the AgentPoolsClient.BeginDelete method. +type AgentPoolsClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// AgentPoolsClientBeginUpdateOptions contains the optional parameters for the AgentPoolsClient.BeginUpdate method. +type AgentPoolsClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// AgentPoolsClientGetOptions contains the optional parameters for the AgentPoolsClient.Get method. +type AgentPoolsClientGetOptions struct { + // placeholder for future optional parameters +} + +// AgentPoolsClientGetQueueStatusOptions contains the optional parameters for the AgentPoolsClient.GetQueueStatus method. +type AgentPoolsClientGetQueueStatusOptions struct { + // placeholder for future optional parameters +} + +// AgentPoolsClientListOptions contains the optional parameters for the AgentPoolsClient.NewListPager method. +type AgentPoolsClientListOptions struct { + // placeholder for future optional parameters +} + +// RegistriesClientGetBuildSourceUploadURLOptions contains the optional parameters for the RegistriesClient.GetBuildSourceUploadURL +// method. +type RegistriesClientGetBuildSourceUploadURLOptions struct { + // placeholder for future optional parameters +} + +// RegistriesClientScheduleRunOptions contains the optional parameters for the RegistriesClient.ScheduleRun method. +type RegistriesClientScheduleRunOptions struct { + // placeholder for future optional parameters +} + +// RunsClientCancelOptions contains the optional parameters for the RunsClient.Cancel method. +type RunsClientCancelOptions struct { + // placeholder for future optional parameters +} + +// RunsClientGetLogSasURLOptions contains the optional parameters for the RunsClient.GetLogSasURL method. +type RunsClientGetLogSasURLOptions struct { + // placeholder for future optional parameters +} + +// RunsClientGetOptions contains the optional parameters for the RunsClient.Get method. +type RunsClientGetOptions struct { + // placeholder for future optional parameters +} + +// RunsClientListOptions contains the optional parameters for the RunsClient.NewListPager method. +type RunsClientListOptions 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 +} + +// RunsClientUpdateOptions contains the optional parameters for the RunsClient.Update method. +type RunsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// TaskRunsClientBeginCreateOptions contains the optional parameters for the TaskRunsClient.BeginCreate method. +type TaskRunsClientBeginCreateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// TaskRunsClientBeginUpdateOptions contains the optional parameters for the TaskRunsClient.BeginUpdate method. +type TaskRunsClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// TaskRunsClientDeleteOptions contains the optional parameters for the TaskRunsClient.Delete method. +type TaskRunsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// TaskRunsClientGetDetailsOptions contains the optional parameters for the TaskRunsClient.GetDetails method. +type TaskRunsClientGetDetailsOptions struct { + // placeholder for future optional parameters +} + +// TaskRunsClientGetOptions contains the optional parameters for the TaskRunsClient.Get method. +type TaskRunsClientGetOptions struct { + // placeholder for future optional parameters +} + +// TaskRunsClientListOptions contains the optional parameters for the TaskRunsClient.NewListPager method. +type TaskRunsClientListOptions struct { + // placeholder for future optional parameters +} + +// TasksClientCreateOptions contains the optional parameters for the TasksClient.Create method. +type TasksClientCreateOptions struct { + // placeholder for future optional parameters +} + +// TasksClientDeleteOptions contains the optional parameters for the TasksClient.Delete method. +type TasksClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// TasksClientGetDetailsOptions contains the optional parameters for the TasksClient.GetDetails method. +type TasksClientGetDetailsOptions struct { + // placeholder for future optional parameters +} + +// TasksClientGetOptions contains the optional parameters for the TasksClient.Get method. +type TasksClientGetOptions struct { + // placeholder for future optional parameters +} + +// TasksClientListOptions contains the optional parameters for the TasksClient.NewListPager method. +type TasksClientListOptions struct { + // placeholder for future optional parameters +} + +// TasksClientUpdateOptions contains the optional parameters for the TasksClient.Update method. +type TasksClientUpdateOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/polymorphic_helpers.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/polymorphic_helpers.go new file mode 100644 index 000000000000..9a742aafb3af --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/polymorphic_helpers.go @@ -0,0 +1,84 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks + +import "encoding/json" + +func unmarshalRunRequestClassification(rawMsg json.RawMessage) (RunRequestClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var m map[string]any + 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{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalTaskStepPropertiesClassification(rawMsg json.RawMessage) (TaskStepPropertiesClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b TaskStepPropertiesClassification + switch m["type"] { + case string(StepTypeDocker): + b = &DockerBuildStep{} + case string(StepTypeFileTask): + b = &FileTaskStep{} + case string(StepTypeEncodedTask): + b = &EncodedTaskStep{} + default: + b = &TaskStepProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalTaskStepUpdateParametersClassification(rawMsg json.RawMessage) (TaskStepUpdateParametersClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b TaskStepUpdateParametersClassification + switch m["type"] { + case string(StepTypeDocker): + b = &DockerBuildStepUpdateParameters{} + case string(StepTypeFileTask): + b = &FileTaskStepUpdateParameters{} + case string(StepTypeEncodedTask): + b = &EncodedTaskStepUpdateParameters{} + default: + b = &TaskStepUpdateParameters{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/registries_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/registries_client.go new file mode 100644 index 000000000000..0e038a257d99 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/registries_client.go @@ -0,0 +1,174 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// RegistriesClient contains the methods for the Registries group. +// Don't use this type directly, use NewRegistriesClient() instead. +type RegistriesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewRegistriesClient creates a new instance of RegistriesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - Contains optional client configuration. Pass nil to accept the default values. +func NewRegistriesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RegistriesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &RegistriesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// GetBuildSourceUploadURL - Get the upload location for the user to be able to upload the source. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the container registry. +// - options - RegistriesClientGetBuildSourceUploadURLOptions contains the optional parameters for the RegistriesClient.GetBuildSourceUploadURL +// method. +func (client *RegistriesClient) GetBuildSourceUploadURL(ctx context.Context, resourceGroupName string, registryName string, options *RegistriesClientGetBuildSourceUploadURLOptions) (RegistriesClientGetBuildSourceUploadURLResponse, error) { + var err error + const operationName = "RegistriesClient.GetBuildSourceUploadURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getBuildSourceUploadURLCreateRequest(ctx, resourceGroupName, registryName, options) + if err != nil { + return RegistriesClientGetBuildSourceUploadURLResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RegistriesClientGetBuildSourceUploadURLResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RegistriesClientGetBuildSourceUploadURLResponse{}, err + } + resp, err := client.getBuildSourceUploadURLHandleResponse(httpResp) + return resp, err +} + +// getBuildSourceUploadURLCreateRequest creates the GetBuildSourceUploadURL request. +func (client *RegistriesClient) getBuildSourceUploadURLCreateRequest(ctx context.Context, resourceGroupName string, registryName string, _ *RegistriesClientGetBuildSourceUploadURLOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getBuildSourceUploadURLHandleResponse handles the GetBuildSourceUploadURL response. +func (client *RegistriesClient) getBuildSourceUploadURLHandleResponse(resp *http.Response) (RegistriesClientGetBuildSourceUploadURLResponse, error) { + result := RegistriesClientGetBuildSourceUploadURLResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SourceUploadDefinition); err != nil { + return RegistriesClientGetBuildSourceUploadURLResponse{}, err + } + 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 an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the container registry. +// - runRequest - The request body +// - options - RegistriesClientScheduleRunOptions contains the optional parameters for the RegistriesClient.ScheduleRun method. +func (client *RegistriesClient) ScheduleRun(ctx context.Context, resourceGroupName string, registryName string, runRequest RunRequestClassification, options *RegistriesClientScheduleRunOptions) (RegistriesClientScheduleRunResponse, error) { + var err error + const operationName = "RegistriesClient.ScheduleRun" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.scheduleRunCreateRequest(ctx, resourceGroupName, registryName, runRequest, options) + if err != nil { + return RegistriesClientScheduleRunResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RegistriesClientScheduleRunResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RegistriesClientScheduleRunResponse{}, err + } + resp, err := client.scheduleRunHandleResponse(httpResp) + return resp, err +} + +// scheduleRunCreateRequest creates the ScheduleRun request. +func (client *RegistriesClient) scheduleRunCreateRequest(ctx context.Context, resourceGroupName string, registryName string, runRequest RunRequestClassification, _ *RegistriesClientScheduleRunOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, runRequest); err != nil { + return nil, err + } + return req, nil +} + +// scheduleRunHandleResponse handles the ScheduleRun response. +func (client *RegistriesClient) scheduleRunHandleResponse(resp *http.Response) (RegistriesClientScheduleRunResponse, error) { + result := RegistriesClientScheduleRunResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Run); err != nil { + return RegistriesClientScheduleRunResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/registries_client_example_test.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/registries_client_example_test.go new file mode 100644 index 000000000000..22e86f8618ca --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/registries_client_example_test.go @@ -0,0 +1,498 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks" + "log" +) + +// Generated from example definition: 2025-03-01-preview/RegistriesGetBuildSourceUploadUrl.json +func ExampleRegistriesClient_GetBuildSourceUploadURL() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRegistriesClient().GetBuildSourceUploadURL(ctx, "myResourceGroup", "myRegistry", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.RegistriesClientGetBuildSourceUploadURLResponse{ + // SourceUploadDefinition: &armcontainerregistrytasks.SourceUploadDefinition{ + // RelativePath: to.Ptr("source/201802130000/b52f12d8-c3d6-4d75-9107-220f0bfc681d.tar.gz"), + // UploadURL: to.Ptr("https://registrystorageaccount.blob.core.windows.net/registrycontainer/source/201802130000/b52f12d8-c3d6-4d75-9107-220f0bfc681d.tar.gz?sv=2015-04-05&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWTjEg2tYkboXr1P9ZUXDtkk%3D"), + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/RegistriesScheduleRun.json +func ExampleRegistriesClient_ScheduleRun_registriesScheduleRun() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRegistriesClient().ScheduleRun(ctx, "myResourceGroup", "myRegistry", &armcontainerregistrytasks.DockerBuildRequest{ + Type: to.Ptr("DockerBuildRequest"), + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](2), + }, + Arguments: []*armcontainerregistrytasks.Argument{ + { + Name: to.Ptr("mytestargument"), + IsSecret: to.Ptr(false), + Value: to.Ptr("mytestvalue"), + }, + { + Name: to.Ptr("mysecrettestargument"), + IsSecret: to.Ptr(true), + Value: to.Ptr("mysecrettestvalue"), + }, + }, + DockerFilePath: to.Ptr("DockerFile"), + ImageNames: []*string{ + to.Ptr("azurerest:testtag"), + }, + IsArchiveEnabled: to.Ptr(true), + IsPushEnabled: to.Ptr(true), + NoCache: to.Ptr(true), + Platform: &armcontainerregistrytasks.PlatformProperties{ + Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + }, + SourceLocation: to.Ptr("https://myaccount.blob.core.windows.net/sascontainer/source.zip?sv=2015-04-05&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWTjEg2tYkboXr1P9ZUXDtkk%3D"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.RegistriesClientScheduleRunResponse{ + // Run: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/run"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/0accec26-d6de-4757-8e74-d080f38eaaab"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.617Z"); return t}()), + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusSucceeded), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/RegistriesScheduleRun_EncodedTaskRun.json +func ExampleRegistriesClient_ScheduleRun_registriesScheduleRunEncodedTaskRun() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRegistriesClient().ScheduleRun(ctx, "myResourceGroup", "myRegistry", &armcontainerregistrytasks.EncodedTaskRunRequest{ + Type: to.Ptr("EncodedTaskRunRequest"), + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](2), + }, + EncodedTaskContent: to.Ptr("c3RlcHM6Cnt7IGlmIFZhbHVlcy5lbnZpcm9ubWVudCA9PSAncHJvZCcgfX0KICAtIHJ1bjogcHJvZCBzZXR1cAp7eyBlbHNlIGlmIFZhbHVlcy5lbnZpcm9ubWVudCA9PSAnc3RhZ2luZycgfX0KICAtIHJ1bjogc3RhZ2luZyBzZXR1cAp7eyBlbHNlIH19CiAgLSBydW46IGRlZmF1bHQgc2V0dXAKe3sgZW5kIH19CgogIC0gcnVuOiBidWlsZCAtdCBGYW5jeVRoaW5nOnt7LlZhbHVlcy5lbnZpcm9ubWVudH19LXt7LlZhbHVlcy52ZXJzaW9ufX0gLgoKcHVzaDogWydGYW5jeVRoaW5nOnt7LlZhbHVlcy5lbnZpcm9ubWVudH19LXt7LlZhbHVlcy52ZXJzaW9ufX0nXQ=="), + EncodedValuesContent: to.Ptr("ZW52aXJvbm1lbnQ6IHByb2QKdmVyc2lvbjogMQ=="), + Platform: &armcontainerregistrytasks.PlatformProperties{ + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + }, + Values: []*armcontainerregistrytasks.SetValue{ + { + Name: to.Ptr("mytestargument"), + IsSecret: to.Ptr(false), + Value: to.Ptr("mytestvalue"), + }, + { + Name: to.Ptr("mysecrettestargument"), + IsSecret: to.Ptr(true), + Value: to.Ptr("mysecrettestvalue"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.RegistriesClientScheduleRunResponse{ + // Run: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/run"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/0accec26-d6de-4757-8e74-d080f38eaaab"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.617Z"); return t}()), + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusSucceeded), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/RegistriesScheduleRun_FileTaskRun.json +func ExampleRegistriesClient_ScheduleRun_registriesScheduleRunFileTaskRun() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRegistriesClient().ScheduleRun(ctx, "myResourceGroup", "myRegistry", &armcontainerregistrytasks.FileTaskRunRequest{ + Type: to.Ptr("FileTaskRunRequest"), + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](2), + }, + Platform: &armcontainerregistrytasks.PlatformProperties{ + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + }, + SourceLocation: to.Ptr("https://myaccount.blob.core.windows.net/sascontainer/source.zip?sv=2015-04-05&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWTjEg2tYkboXr1P9ZUXDtkk%3D"), + TaskFilePath: to.Ptr("acb.yaml"), + Values: []*armcontainerregistrytasks.SetValue{ + { + Name: to.Ptr("mytestargument"), + IsSecret: to.Ptr(false), + Value: to.Ptr("mytestvalue"), + }, + { + Name: to.Ptr("mysecrettestargument"), + IsSecret: to.Ptr(true), + Value: to.Ptr("mysecrettestvalue"), + }, + }, + ValuesFilePath: to.Ptr("prod-values.yaml"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.RegistriesClientScheduleRunResponse{ + // Run: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/run"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/0accec26-d6de-4757-8e74-d080f38eaaab"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.617Z"); return t}()), + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusSucceeded), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/RegistriesScheduleRun_FileTask_WithCustomCredentials.json +func ExampleRegistriesClient_ScheduleRun_registriesScheduleRunTaskWithCustomCredentials() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRegistriesClient().ScheduleRun(ctx, "myResourceGroup", "myRegistry", &armcontainerregistrytasks.FileTaskRunRequest{ + Type: to.Ptr("FileTaskRunRequest"), + Credentials: &armcontainerregistrytasks.Credentials{ + CustomRegistries: map[string]*armcontainerregistrytasks.CustomRegistryCredentials{ + "myregistry.azurecr.io": { + Password: &armcontainerregistrytasks.SecretObject{ + Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeOpaque), + Value: to.Ptr("***"), + }, + UserName: &armcontainerregistrytasks.SecretObject{ + Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeOpaque), + Value: to.Ptr("reg1"), + }, + }, + }, + SourceRegistry: &armcontainerregistrytasks.SourceRegistryCredentials{ + LoginMode: to.Ptr(armcontainerregistrytasks.SourceRegistryLoginModeDefault), + }, + }, + Platform: &armcontainerregistrytasks.PlatformProperties{ + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + }, + TaskFilePath: to.Ptr("acb.yaml"), + Values: []*armcontainerregistrytasks.SetValue{ + { + Name: to.Ptr("mytestargument"), + IsSecret: to.Ptr(false), + Value: to.Ptr("mytestvalue"), + }, + { + Name: to.Ptr("mysecrettestargument"), + IsSecret: to.Ptr(true), + Value: to.Ptr("mysecrettestvalue"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.RegistriesClientScheduleRunResponse{ + // Run: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/run"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/0accec26-d6de-4757-8e74-d080f38eaaab"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.617Z"); return t}()), + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusSucceeded), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/RegistriesScheduleRun_Task.json +func ExampleRegistriesClient_ScheduleRun_registriesScheduleRunTask() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRegistriesClient().ScheduleRun(ctx, "myResourceGroup", "myRegistry", &armcontainerregistrytasks.TaskRunRequest{ + Type: to.Ptr("TaskRunRequest"), + OverrideTaskStepProperties: &armcontainerregistrytasks.OverrideTaskStepProperties{ + Arguments: []*armcontainerregistrytasks.Argument{ + { + Name: to.Ptr("mytestargument"), + IsSecret: to.Ptr(false), + Value: to.Ptr("mytestvalue"), + }, + { + Name: to.Ptr("mysecrettestargument"), + IsSecret: to.Ptr(true), + Value: to.Ptr("mysecrettestvalue"), + }, + }, + File: to.Ptr("overriddenDockerfile"), + Target: to.Ptr("build"), + UpdateTriggerToken: to.Ptr("aGVsbG8gd29ybGQ="), + Values: []*armcontainerregistrytasks.SetValue{ + { + Name: to.Ptr("mytestname"), + IsSecret: to.Ptr(false), + Value: to.Ptr("mytestvalue"), + }, + { + Name: to.Ptr("mysecrettestname"), + IsSecret: to.Ptr(true), + Value: to.Ptr("mysecrettestvalue"), + }, + }, + }, + TaskID: to.Ptr("myTask"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.RegistriesClientScheduleRunResponse{ + // Run: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/run"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/0accec26-d6de-4757-8e74-d080f38eaaab"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.617Z"); return t}()), + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusSucceeded), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/RegistriesScheduleRun_WithCustomCredentials.json +func ExampleRegistriesClient_ScheduleRun_registriesScheduleRunWithCustomCredentials() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRegistriesClient().ScheduleRun(ctx, "myResourceGroup", "myRegistry", &armcontainerregistrytasks.DockerBuildRequest{ + Type: to.Ptr("DockerBuildRequest"), + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](2), + }, + Arguments: []*armcontainerregistrytasks.Argument{ + { + Name: to.Ptr("mytestargument"), + IsSecret: to.Ptr(false), + Value: to.Ptr("mytestvalue"), + }, + { + Name: to.Ptr("mysecrettestargument"), + IsSecret: to.Ptr(true), + Value: to.Ptr("mysecrettestvalue"), + }, + }, + Credentials: &armcontainerregistrytasks.Credentials{ + CustomRegistries: map[string]*armcontainerregistrytasks.CustomRegistryCredentials{ + "myregistry.azurecr.io": { + Password: &armcontainerregistrytasks.SecretObject{ + Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeOpaque), + Value: to.Ptr("***"), + }, + UserName: &armcontainerregistrytasks.SecretObject{ + Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeOpaque), + Value: to.Ptr("reg1"), + }, + }, + "myregistry2.azurecr.io": { + Password: &armcontainerregistrytasks.SecretObject{ + Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeOpaque), + Value: to.Ptr("***"), + }, + UserName: &armcontainerregistrytasks.SecretObject{ + Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeOpaque), + Value: to.Ptr("reg2"), + }, + }, + }, + SourceRegistry: &armcontainerregistrytasks.SourceRegistryCredentials{ + LoginMode: to.Ptr(armcontainerregistrytasks.SourceRegistryLoginModeDefault), + }, + }, + DockerFilePath: to.Ptr("DockerFile"), + ImageNames: []*string{ + to.Ptr("azurerest:testtag"), + }, + IsArchiveEnabled: to.Ptr(true), + IsPushEnabled: to.Ptr(true), + NoCache: to.Ptr(true), + Platform: &armcontainerregistrytasks.PlatformProperties{ + Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + }, + SourceLocation: to.Ptr("https://myaccount.blob.core.windows.net/sascontainer/source.zip?sv=2015-04-05&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWTjEg2tYkboXr1P9ZUXDtkk%3D"), + Target: to.Ptr("stage1"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.RegistriesClientScheduleRunResponse{ + // Run: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/run"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/0accec26-d6de-4757-8e74-d080f38eaaab"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.617Z"); return t}()), + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusSucceeded), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/RegistriesScheduleRun_WithLogTemplate.json +func ExampleRegistriesClient_ScheduleRun_registriesScheduleRunWithLogTemplate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRegistriesClient().ScheduleRun(ctx, "myResourceGroup", "myRegistry", &armcontainerregistrytasks.DockerBuildRequest{ + Type: to.Ptr("DockerBuildRequest"), + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](2), + }, + Arguments: []*armcontainerregistrytasks.Argument{ + { + Name: to.Ptr("mytestargument"), + IsSecret: to.Ptr(false), + Value: to.Ptr("mytestvalue"), + }, + { + Name: to.Ptr("mysecrettestargument"), + IsSecret: to.Ptr(true), + Value: to.Ptr("mysecrettestvalue"), + }, + }, + DockerFilePath: to.Ptr("DockerFile"), + ImageNames: []*string{ + to.Ptr("azurerest:testtag"), + }, + IsArchiveEnabled: to.Ptr(true), + IsPushEnabled: to.Ptr(true), + LogTemplate: to.Ptr("acr/tasks:{{.Run.OS}}"), + NoCache: to.Ptr(true), + Platform: &armcontainerregistrytasks.PlatformProperties{ + Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + }, + SourceLocation: to.Ptr("https://myaccount.blob.core.windows.net/sascontainer/source.zip?sv=2015-04-05&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWTjEg2tYkboXr1P9ZUXDtkk%3D"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.RegistriesClientScheduleRunResponse{ + // Run: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/run"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/0accec26-d6de-4757-8e74-d080f38eaaab"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.617Z"); return t}()), + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusSucceeded), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/responses.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/responses.go new file mode 100644 index 000000000000..ae597c442534 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/responses.go @@ -0,0 +1,162 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks + +// AgentPoolsClientCreateResponse contains the response from method AgentPoolsClient.BeginCreate. +type AgentPoolsClientCreateResponse struct { + // The agentpool that has the ARM resource and properties. + // The agentpool will have all information to create an agent pool. + AgentPool +} + +// AgentPoolsClientDeleteResponse contains the response from method AgentPoolsClient.BeginDelete. +type AgentPoolsClientDeleteResponse struct { + // placeholder for future response values +} + +// AgentPoolsClientGetQueueStatusResponse contains the response from method AgentPoolsClient.GetQueueStatus. +type AgentPoolsClientGetQueueStatusResponse struct { + // The QueueStatus of Agent Pool + AgentPoolQueueStatus +} + +// AgentPoolsClientGetResponse contains the response from method AgentPoolsClient.Get. +type AgentPoolsClientGetResponse struct { + // The agentpool that has the ARM resource and properties. + // The agentpool will have all information to create an agent pool. + AgentPool +} + +// AgentPoolsClientListResponse contains the response from method AgentPoolsClient.NewListPager. +type AgentPoolsClientListResponse struct { + // The collection of agent pools. + AgentPoolListResult +} + +// AgentPoolsClientUpdateResponse contains the response from method AgentPoolsClient.BeginUpdate. +type AgentPoolsClientUpdateResponse struct { + // The agentpool that has the ARM resource and properties. + // The agentpool will have all information to create an agent pool. + AgentPool +} + +// RegistriesClientGetBuildSourceUploadURLResponse contains the response from method RegistriesClient.GetBuildSourceUploadURL. +type RegistriesClientGetBuildSourceUploadURLResponse struct { + // The properties of a response to source upload request. + SourceUploadDefinition +} + +// RegistriesClientScheduleRunResponse contains the response from method RegistriesClient.ScheduleRun. +type RegistriesClientScheduleRunResponse struct { + // Run resource properties + Run +} + +// RunsClientCancelResponse contains the response from method RunsClient.Cancel. +type RunsClientCancelResponse struct { + // placeholder for future response values +} + +// RunsClientGetLogSasURLResponse contains the response from method RunsClient.GetLogSasURL. +type RunsClientGetLogSasURLResponse struct { + // The result of get log link operation. + RunGetLogResult +} + +// RunsClientGetResponse contains the response from method RunsClient.Get. +type RunsClientGetResponse struct { + // Run resource properties + Run +} + +// RunsClientListResponse contains the response from method RunsClient.NewListPager. +type RunsClientListResponse struct { + // The collection of runs. + RunListResult +} + +// RunsClientUpdateResponse contains the response from method RunsClient.Update. +type RunsClientUpdateResponse struct { + // Run resource properties + Run +} + +// TaskRunsClientCreateResponse contains the response from method TaskRunsClient.BeginCreate. +type TaskRunsClientCreateResponse struct { + // 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 +} + +// TaskRunsClientDeleteResponse contains the response from method TaskRunsClient.Delete. +type TaskRunsClientDeleteResponse struct { + // placeholder for future response values +} + +// TaskRunsClientGetDetailsResponse contains the response from method TaskRunsClient.GetDetails. +type TaskRunsClientGetDetailsResponse struct { + // 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 +} + +// TaskRunsClientGetResponse contains the response from method TaskRunsClient.Get. +type TaskRunsClientGetResponse struct { + // 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 +} + +// TaskRunsClientListResponse contains the response from method TaskRunsClient.NewListPager. +type TaskRunsClientListResponse struct { + // The collection of task runs. + TaskRunListResult +} + +// TaskRunsClientUpdateResponse contains the response from method TaskRunsClient.BeginUpdate. +type TaskRunsClientUpdateResponse struct { + // 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 +} + +// TasksClientCreateResponse contains the response from method TasksClient.Create. +type TasksClientCreateResponse struct { + // The task that has the ARM resource and task properties. + // The task will have all information to schedule a run against it. + Task +} + +// TasksClientDeleteResponse contains the response from method TasksClient.Delete. +type TasksClientDeleteResponse struct { + // placeholder for future response values +} + +// TasksClientGetDetailsResponse contains the response from method TasksClient.GetDetails. +type TasksClientGetDetailsResponse struct { + // The task that has the ARM resource and task properties. + // The task will have all information to schedule a run against it. + Task +} + +// TasksClientGetResponse contains the response from method TasksClient.Get. +type TasksClientGetResponse struct { + // The task that has the ARM resource and task properties. + // The task will have all information to schedule a run against it. + Task +} + +// TasksClientListResponse contains the response from method TasksClient.NewListPager. +type TasksClientListResponse struct { + // The collection of tasks. + TaskListResult +} + +// TasksClientUpdateResponse contains the response from method TasksClient.Update. +type TasksClientUpdateResponse struct { + // The task that has the ARM resource and task properties. + // The task will have all information to schedule a run against it. + Task +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/runs_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/runs_client.go new file mode 100644 index 000000000000..26860959c483 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/runs_client.go @@ -0,0 +1,381 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// RunsClient contains the methods for the Runs group. +// Don't use this type directly, use NewRunsClient() instead. +type RunsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewRunsClient creates a new instance of RunsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - Contains optional client configuration. Pass nil to accept the default values. +func NewRunsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RunsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &RunsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Cancel - Cancel an existing run. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - runID - The run ID. +// - options - RunsClientCancelOptions contains the optional parameters for the RunsClient.Cancel method. +func (client *RunsClient) Cancel(ctx context.Context, resourceGroupName string, registryName string, runID string, options *RunsClientCancelOptions) (RunsClientCancelResponse, error) { + var err error + const operationName = "RunsClient.Cancel" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.cancelCreateRequest(ctx, resourceGroupName, registryName, runID, options) + if err != nil { + return RunsClientCancelResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RunsClientCancelResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RunsClientCancelResponse{}, err + } + return RunsClientCancelResponse{}, nil +} + +// cancelCreateRequest creates the Cancel request. +func (client *RunsClient) cancelCreateRequest(ctx context.Context, resourceGroupName string, registryName string, runID string, _ *RunsClientCancelOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Gets the detailed information for a given run. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - runID - The run ID. +// - options - RunsClientGetOptions contains the optional parameters for the RunsClient.Get method. +func (client *RunsClient) Get(ctx context.Context, resourceGroupName string, registryName string, runID string, options *RunsClientGetOptions) (RunsClientGetResponse, error) { + var err error + const operationName = "RunsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, runID, options) + if err != nil { + return RunsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RunsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RunsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *RunsClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, runID string, _ *RunsClientGetOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RunsClient) getHandleResponse(resp *http.Response) (RunsClientGetResponse, error) { + result := RunsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Run); err != nil { + return RunsClientGetResponse{}, err + } + return result, nil +} + +// GetLogSasURL - Gets a link to download the run logs. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - runID - The run ID. +// - options - RunsClientGetLogSasURLOptions contains the optional parameters for the RunsClient.GetLogSasURL method. +func (client *RunsClient) GetLogSasURL(ctx context.Context, resourceGroupName string, registryName string, runID string, options *RunsClientGetLogSasURLOptions) (RunsClientGetLogSasURLResponse, error) { + var err error + const operationName = "RunsClient.GetLogSasURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getLogSasURLCreateRequest(ctx, resourceGroupName, registryName, runID, options) + if err != nil { + return RunsClientGetLogSasURLResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RunsClientGetLogSasURLResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RunsClientGetLogSasURLResponse{}, err + } + resp, err := client.getLogSasURLHandleResponse(httpResp) + return resp, err +} + +// getLogSasURLCreateRequest creates the GetLogSasURL request. +func (client *RunsClient) getLogSasURLCreateRequest(ctx context.Context, resourceGroupName string, registryName string, runID string, _ *RunsClientGetLogSasURLOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getLogSasURLHandleResponse handles the GetLogSasURL response. +func (client *RunsClient) getLogSasURLHandleResponse(resp *http.Response) (RunsClientGetLogSasURLResponse, error) { + result := RunsClientGetLogSasURLResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RunGetLogResult); err != nil { + return RunsClientGetLogSasURLResponse{}, err + } + return result, nil +} + +// NewListPager - Gets all the runs for a registry. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - options - RunsClientListOptions contains the optional parameters for the RunsClient.NewListPager method. +func (client *RunsClient) NewListPager(resourceGroupName string, registryName string, options *RunsClientListOptions) *runtime.Pager[RunsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[RunsClientListResponse]{ + More: func(page RunsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RunsClientListResponse) (RunsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RunsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, nil) + if err != nil { + return RunsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *RunsClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, options *RunsClientListOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + 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)) + } + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *RunsClient) listHandleResponse(resp *http.Response) (RunsClientListResponse, error) { + result := RunsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RunListResult); err != nil { + return RunsClientListResponse{}, err + } + return result, nil +} + +// Update - Patch the run properties. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - runID - The run ID. +// - runUpdateParameters - The run update properties. +// - options - RunsClientUpdateOptions contains the optional parameters for the RunsClient.Update method. +func (client *RunsClient) Update(ctx context.Context, resourceGroupName string, registryName string, runID string, runUpdateParameters RunUpdateParameters, options *RunsClientUpdateOptions) (RunsClientUpdateResponse, error) { + var err error + const operationName = "RunsClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, runID, runUpdateParameters, options) + if err != nil { + return RunsClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RunsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RunsClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *RunsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, runID string, runUpdateParameters RunUpdateParameters, _ *RunsClientUpdateOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, runUpdateParameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *RunsClient) updateHandleResponse(resp *http.Response) (RunsClientUpdateResponse, error) { + result := RunsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Run); err != nil { + return RunsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/runs_client_example_test.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/runs_client_example_test.go new file mode 100644 index 000000000000..34a03e23e862 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/runs_client_example_test.go @@ -0,0 +1,289 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks" + "log" +) + +// Generated from example definition: 2025-03-01-preview/RunsCancel.json +func ExampleRunsClient_Cancel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRunsClient().Cancel(ctx, "myResourceGroup", "myRegistry", "0accec26-d6de-4757-8e74-d080f38eaaab", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.RunsClientCancelResponse{ + // } +} + +// Generated from example definition: 2025-03-01-preview/RunsGet.json +func ExampleRunsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRunsClient().Get(ctx, "myResourceGroup", "myRegistry", "0accec26-d6de-4757-8e74-d080f38eaaab", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.RunsClientGetResponse{ + // Run: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/runs"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/0accec26-d6de-4757-8e74-d080f38eaaab"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.618Z"); return t}()), + // FinishTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:13:51.618Z"); return t}()), + // ImageUpdateTrigger: &armcontainerregistrytasks.ImageUpdateTrigger{ + // ID: to.Ptr("c0c43143-da5d-41ef-b9e1-e7d749272e88"), + // Images: []*armcontainerregistrytasks.ImageDescriptor{ + // { + // Digest: to.Ptr("sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0"), + // Registry: to.Ptr("registry.hub.docker.com"), + // Repository: to.Ptr("mybaseimage"), + // Tag: to.Ptr("latest"), + // }, + // }, + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.618Z"); return t}()), + // }, + // IsArchiveEnabled: to.Ptr(true), + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.617Z"); return t}()), + // LogArtifact: &armcontainerregistrytasks.ImageDescriptor{ + // Digest: to.Ptr("sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0"), + // Registry: to.Ptr("myregistry"), + // Repository: to.Ptr("acr/tasks"), + // Tag: to.Ptr("mytask-0accec26-d6de-4757-8e74-d080f38eaaab-log"), + // }, + // OutputImages: []*armcontainerregistrytasks.ImageDescriptor{ + // { + // Digest: to.Ptr("sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0"), + // Registry: to.Ptr("myregistry.azurecr.io"), + // Repository: to.Ptr("myimage"), + // Tag: to.Ptr("latest"), + // }, + // }, + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // RunType: to.Ptr(armcontainerregistrytasks.RunTypeAutoBuild), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:50:51.618Z"); return t}()), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusSucceeded), + // Task: to.Ptr("myTask"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/RunsGetLogSasUrl.json +func ExampleRunsClient_GetLogSasURL() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRunsClient().GetLogSasURL(ctx, "myResourceGroup", "myRegistry", "0accec26-d6de-4757-8e74-d080f38eaaab", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.RunsClientGetLogSasURLResponse{ + // RunGetLogResult: &armcontainerregistrytasks.RunGetLogResult{ + // LogLink: to.Ptr("https://registrystorageaccount.blob.core.windows.net/sascontainer/logs/0accec26-d6de-4757-8e74-d080f38eaaab/rawtext.log?sv=2015-04-05&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWTjEg2tYkboXr1P9ZUXDtkk%3D"), + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/RunsList.json +func ExampleRunsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRunsClient().NewListPager("myResourceGroup", "myRegistry", &armcontainerregistrytasks.RunsClientListOptions{ + Filter: to.Ptr(""), + Top: to.Ptr[int32](10)}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcontainerregistrytasks.RunsClientListResponse{ + // RunListResult: armcontainerregistrytasks.RunListResult{ + // Value: []*armcontainerregistrytasks.Run{ + // { + // Name: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/runs"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/0accec26-d6de-4757-8e74-d080f38eaaab"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.618Z"); return t}()), + // FinishTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:13:51.618Z"); return t}()), + // ImageUpdateTrigger: &armcontainerregistrytasks.ImageUpdateTrigger{ + // ID: to.Ptr("c0c43143-da5d-41ef-b9e1-e7d749272e88"), + // Images: []*armcontainerregistrytasks.ImageDescriptor{ + // { + // Digest: to.Ptr("sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0"), + // Registry: to.Ptr("registry.hub.docker.com"), + // Repository: to.Ptr("mybaseimage"), + // Tag: to.Ptr("latest"), + // }, + // }, + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.618Z"); return t}()), + // }, + // IsArchiveEnabled: to.Ptr(true), + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.617Z"); return t}()), + // LogArtifact: &armcontainerregistrytasks.ImageDescriptor{ + // Digest: to.Ptr("sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0"), + // Registry: to.Ptr("myregistry"), + // Repository: to.Ptr("acr/tasks"), + // Tag: to.Ptr("mytask-0accec26-d6de-4757-8e74-d080f38eaaab-log"), + // }, + // OutputImages: []*armcontainerregistrytasks.ImageDescriptor{ + // { + // Digest: to.Ptr("sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0"), + // Registry: to.Ptr("myregistry.azurecr.io"), + // Repository: to.Ptr("myimage"), + // Tag: to.Ptr("latest"), + // }, + // }, + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // RunType: to.Ptr(armcontainerregistrytasks.RunTypeAutoBuild), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:50:51.618Z"); return t}()), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusSucceeded), + // Task: to.Ptr("myTask"), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01-preview/RunsUpdate.json +func ExampleRunsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRunsClient().Update(ctx, "myResourceGroup", "myRegistry", "0accec26-d6de-4757-8e74-d080f38eaaab", armcontainerregistrytasks.RunUpdateParameters{ + IsArchiveEnabled: to.Ptr(true), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.RunsClientUpdateResponse{ + // Run: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/runs"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/0accec26-d6de-4757-8e74-d080f38eaaab"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.618Z"); return t}()), + // FinishTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:13:51.618Z"); return t}()), + // ImageUpdateTrigger: &armcontainerregistrytasks.ImageUpdateTrigger{ + // ID: to.Ptr("c0c43143-da5d-41ef-b9e1-e7d749272e88"), + // Images: []*armcontainerregistrytasks.ImageDescriptor{ + // { + // Digest: to.Ptr("sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0"), + // Registry: to.Ptr("registry.hub.docker.com"), + // Repository: to.Ptr("mybaseimage"), + // Tag: to.Ptr("latest"), + // }, + // }, + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.618Z"); return t}()), + // }, + // IsArchiveEnabled: to.Ptr(true), + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:13:51.617Z"); return t}()), + // LogArtifact: &armcontainerregistrytasks.ImageDescriptor{ + // Digest: to.Ptr("sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0"), + // Registry: to.Ptr("myregistry"), + // Repository: to.Ptr("acr/tasks"), + // Tag: to.Ptr("mytask-0accec26-d6de-4757-8e74-d080f38eaaab-log"), + // }, + // OutputImages: []*armcontainerregistrytasks.ImageDescriptor{ + // { + // Digest: to.Ptr("sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0"), + // Registry: to.Ptr("myregistry.azurecr.io"), + // Repository: to.Ptr("myimage"), + // Tag: to.Ptr("latest"), + // }, + // }, + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("0accec26-d6de-4757-8e74-d080f38eaaab"), + // RunType: to.Ptr(armcontainerregistrytasks.RunTypeAutoBuild), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T05:50:51.618Z"); return t}()), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusSucceeded), + // Task: to.Ptr("myTask"), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/taskruns_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/taskruns_client.go new file mode 100644 index 000000000000..81b1e4850cbd --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/taskruns_client.go @@ -0,0 +1,470 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// TaskRunsClient contains the methods for the TaskRuns group. +// Don't use this type directly, use NewTaskRunsClient() instead. +type TaskRunsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewTaskRunsClient creates a new instance of TaskRunsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - Contains optional client configuration. Pass nil to accept the default values. +func NewTaskRunsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TaskRunsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &TaskRunsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Creates a task run for a container registry with the specified parameters. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - taskRunName - The name of the task run. +// - taskRun - The parameters of a run that needs to scheduled. +// - options - TaskRunsClientBeginCreateOptions contains the optional parameters for the TaskRunsClient.BeginCreate method. +func (client *TaskRunsClient) BeginCreate(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, taskRun TaskRun, options *TaskRunsClientBeginCreateOptions) (*runtime.Poller[TaskRunsClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, registryName, taskRunName, taskRun, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TaskRunsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TaskRunsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Creates a task run for a container registry with the specified parameters. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +func (client *TaskRunsClient) create(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, taskRun TaskRun, options *TaskRunsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "TaskRunsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, taskRunName, taskRun, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *TaskRunsClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, taskRun TaskRun, _ *TaskRunsClientBeginCreateOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, taskRun); err != nil { + return nil, err + } + return req, nil +} + +// Delete - Deletes a specified task run resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - taskRunName - The name of the task run. +// - options - TaskRunsClientDeleteOptions contains the optional parameters for the TaskRunsClient.Delete method. +func (client *TaskRunsClient) Delete(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsClientDeleteOptions) (TaskRunsClientDeleteResponse, error) { + var err error + const operationName = "TaskRunsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, taskRunName, options) + if err != nil { + return TaskRunsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TaskRunsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return TaskRunsClientDeleteResponse{}, err + } + return TaskRunsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TaskRunsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, _ *TaskRunsClientDeleteOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Gets the detailed information for a given task run. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - taskRunName - The name of the task run. +// - options - TaskRunsClientGetOptions contains the optional parameters for the TaskRunsClient.Get method. +func (client *TaskRunsClient) Get(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsClientGetOptions) (TaskRunsClientGetResponse, error) { + var err error + const operationName = "TaskRunsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, taskRunName, options) + if err != nil { + return TaskRunsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TaskRunsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TaskRunsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *TaskRunsClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, _ *TaskRunsClientGetOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TaskRunsClient) getHandleResponse(resp *http.Response) (TaskRunsClientGetResponse, error) { + result := TaskRunsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TaskRun); err != nil { + return TaskRunsClientGetResponse{}, err + } + return result, nil +} + +// GetDetails - Gets the detailed information for a given task run that includes all secrets. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - taskRunName - The name of the task run. +// - options - TaskRunsClientGetDetailsOptions contains the optional parameters for the TaskRunsClient.GetDetails method. +func (client *TaskRunsClient) GetDetails(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, options *TaskRunsClientGetDetailsOptions) (TaskRunsClientGetDetailsResponse, error) { + var err error + const operationName = "TaskRunsClient.GetDetails" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getDetailsCreateRequest(ctx, resourceGroupName, registryName, taskRunName, options) + if err != nil { + return TaskRunsClientGetDetailsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TaskRunsClientGetDetailsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TaskRunsClientGetDetailsResponse{}, err + } + resp, err := client.getDetailsHandleResponse(httpResp) + return resp, err +} + +// getDetailsCreateRequest creates the GetDetails request. +func (client *TaskRunsClient) getDetailsCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, _ *TaskRunsClientGetDetailsOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getDetailsHandleResponse handles the GetDetails response. +func (client *TaskRunsClient) getDetailsHandleResponse(resp *http.Response) (TaskRunsClientGetDetailsResponse, error) { + result := TaskRunsClientGetDetailsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TaskRun); err != nil { + return TaskRunsClientGetDetailsResponse{}, err + } + return result, nil +} + +// NewListPager - Lists all the task runs for a specified container registry. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - options - TaskRunsClientListOptions contains the optional parameters for the TaskRunsClient.NewListPager method. +func (client *TaskRunsClient) NewListPager(resourceGroupName string, registryName string, options *TaskRunsClientListOptions) *runtime.Pager[TaskRunsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[TaskRunsClientListResponse]{ + More: func(page TaskRunsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TaskRunsClientListResponse) (TaskRunsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TaskRunsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, nil) + if err != nil { + return TaskRunsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *TaskRunsClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, _ *TaskRunsClientListOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *TaskRunsClient) listHandleResponse(resp *http.Response) (TaskRunsClientListResponse, error) { + result := TaskRunsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TaskRunListResult); err != nil { + return TaskRunsClientListResponse{}, err + } + return result, nil +} + +// BeginUpdate - Updates a task run with the specified parameters. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - taskRunName - The name of the task run. +// - updateParameters - The parameters for updating a task run. +// - options - TaskRunsClientBeginUpdateOptions contains the optional parameters for the TaskRunsClient.BeginUpdate method. +func (client *TaskRunsClient) BeginUpdate(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, updateParameters TaskRunUpdateParameters, options *TaskRunsClientBeginUpdateOptions) (*runtime.Poller[TaskRunsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, registryName, taskRunName, updateParameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TaskRunsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TaskRunsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Updates a task run with the specified parameters. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +func (client *TaskRunsClient) update(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, updateParameters TaskRunUpdateParameters, options *TaskRunsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "TaskRunsClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, taskRunName, updateParameters, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *TaskRunsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, updateParameters TaskRunUpdateParameters, _ *TaskRunsClientBeginUpdateOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, updateParameters); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/taskruns_client_example_test.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/taskruns_client_example_test.go new file mode 100644 index 000000000000..95f70531a4ae --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/taskruns_client_example_test.go @@ -0,0 +1,414 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks" + "log" +) + +// Generated from example definition: 2025-03-01-preview/TaskRunsCreate.json +func ExampleTaskRunsClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTaskRunsClient().BeginCreate(ctx, "myResourceGroup", "myRegistry", "myRun", armcontainerregistrytasks.TaskRun{ + Properties: &armcontainerregistrytasks.TaskRunProperties{ + ForceUpdateTag: to.Ptr("test"), + RunRequest: &armcontainerregistrytasks.EncodedTaskRunRequest{ + Type: to.Ptr("EncodedTaskRunRequest"), + Credentials: &armcontainerregistrytasks.Credentials{}, + EncodedTaskContent: to.Ptr("c3RlcHM6IAogIC0gY21kOiB7eyAuVmFsdWVzLmNvbW1hbmQgfX0K"), + EncodedValuesContent: to.Ptr("Y29tbWFuZDogYmFzaCBlY2hvIHt7LlJ1bi5SZWdpc3RyeX19Cg=="), + Platform: &armcontainerregistrytasks.PlatformProperties{ + Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + }, + Values: []*armcontainerregistrytasks.SetValue{}, + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TaskRunsClientCreateResponse{ + // TaskRun: &armcontainerregistrytasks.TaskRun{ + // Name: to.Ptr("myrun"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/TaskRuns"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/taskRuns/myRun"), + // Properties: &armcontainerregistrytasks.TaskRunProperties{ + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateCreating), + // RunRequest: &armcontainerregistrytasks.EncodedTaskRunRequest{ + // Type: to.Ptr("EncodedTaskRunRequest"), + // Credentials: &armcontainerregistrytasks.Credentials{ + // }, + // EncodedTaskContent: to.Ptr("c3RlcHM6IAogIC0gY21kOiB7eyAuVmFsdWVzLmNvbW1hbmQgfX0K"), + // EncodedValuesContent: to.Ptr("Y29tbWFuZDogYmFzaCBlY2hvIHt7LlJ1bi5SZWdpc3RyeX19Cg=="), + // IsArchiveEnabled: to.Ptr(true), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // Values: []*armcontainerregistrytasks.SetValue{ + // }, + // }, + // RunResult: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("yd5"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/runs"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/yd5"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-06T17:23:21.9261521+00:00"); return t}()), + // IsArchiveEnabled: to.Ptr(true), + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-06T17:23:21+00:00"); return t}()), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("yd5"), + // RunType: to.Ptr(armcontainerregistrytasks.RunTypeQuickRun), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusQueued), + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/TaskRunsDelete.json +func ExampleTaskRunsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTaskRunsClient().Delete(ctx, "myResourceGroup", "myRegistry", "myRun", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TaskRunsClientDeleteResponse{ + // } +} + +// Generated from example definition: 2025-03-01-preview/TaskRunsGet.json +func ExampleTaskRunsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTaskRunsClient().Get(ctx, "myResourceGroup", "myRegistry", "myRun", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TaskRunsClientGetResponse{ + // TaskRun: &armcontainerregistrytasks.TaskRun{ + // Name: to.Ptr("myRun"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/TaskRuns"), + // ID: to.Ptr("/subscriptions/3647315e-0c5b-4ce4-8739-b071e144b2c9/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/taskRuns/myRun"), + // Properties: &armcontainerregistrytasks.TaskRunProperties{ + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunRequest: &armcontainerregistrytasks.EncodedTaskRunRequest{ + // Type: to.Ptr("EncodedTaskRunRequest"), + // Credentials: &armcontainerregistrytasks.Credentials{ + // }, + // EncodedTaskContent: to.Ptr("c3RlcHM6IAogIC0gY21kOiB7eyAuVmFsdWVzLmNvbW1hbmQgfX0K"), + // EncodedValuesContent: to.Ptr("Y29tbWFuZDogYmFzaCBlY2hvIHt7LlJ1bi5SZWdpc3RyeX19Cg=="), + // IsArchiveEnabled: to.Ptr(true), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // Values: []*armcontainerregistrytasks.SetValue{ + // }, + // }, + // RunResult: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("yd5"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/runs"), + // ID: to.Ptr("/subscriptions/3647315e-0c5b-4ce4-8739-b071e144b2c9/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/yd5"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-06T17:23:21.9261521+00:00"); return t}()), + // FinishTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-06T17:23:29.8792157+00:00"); return t}()), + // IsArchiveEnabled: to.Ptr(true), + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-06T17:23:29+00:00"); return t}()), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("yd5"), + // RunType: to.Ptr(armcontainerregistrytasks.RunTypeQuickRun), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-06T17:23:22.1348714+00:00"); return t}()), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusSucceeded), + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/TaskRunsGetDetails.json +func ExampleTaskRunsClient_GetDetails() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTaskRunsClient().GetDetails(ctx, "myResourceGroup", "myRegistry", "myRun", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TaskRunsClientGetDetailsResponse{ + // TaskRun: &armcontainerregistrytasks.TaskRun{ + // Name: to.Ptr("myRun"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/TaskRuns"), + // ID: to.Ptr("/subscriptions/3647315e-0c5b-4ce4-8739-b071e144b2c9/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/taskRuns/myRun"), + // Properties: &armcontainerregistrytasks.TaskRunProperties{ + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunRequest: &armcontainerregistrytasks.EncodedTaskRunRequest{ + // Type: to.Ptr("EncodedTaskRunRequest"), + // Credentials: &armcontainerregistrytasks.Credentials{ + // }, + // EncodedTaskContent: to.Ptr("c3RlcHM6IAogIC0gY21kOiB7eyAuVmFsdWVzLmNvbW1hbmQgfX0K"), + // EncodedValuesContent: to.Ptr("Y29tbWFuZDogYmFzaCBlY2hvIHt7LlJ1bi5SZWdpc3RyeX19Cg=="), + // IsArchiveEnabled: to.Ptr(true), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // Values: []*armcontainerregistrytasks.SetValue{ + // }, + // }, + // RunResult: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("yd5"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/runs"), + // ID: to.Ptr("/subscriptions/3647315e-0c5b-4ce4-8739-b071e144b2c9/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/yd5"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-06T17:23:21.9261521+00:00"); return t}()), + // FinishTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-06T17:23:29.8792157+00:00"); return t}()), + // IsArchiveEnabled: to.Ptr(true), + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-06T17:23:29+00:00"); return t}()), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("yd5"), + // RunType: to.Ptr(armcontainerregistrytasks.RunTypeQuickRun), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-06T17:23:22.1348714+00:00"); return t}()), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusSucceeded), + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/TaskRunsList.json +func ExampleTaskRunsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTaskRunsClient().NewListPager("myResourceGroup", "myRegistry", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcontainerregistrytasks.TaskRunsClientListResponse{ + // TaskRunListResult: armcontainerregistrytasks.TaskRunListResult{ + // Value: []*armcontainerregistrytasks.TaskRun{ + // { + // Name: to.Ptr("mytestrun"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/TaskRuns"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/taskRuns/myRun"), + // Properties: &armcontainerregistrytasks.TaskRunProperties{ + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunRequest: &armcontainerregistrytasks.EncodedTaskRunRequest{ + // Type: to.Ptr("EncodedTaskRunRequest"), + // Credentials: &armcontainerregistrytasks.Credentials{ + // }, + // EncodedTaskContent: to.Ptr("c3RlcHM6IAogIC0gY21kOiB7eyAuVmFsdWVzLmNvbW1hbmQgfX0K"), + // EncodedValuesContent: to.Ptr("Y29tbWFuZDogYmFzaCBlY2hvIHt7LlJ1bi5SZWdpc3RyeX19Cg=="), + // IsArchiveEnabled: to.Ptr(true), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // Values: []*armcontainerregistrytasks.SetValue{ + // }, + // }, + // RunResult: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("yd4"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/runs"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/yd4"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-04T17:15:29.2278794+00:00"); return t}()), + // FinishTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-04T17:15:37.0349516+00:00"); return t}()), + // IsArchiveEnabled: to.Ptr(true), + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-04T17:15:37+00:00"); return t}()), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("yd4"), + // RunType: to.Ptr(armcontainerregistrytasks.RunTypeQuickRun), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-04T17:15:29.4589616+00:00"); return t}()), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusSucceeded), + // }, + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01-preview/TaskRunsUpdate.json +func ExampleTaskRunsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTaskRunsClient().BeginUpdate(ctx, "myResourceGroup", "myRegistry", "myRun", armcontainerregistrytasks.TaskRunUpdateParameters{ + Properties: &armcontainerregistrytasks.TaskRunPropertiesUpdateParameters{ + ForceUpdateTag: to.Ptr("test"), + RunRequest: &armcontainerregistrytasks.EncodedTaskRunRequest{ + Type: to.Ptr("EncodedTaskRunRequest"), + Credentials: &armcontainerregistrytasks.Credentials{}, + EncodedTaskContent: to.Ptr("c3RlcHM6IAogIC0gY21kOiB7eyAuVmFsdWVzLmNvbW1hbmQgfX0K"), + EncodedValuesContent: to.Ptr("Y29tbWFuZDogYmFzaCBlY2hvIHt7LlJ1bi5SZWdpc3RyeX19Cg=="), + IsArchiveEnabled: to.Ptr(true), + Platform: &armcontainerregistrytasks.PlatformProperties{ + Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + }, + Values: []*armcontainerregistrytasks.SetValue{}, + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TaskRunsClientUpdateResponse{ + // TaskRun: &armcontainerregistrytasks.TaskRun{ + // Name: to.Ptr("mytestrun"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/TaskRuns"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/taskRuns/myRun"), + // Properties: &armcontainerregistrytasks.TaskRunProperties{ + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateCreating), + // RunRequest: &armcontainerregistrytasks.EncodedTaskRunRequest{ + // Type: to.Ptr("EncodedTaskRunRequest"), + // Credentials: &armcontainerregistrytasks.Credentials{ + // }, + // EncodedTaskContent: to.Ptr("c3RlcHM6IAogIC0gY21kOiB7eyAuVmFsdWVzLmNvbW1hbmQgfX0K"), + // EncodedValuesContent: to.Ptr("Y29tbWFuZDogYmFzaCBlY2hvIHt7LlJ1bi5SZWdpc3RyeX19Cg=="), + // IsArchiveEnabled: to.Ptr(true), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // Values: []*armcontainerregistrytasks.SetValue{ + // }, + // }, + // RunResult: &armcontainerregistrytasks.Run{ + // Name: to.Ptr("yd6"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/runs"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/runs/yd6"), + // Properties: &armcontainerregistrytasks.RunProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-06T17:31:34.1184031+00:00"); return t}()), + // IsArchiveEnabled: to.Ptr(true), + // LastUpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-06T17:31:34+00:00"); return t}()), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // RunID: to.Ptr("yd6"), + // RunType: to.Ptr(armcontainerregistrytasks.RunTypeQuickRun), + // Status: to.Ptr(armcontainerregistrytasks.RunStatusQueued), + // }, + // }, + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/tasks_client.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/tasks_client.go new file mode 100644 index 000000000000..e9f0c07a035a --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/tasks_client.go @@ -0,0 +1,448 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// TasksClient contains the methods for the Tasks group. +// Don't use this type directly, use NewTasksClient() instead. +type TasksClient struct { + internal *arm.Client + subscriptionID string +} + +// NewTasksClient creates a new instance of TasksClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - Contains optional client configuration. Pass nil to accept the default values. +func NewTasksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TasksClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &TasksClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Create - Creates a task for a container registry with the specified parameters. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - taskName - The name of the container registry task. +// - taskCreateParameters - The parameters for creating a task. +// - options - TasksClientCreateOptions contains the optional parameters for the TasksClient.Create method. +func (client *TasksClient) Create(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskCreateParameters Task, options *TasksClientCreateOptions) (TasksClientCreateResponse, error) { + var err error + const operationName = "TasksClient.Create" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, registryName, taskName, taskCreateParameters, options) + if err != nil { + return TasksClientCreateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TasksClientCreateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return TasksClientCreateResponse{}, err + } + resp, err := client.createHandleResponse(httpResp) + return resp, err +} + +// createCreateRequest creates the Create request. +func (client *TasksClient) createCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskCreateParameters Task, _ *TasksClientCreateOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, taskCreateParameters); err != nil { + return nil, err + } + return req, nil +} + +// createHandleResponse handles the Create response. +func (client *TasksClient) createHandleResponse(resp *http.Response) (TasksClientCreateResponse, error) { + result := TasksClientCreateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Task); err != nil { + return TasksClientCreateResponse{}, err + } + return result, nil +} + +// Delete - Deletes a specified task. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - taskName - The name of the container registry task. +// - options - TasksClientDeleteOptions contains the optional parameters for the TasksClient.Delete method. +func (client *TasksClient) Delete(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *TasksClientDeleteOptions) (TasksClientDeleteResponse, error) { + var err error + const operationName = "TasksClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, registryName, taskName, options) + if err != nil { + return TasksClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TasksClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return TasksClientDeleteResponse{}, err + } + return TasksClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TasksClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskName string, _ *TasksClientDeleteOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Get the properties of a specified task. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - taskName - The name of the container registry task. +// - options - TasksClientGetOptions contains the optional parameters for the TasksClient.Get method. +func (client *TasksClient) Get(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *TasksClientGetOptions) (TasksClientGetResponse, error) { + var err error + const operationName = "TasksClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, registryName, taskName, options) + if err != nil { + return TasksClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TasksClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TasksClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *TasksClient) getCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskName string, _ *TasksClientGetOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TasksClient) getHandleResponse(resp *http.Response) (TasksClientGetResponse, error) { + result := TasksClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Task); err != nil { + return TasksClientGetResponse{}, err + } + return result, nil +} + +// GetDetails - Returns a task with extended information that includes all secrets. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - taskName - The name of the container registry task. +// - options - TasksClientGetDetailsOptions contains the optional parameters for the TasksClient.GetDetails method. +func (client *TasksClient) GetDetails(ctx context.Context, resourceGroupName string, registryName string, taskName string, options *TasksClientGetDetailsOptions) (TasksClientGetDetailsResponse, error) { + var err error + const operationName = "TasksClient.GetDetails" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getDetailsCreateRequest(ctx, resourceGroupName, registryName, taskName, options) + if err != nil { + return TasksClientGetDetailsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TasksClientGetDetailsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TasksClientGetDetailsResponse{}, err + } + resp, err := client.getDetailsHandleResponse(httpResp) + return resp, err +} + +// getDetailsCreateRequest creates the GetDetails request. +func (client *TasksClient) getDetailsCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskName string, _ *TasksClientGetDetailsOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getDetailsHandleResponse handles the GetDetails response. +func (client *TasksClient) getDetailsHandleResponse(resp *http.Response) (TasksClientGetDetailsResponse, error) { + result := TasksClientGetDetailsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Task); err != nil { + return TasksClientGetDetailsResponse{}, err + } + return result, nil +} + +// NewListPager - Lists all the tasks for a specified container registry. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - options - TasksClientListOptions contains the optional parameters for the TasksClient.NewListPager method. +func (client *TasksClient) NewListPager(resourceGroupName string, registryName string, options *TasksClientListOptions) *runtime.Pager[TasksClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[TasksClientListResponse]{ + More: func(page TasksClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TasksClientListResponse) (TasksClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TasksClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, registryName, options) + }, nil) + if err != nil { + return TasksClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *TasksClient) listCreateRequest(ctx context.Context, resourceGroupName string, registryName string, _ *TasksClientListOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *TasksClient) listHandleResponse(resp *http.Response) (TasksClientListResponse, error) { + result := TasksClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TaskListResult); err != nil { + return TasksClientListResponse{}, err + } + return result, nil +} + +// Update - Updates a task with the specified parameters. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-03-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - registryName - The name of the Registry +// - taskName - The name of the container registry task. +// - taskUpdateParameters - The parameters for updating a task. +// - options - TasksClientUpdateOptions contains the optional parameters for the TasksClient.Update method. +func (client *TasksClient) Update(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskUpdateParameters TaskUpdateParameters, options *TasksClientUpdateOptions) (TasksClientUpdateResponse, error) { + var err error + const operationName = "TasksClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, registryName, taskName, taskUpdateParameters, options) + if err != nil { + return TasksClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TasksClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TasksClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *TasksClient) updateCreateRequest(ctx context.Context, resourceGroupName string, registryName string, taskName string, taskUpdateParameters TaskUpdateParameters, _ *TasksClientUpdateOptions) (*policy.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 := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, taskUpdateParameters); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *TasksClient) updateHandleResponse(resp *http.Response) (TasksClientUpdateResponse, error) { + result := TasksClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Task); err != nil { + return TasksClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/tasks_client_example_test.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/tasks_client_example_test.go new file mode 100644 index 000000000000..2e5cff196711 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/tasks_client_example_test.go @@ -0,0 +1,2024 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcontainerregistrytasks_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks" + "log" +) + +// Generated from example definition: 2025-03-01-preview/ManagedIdentity/TasksCreate_WithLoginIdentity.json +func ExampleTasksClient_Create_tasksCreateWithLoginIdentity() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Create(ctx, "myResourceGroup", "myRegistry", "mytTask", armcontainerregistrytasks.Task{ + Identity: &armcontainerregistrytasks.IdentityProperties{ + Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("eastus"), + Properties: &armcontainerregistrytasks.TaskProperties{ + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](2), + }, + Credentials: &armcontainerregistrytasks.Credentials{ + SourceRegistry: &armcontainerregistrytasks.SourceRegistryCredentials{ + Identity: to.Ptr("[system]"), + }, + }, + IsSystemTask: to.Ptr(false), + Platform: &armcontainerregistrytasks.PlatformProperties{ + Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + }, + Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + Step: &armcontainerregistrytasks.DockerBuildStep{ + Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + Arguments: []*armcontainerregistrytasks.Argument{ + { + Name: to.Ptr("mytestargument"), + IsSecret: to.Ptr(false), + Value: to.Ptr("mytestvalue"), + }, + { + Name: to.Ptr("mysecrettestargument"), + IsSecret: to.Ptr(true), + Value: to.Ptr("mysecrettestvalue"), + }, + }, + ContextPath: to.Ptr("src"), + DockerFilePath: to.Ptr("src/DockerFile"), + ImageNames: []*string{ + to.Ptr("azurerest:testtag"), + }, + IsPushEnabled: to.Ptr(true), + NoCache: to.Ptr(false), + }, + Trigger: &armcontainerregistrytasks.TriggerProperties{ + BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + Name: to.Ptr("myBaseImageTrigger"), + BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + }, + SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + { + Name: to.Ptr("mySourceTrigger"), + SourceRepository: &armcontainerregistrytasks.SourceProperties{ + Branch: to.Ptr("master"), + RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + SourceControlAuthProperties: &armcontainerregistrytasks.AuthInfo{ + Token: to.Ptr("xxxxx"), + TokenType: to.Ptr(armcontainerregistrytasks.TokenTypePAT), + }, + SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + }, + SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + }, + }, + }, + TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + { + Name: to.Ptr("myTimerTrigger"), + Schedule: to.Ptr("30 9 * * 1-5"), + }, + }, + }, + }, + Tags: map[string]*string{ + "testkey": to.Ptr("value"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientCreateResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Name: to.Ptr("myTask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Identity: &armcontainerregistrytasks.IdentityProperties{ + // Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("fa153151-b9fd-46f4-9088-5e6600f2689v"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-abu4gm510ccd"), + // }, + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // Credentials: &armcontainerregistrytasks.Credentials{ + // SourceRegistry: &armcontainerregistrytasks.SourceRegistryCredentials{ + // Identity: to.Ptr("[system]"), + // }, + // }, + // IsSystemTask: to.Ptr(false), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // Step: &armcontainerregistrytasks.DockerBuildStep{ + // Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + // Arguments: []*armcontainerregistrytasks.Argument{ + // { + // Name: to.Ptr("mytestargument"), + // IsSecret: to.Ptr(false), + // Value: to.Ptr("mytestvalue"), + // }, + // }, + // ContextPath: to.Ptr("src"), + // DockerFilePath: to.Ptr("src/DockerFile"), + // ImageNames: []*string{ + // to.Ptr("azurerest:testtag"), + // }, + // IsPushEnabled: to.Ptr(true), + // NoCache: to.Ptr(false), + // }, + // Trigger: &armcontainerregistrytasks.TriggerProperties{ + // BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + // Name: to.Ptr("myBaseImageTrigger"), + // BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + // { + // Name: to.Ptr("mySourceTrigger"), + // SourceRepository: &armcontainerregistrytasks.SourceProperties{ + // Branch: to.Ptr("master"), + // RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + // SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + // }, + // SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + // to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + // { + // Name: to.Ptr("myTimerTrigger"), + // Schedule: to.Ptr("30 9 * * 1-5"), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/ManagedIdentity/TasksCreate_WithSystemAndUserIdentities.json +func ExampleTasksClient_Create_tasksCreateWithSystemAndUserIdentities() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Create(ctx, "myResourceGroup", "myRegistry", "mytTask", armcontainerregistrytasks.Task{ + Identity: &armcontainerregistrytasks.IdentityProperties{ + Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssignedUserAssigned), + UserAssignedIdentities: map[string]*armcontainerregistrytasks.UserIdentityProperties{ + "/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourcegroups/myResourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity2": {}, + }, + }, + Location: to.Ptr("eastus"), + Properties: &armcontainerregistrytasks.TaskProperties{ + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](2), + }, + IsSystemTask: to.Ptr(false), + Platform: &armcontainerregistrytasks.PlatformProperties{ + Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + }, + Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + Step: &armcontainerregistrytasks.DockerBuildStep{ + Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + Arguments: []*armcontainerregistrytasks.Argument{ + { + Name: to.Ptr("mytestargument"), + IsSecret: to.Ptr(false), + Value: to.Ptr("mytestvalue"), + }, + { + Name: to.Ptr("mysecrettestargument"), + IsSecret: to.Ptr(true), + Value: to.Ptr("mysecrettestvalue"), + }, + }, + ContextPath: to.Ptr("src"), + DockerFilePath: to.Ptr("src/DockerFile"), + ImageNames: []*string{ + to.Ptr("azurerest:testtag"), + }, + IsPushEnabled: to.Ptr(true), + NoCache: to.Ptr(false), + }, + Trigger: &armcontainerregistrytasks.TriggerProperties{ + BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + Name: to.Ptr("myBaseImageTrigger"), + BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + UpdateTriggerEndpoint: to.Ptr("https://user:pass@mycicd.webhook.com?token=foo"), + UpdateTriggerPayloadType: to.Ptr(armcontainerregistrytasks.UpdateTriggerPayloadTypeDefault), + }, + SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + { + Name: to.Ptr("mySourceTrigger"), + SourceRepository: &armcontainerregistrytasks.SourceProperties{ + Branch: to.Ptr("master"), + RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + SourceControlAuthProperties: &armcontainerregistrytasks.AuthInfo{ + Token: to.Ptr("xxxxx"), + TokenType: to.Ptr(armcontainerregistrytasks.TokenTypePAT), + }, + SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + }, + SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + }, + }, + }, + TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + { + Name: to.Ptr("myTimerTrigger"), + Schedule: to.Ptr("30 9 * * 1-5"), + }, + }, + }, + }, + Tags: map[string]*string{ + "testkey": to.Ptr("value"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientCreateResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Name: to.Ptr("myTask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Identity: &armcontainerregistrytasks.IdentityProperties{ + // Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssignedUserAssigned), + // PrincipalID: to.Ptr("fc99dc67-1ad9-45c8-9ebc-e438081c8e30"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), + // UserAssignedIdentities: map[string]*armcontainerregistrytasks.UserIdentityProperties{ + // "/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourcegroups/myResourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity2": &armcontainerregistrytasks.UserIdentityProperties{ + // ClientID: to.Ptr("e35621a5-f615-4a20-940e-de8a84b15abc"), + // PrincipalID: to.Ptr("e45e3m7c-176e-416a-b466-0c5ec8298f8a"), + // }, + // }, + // }, + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // IsSystemTask: to.Ptr(false), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // Step: &armcontainerregistrytasks.DockerBuildStep{ + // Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + // Arguments: []*armcontainerregistrytasks.Argument{ + // { + // Name: to.Ptr("mytestargument"), + // IsSecret: to.Ptr(false), + // Value: to.Ptr("mytestvalue"), + // }, + // }, + // ContextPath: to.Ptr("src"), + // DockerFilePath: to.Ptr("src/DockerFile"), + // ImageNames: []*string{ + // to.Ptr("azurerest:testtag"), + // }, + // IsPushEnabled: to.Ptr(true), + // NoCache: to.Ptr(false), + // }, + // Trigger: &armcontainerregistrytasks.TriggerProperties{ + // BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + // Name: to.Ptr("myBaseImageTrigger"), + // BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // UpdateTriggerPayloadType: to.Ptr(armcontainerregistrytasks.UpdateTriggerPayloadTypeDefault), + // }, + // SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + // { + // Name: to.Ptr("mySourceTrigger"), + // SourceRepository: &armcontainerregistrytasks.SourceProperties{ + // Branch: to.Ptr("master"), + // RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + // SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + // }, + // SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + // to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + // { + // Name: to.Ptr("myTimerTrigger"), + // Schedule: to.Ptr("30 9 * * 1-5"), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/ManagedIdentity/TasksCreate_WithSystemIdentity.json +func ExampleTasksClient_Create_tasksCreateWithUserIdentitiesWithSystemIdentity() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Create(ctx, "myResourceGroup", "myRegistry", "mytTask", armcontainerregistrytasks.Task{ + Identity: &armcontainerregistrytasks.IdentityProperties{ + Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("eastus"), + Properties: &armcontainerregistrytasks.TaskProperties{ + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](2), + }, + IsSystemTask: to.Ptr(false), + Platform: &armcontainerregistrytasks.PlatformProperties{ + Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + }, + Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + Step: &armcontainerregistrytasks.DockerBuildStep{ + Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + Arguments: []*armcontainerregistrytasks.Argument{ + { + Name: to.Ptr("mytestargument"), + IsSecret: to.Ptr(false), + Value: to.Ptr("mytestvalue"), + }, + { + Name: to.Ptr("mysecrettestargument"), + IsSecret: to.Ptr(true), + Value: to.Ptr("mysecrettestvalue"), + }, + }, + ContextPath: to.Ptr("src"), + DockerFilePath: to.Ptr("src/DockerFile"), + ImageNames: []*string{ + to.Ptr("azurerest:testtag"), + }, + IsPushEnabled: to.Ptr(true), + NoCache: to.Ptr(false), + }, + Trigger: &armcontainerregistrytasks.TriggerProperties{ + BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + Name: to.Ptr("myBaseImageTrigger"), + BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + }, + SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + { + Name: to.Ptr("mySourceTrigger"), + SourceRepository: &armcontainerregistrytasks.SourceProperties{ + Branch: to.Ptr("master"), + RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + SourceControlAuthProperties: &armcontainerregistrytasks.AuthInfo{ + Token: to.Ptr("xxxxx"), + TokenType: to.Ptr(armcontainerregistrytasks.TokenTypePAT), + }, + SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + }, + SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + }, + }, + }, + TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + { + Name: to.Ptr("myTimerTrigger"), + Schedule: to.Ptr("30 9 * * 1-5"), + }, + }, + }, + }, + Tags: map[string]*string{ + "testkey": to.Ptr("value"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientCreateResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Name: to.Ptr("myTask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Identity: &armcontainerregistrytasks.IdentityProperties{ + // Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("fa153151-b9fd-46f4-9088-5e6600f2689v"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-abu4gm510ccd"), + // }, + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // IsSystemTask: to.Ptr(false), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // Step: &armcontainerregistrytasks.DockerBuildStep{ + // Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + // Arguments: []*armcontainerregistrytasks.Argument{ + // { + // Name: to.Ptr("mytestargument"), + // IsSecret: to.Ptr(false), + // Value: to.Ptr("mytestvalue"), + // }, + // }, + // ContextPath: to.Ptr("src"), + // DockerFilePath: to.Ptr("src/DockerFile"), + // ImageNames: []*string{ + // to.Ptr("azurerest:testtag"), + // }, + // IsPushEnabled: to.Ptr(true), + // NoCache: to.Ptr(false), + // }, + // Trigger: &armcontainerregistrytasks.TriggerProperties{ + // BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + // Name: to.Ptr("myBaseImageTrigger"), + // BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + // { + // Name: to.Ptr("mySourceTrigger"), + // SourceRepository: &armcontainerregistrytasks.SourceProperties{ + // Branch: to.Ptr("master"), + // RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + // SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + // }, + // SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + // to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + // { + // Name: to.Ptr("myTimerTrigger"), + // Schedule: to.Ptr("30 9 * * 1-5"), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/ManagedIdentity/TasksCreate_WithUserIdentities.json +func ExampleTasksClient_Create_tasksCreateWithUserIdentities() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Create(ctx, "myResourceGroup", "myRegistry", "mytTask", armcontainerregistrytasks.Task{ + Identity: &armcontainerregistrytasks.IdentityProperties{ + Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeUserAssigned), + UserAssignedIdentities: map[string]*armcontainerregistrytasks.UserIdentityProperties{ + "/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourcegroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1": {}, + "/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourcegroups/myResourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity2": {}, + }, + }, + Location: to.Ptr("eastus"), + Properties: &armcontainerregistrytasks.TaskProperties{ + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](2), + }, + IsSystemTask: to.Ptr(false), + Platform: &armcontainerregistrytasks.PlatformProperties{ + Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + }, + Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + Step: &armcontainerregistrytasks.DockerBuildStep{ + Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + Arguments: []*armcontainerregistrytasks.Argument{ + { + Name: to.Ptr("mytestargument"), + IsSecret: to.Ptr(false), + Value: to.Ptr("mytestvalue"), + }, + { + Name: to.Ptr("mysecrettestargument"), + IsSecret: to.Ptr(true), + Value: to.Ptr("mysecrettestvalue"), + }, + }, + ContextPath: to.Ptr("src"), + DockerFilePath: to.Ptr("src/DockerFile"), + ImageNames: []*string{ + to.Ptr("azurerest:testtag"), + }, + IsPushEnabled: to.Ptr(true), + NoCache: to.Ptr(false), + }, + Trigger: &armcontainerregistrytasks.TriggerProperties{ + BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + Name: to.Ptr("myBaseImageTrigger"), + BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + UpdateTriggerEndpoint: to.Ptr("https://user:pass@mycicd.webhook.com?token=foo"), + UpdateTriggerPayloadType: to.Ptr(armcontainerregistrytasks.UpdateTriggerPayloadTypeDefault), + }, + SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + { + Name: to.Ptr("mySourceTrigger"), + SourceRepository: &armcontainerregistrytasks.SourceProperties{ + Branch: to.Ptr("master"), + RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + SourceControlAuthProperties: &armcontainerregistrytasks.AuthInfo{ + Token: to.Ptr("xxxxx"), + TokenType: to.Ptr(armcontainerregistrytasks.TokenTypePAT), + }, + SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + }, + SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + }, + }, + }, + TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + { + Name: to.Ptr("myTimerTrigger"), + Schedule: to.Ptr("30 9 * * 1-5"), + }, + }, + }, + }, + Tags: map[string]*string{ + "testkey": to.Ptr("value"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientCreateResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Name: to.Ptr("myTask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Identity: &armcontainerregistrytasks.IdentityProperties{ + // Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armcontainerregistrytasks.UserIdentityProperties{ + // "/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourcegroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1": &armcontainerregistrytasks.UserIdentityProperties{ + // ClientID: to.Ptr("d3ce1bc2-f7d7-4a5b-9979-950f4e57680e"), + // PrincipalID: to.Ptr("b6p9f58b-6fbf-4efd-a7e0-fvd46911a466"), + // }, + // "/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourcegroups/myResourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity2": &armcontainerregistrytasks.UserIdentityProperties{ + // ClientID: to.Ptr("e35621a5-f615-4a20-940e-de8a84b15abc"), + // PrincipalID: to.Ptr("e45e3m7c-176e-416a-b466-0c5ec8298f8a"), + // }, + // }, + // }, + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // IsSystemTask: to.Ptr(false), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // Step: &armcontainerregistrytasks.DockerBuildStep{ + // Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + // Arguments: []*armcontainerregistrytasks.Argument{ + // { + // Name: to.Ptr("mytestargument"), + // IsSecret: to.Ptr(false), + // Value: to.Ptr("mytestvalue"), + // }, + // }, + // ContextPath: to.Ptr("src"), + // DockerFilePath: to.Ptr("src/DockerFile"), + // ImageNames: []*string{ + // to.Ptr("azurerest:testtag"), + // }, + // IsPushEnabled: to.Ptr(true), + // NoCache: to.Ptr(false), + // }, + // Trigger: &armcontainerregistrytasks.TriggerProperties{ + // BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + // Name: to.Ptr("myBaseImageTrigger"), + // BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // UpdateTriggerPayloadType: to.Ptr(armcontainerregistrytasks.UpdateTriggerPayloadTypeDefault), + // }, + // SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + // { + // Name: to.Ptr("mySourceTrigger"), + // SourceRepository: &armcontainerregistrytasks.SourceProperties{ + // Branch: to.Ptr("master"), + // RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + // SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + // }, + // SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + // to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + // { + // Name: to.Ptr("myTimerTrigger"), + // Schedule: to.Ptr("30 9 * * 1-5"), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/TasksCreate.json +func ExampleTasksClient_Create_tasksCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Create(ctx, "myResourceGroup", "myRegistry", "mytTask", armcontainerregistrytasks.Task{ + Identity: &armcontainerregistrytasks.IdentityProperties{ + Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("eastus"), + Properties: &armcontainerregistrytasks.TaskProperties{ + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](2), + }, + IsSystemTask: to.Ptr(false), + LogTemplate: to.Ptr("acr/tasks:{{.Run.OS}}"), + Platform: &armcontainerregistrytasks.PlatformProperties{ + Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + OS: to.Ptr(armcontainerregistrytasks.OSLinux), + }, + Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + Step: &armcontainerregistrytasks.DockerBuildStep{ + Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + Arguments: []*armcontainerregistrytasks.Argument{ + { + Name: to.Ptr("mytestargument"), + IsSecret: to.Ptr(false), + Value: to.Ptr("mytestvalue"), + }, + { + Name: to.Ptr("mysecrettestargument"), + IsSecret: to.Ptr(true), + Value: to.Ptr("mysecrettestvalue"), + }, + }, + ContextPath: to.Ptr("src"), + DockerFilePath: to.Ptr("src/DockerFile"), + ImageNames: []*string{ + to.Ptr("azurerest:testtag"), + }, + IsPushEnabled: to.Ptr(true), + NoCache: to.Ptr(false), + }, + Trigger: &armcontainerregistrytasks.TriggerProperties{ + BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + Name: to.Ptr("myBaseImageTrigger"), + BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + UpdateTriggerEndpoint: to.Ptr("https://user:pass@mycicd.webhook.com?token=foo"), + UpdateTriggerPayloadType: to.Ptr(armcontainerregistrytasks.UpdateTriggerPayloadTypeToken), + }, + SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + { + Name: to.Ptr("mySourceTrigger"), + SourceRepository: &armcontainerregistrytasks.SourceProperties{ + Branch: to.Ptr("master"), + RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + SourceControlAuthProperties: &armcontainerregistrytasks.AuthInfo{ + Token: to.Ptr("xxxxx"), + TokenType: to.Ptr(armcontainerregistrytasks.TokenTypePAT), + }, + SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + }, + SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + }, + }, + }, + TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + { + Name: to.Ptr("myTimerTrigger"), + Schedule: to.Ptr("30 9 * * 1-5"), + }, + }, + }, + }, + Tags: map[string]*string{ + "testkey": to.Ptr("value"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientCreateResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Name: to.Ptr("myTask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Identity: &armcontainerregistrytasks.IdentityProperties{ + // Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("fa153151-b9fd-46f4-9088-5e6600f2689v"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-abu4gm510ccd"), + // }, + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // IsSystemTask: to.Ptr(false), + // LogTemplate: to.Ptr("acr/tasks:{{.Run.OS}}"), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // Step: &armcontainerregistrytasks.DockerBuildStep{ + // Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + // Arguments: []*armcontainerregistrytasks.Argument{ + // { + // Name: to.Ptr("mytestargument"), + // IsSecret: to.Ptr(false), + // Value: to.Ptr("mytestvalue"), + // }, + // }, + // ContextPath: to.Ptr("src"), + // DockerFilePath: to.Ptr("src/DockerFile"), + // ImageNames: []*string{ + // to.Ptr("azurerest:testtag"), + // }, + // IsPushEnabled: to.Ptr(true), + // NoCache: to.Ptr(false), + // }, + // Trigger: &armcontainerregistrytasks.TriggerProperties{ + // BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + // Name: to.Ptr("myBaseImageTrigger"), + // BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // UpdateTriggerPayloadType: to.Ptr(armcontainerregistrytasks.UpdateTriggerPayloadTypeToken), + // }, + // SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + // { + // Name: to.Ptr("mySourceTrigger"), + // SourceRepository: &armcontainerregistrytasks.SourceProperties{ + // Branch: to.Ptr("master"), + // RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + // SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + // }, + // SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + // to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + // { + // Name: to.Ptr("myTimerTrigger"), + // Schedule: to.Ptr("30 9 * * 1-5"), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/TasksCreate_QuickTask.json +func ExampleTasksClient_Create_tasksCreateQuickTask() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Create(ctx, "myResourceGroup", "myRegistry", "quicktask", armcontainerregistrytasks.Task{ + Location: to.Ptr("eastus"), + Properties: &armcontainerregistrytasks.TaskProperties{ + IsSystemTask: to.Ptr(true), + LogTemplate: to.Ptr("acr/tasks:{{.Run.OS}}"), + Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + }, + Tags: map[string]*string{ + "testkey": to.Ptr("value"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientCreateResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Name: to.Ptr("quicktask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // IsSystemTask: to.Ptr(true), + // LogTemplate: to.Ptr("acr/tasks:{{.Run.OS}}"), + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/TasksDelete.json +func ExampleTasksClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Delete(ctx, "myResourceGroup", "myRegistry", "myTask", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientDeleteResponse{ + // } +} + +// Generated from example definition: 2025-03-01-preview/TasksGet.json +func ExampleTasksClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Get(ctx, "myResourceGroup", "myRegistry", "myTask", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientGetResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Name: to.Ptr("myTask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Identity: &armcontainerregistrytasks.IdentityProperties{ + // Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("fa153151-b9fd-46f4-9088-5e6600f2689v"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-abu4gm510ccd"), + // }, + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // Credentials: &armcontainerregistrytasks.Credentials{ + // CustomRegistries: map[string]*armcontainerregistrytasks.CustomRegistryCredentials{ + // }, + // }, + // IsSystemTask: to.Ptr(false), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // Step: &armcontainerregistrytasks.DockerBuildStep{ + // Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + // Arguments: []*armcontainerregistrytasks.Argument{ + // { + // Name: to.Ptr("mytestargument"), + // IsSecret: to.Ptr(false), + // Value: to.Ptr("mytestvalue"), + // }, + // }, + // ContextPath: to.Ptr("src"), + // DockerFilePath: to.Ptr("src/DockerFile"), + // ImageNames: []*string{ + // to.Ptr("azurerest:testtag"), + // }, + // IsPushEnabled: to.Ptr(true), + // NoCache: to.Ptr(false), + // }, + // Trigger: &armcontainerregistrytasks.TriggerProperties{ + // BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + // Name: to.Ptr("myBaseImageTrigger"), + // BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // UpdateTriggerPayloadType: to.Ptr(armcontainerregistrytasks.UpdateTriggerPayloadTypeToken), + // }, + // SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + // { + // Name: to.Ptr("mySourceTrigger"), + // SourceRepository: &armcontainerregistrytasks.SourceProperties{ + // Branch: to.Ptr("master"), + // RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + // SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + // }, + // SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + // to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + // { + // Name: to.Ptr("myTimerTrigger"), + // Schedule: to.Ptr("30 9 * * 1-5"), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/TasksGetDetails.json +func ExampleTasksClient_GetDetails() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().GetDetails(ctx, "myResourceGroup", "myRegistry", "myTask", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientGetDetailsResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Identity: &armcontainerregistrytasks.IdentityProperties{ + // Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("fa153151-b9fd-46f4-9088-5e6600f2689v"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-abu4gm510ccd"), + // }, + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // Credentials: &armcontainerregistrytasks.Credentials{ + // CustomRegistries: map[string]*armcontainerregistrytasks.CustomRegistryCredentials{ + // "myregistry.azure-test.io": &armcontainerregistrytasks.CustomRegistryCredentials{ + // Identity: to.Ptr("[system]"), + // Password: &armcontainerregistrytasks.SecretObject{ + // Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeVaultsecret), + // Value: to.Ptr("https://myacbvault.vault.azure.net/secrets/username"), + // }, + // UserName: &armcontainerregistrytasks.SecretObject{ + // Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeOpaque), + // Value: to.Ptr("username"), + // }, + // }, + // }, + // }, + // IsSystemTask: to.Ptr(false), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // Step: &armcontainerregistrytasks.DockerBuildStep{ + // Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + // Arguments: []*armcontainerregistrytasks.Argument{ + // { + // Name: to.Ptr("mytestargument"), + // IsSecret: to.Ptr(false), + // Value: to.Ptr("mytestvalue"), + // }, + // { + // Name: to.Ptr("mysecrettestargument"), + // IsSecret: to.Ptr(true), + // Value: to.Ptr("mysecrettestvalue"), + // }, + // }, + // ContextPath: to.Ptr("src"), + // DockerFilePath: to.Ptr("src/DockerFile"), + // ImageNames: []*string{ + // to.Ptr("azurerest:testtag"), + // }, + // IsPushEnabled: to.Ptr(true), + // NoCache: to.Ptr(false), + // }, + // Trigger: &armcontainerregistrytasks.TriggerProperties{ + // BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + // Name: to.Ptr("myBaseImageTrigger"), + // BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // UpdateTriggerEndpoint: to.Ptr("https://user:pass@mycicd.webhook.com?token=foo"), + // UpdateTriggerPayloadType: to.Ptr(armcontainerregistrytasks.UpdateTriggerPayloadTypeToken), + // }, + // SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + // { + // Name: to.Ptr("mySourceTrigger"), + // SourceRepository: &armcontainerregistrytasks.SourceProperties{ + // Branch: to.Ptr("master"), + // RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + // SourceControlAuthProperties: &armcontainerregistrytasks.AuthInfo{ + // Token: to.Ptr("xxxxx"), + // TokenType: to.Ptr(armcontainerregistrytasks.TokenTypePAT), + // }, + // SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + // }, + // SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + // to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + // { + // Name: to.Ptr("myTimerTrigger"), + // Schedule: to.Ptr("30 9 * * 1-5"), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/TasksList.json +func ExampleTasksClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTasksClient().NewListPager("myResourceGroup", "myRegistry", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcontainerregistrytasks.TasksClientListResponse{ + // TaskListResult: armcontainerregistrytasks.TaskListResult{ + // Value: []*armcontainerregistrytasks.Task{ + // { + // Name: to.Ptr("myTask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Identity: &armcontainerregistrytasks.IdentityProperties{ + // Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("fa153151-b9fd-46f4-9088-5e6600f2689v"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-abu4gm510ccd"), + // }, + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](2), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // Credentials: &armcontainerregistrytasks.Credentials{ + // CustomRegistries: map[string]*armcontainerregistrytasks.CustomRegistryCredentials{ + // }, + // }, + // IsSystemTask: to.Ptr(false), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // Step: &armcontainerregistrytasks.DockerBuildStep{ + // Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + // Arguments: []*armcontainerregistrytasks.Argument{ + // { + // Name: to.Ptr("mytestargument"), + // IsSecret: to.Ptr(false), + // Value: to.Ptr("mytestvalue"), + // }, + // }, + // ContextPath: to.Ptr("src"), + // DockerFilePath: to.Ptr("src/DockerFile"), + // ImageNames: []*string{ + // to.Ptr("azurerest:testtag"), + // }, + // IsPushEnabled: to.Ptr(true), + // NoCache: to.Ptr(false), + // }, + // Trigger: &armcontainerregistrytasks.TriggerProperties{ + // BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + // Name: to.Ptr("myBaseImageTrigger"), + // BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // UpdateTriggerPayloadType: to.Ptr(armcontainerregistrytasks.UpdateTriggerPayloadTypeDefault), + // }, + // SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + // { + // Name: to.Ptr("mySourceTrigger"), + // SourceRepository: &armcontainerregistrytasks.SourceProperties{ + // Branch: to.Ptr("master"), + // RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + // SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + // }, + // SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + // to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + // { + // Name: to.Ptr("myTimerTrigger"), + // Schedule: to.Ptr("30 9 * * 1-5"), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01-preview/ManagedIdentity/TasksUpdate_WithKeyVaultCustomCredentials.json +func ExampleTasksClient_Update_tasksUpdateWithKeyVaultCustomCredentials() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Update(ctx, "myResourceGroup", "myRegistry", "myTask", armcontainerregistrytasks.TaskUpdateParameters{ + Properties: &armcontainerregistrytasks.TaskPropertiesUpdateParameters{ + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](3), + }, + Credentials: &armcontainerregistrytasks.Credentials{ + CustomRegistries: map[string]*armcontainerregistrytasks.CustomRegistryCredentials{ + "myregistry.azurecr.io": { + Identity: to.Ptr("[system]"), + Password: &armcontainerregistrytasks.SecretObject{ + Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeVaultsecret), + Value: to.Ptr("https://myacbvault.vault.azure.net/secrets/password"), + }, + UserName: &armcontainerregistrytasks.SecretObject{ + Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeVaultsecret), + Value: to.Ptr("https://myacbvault.vault.azure.net/secrets/username"), + }, + }, + }, + }, + Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + Step: &armcontainerregistrytasks.DockerBuildStepUpdateParameters{ + Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + DockerFilePath: to.Ptr("src/DockerFile"), + ImageNames: []*string{ + to.Ptr("azurerest:testtag1"), + }, + }, + Trigger: &armcontainerregistrytasks.TriggerUpdateParameters{ + SourceTriggers: []*armcontainerregistrytasks.SourceTriggerUpdateParameters{ + { + Name: to.Ptr("mySourceTrigger"), + SourceRepository: &armcontainerregistrytasks.SourceUpdateParameters{ + SourceControlAuthProperties: &armcontainerregistrytasks.AuthInfoUpdateParameters{ + Token: to.Ptr("xxxxx"), + TokenType: to.Ptr(armcontainerregistrytasks.TokenTypePAT), + }, + }, + SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + }, + }, + }, + }, + }, + Tags: map[string]*string{ + "testkey": to.Ptr("value"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientUpdateResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Name: to.Ptr("myTask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Identity: &armcontainerregistrytasks.IdentityProperties{ + // Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("fa153151-b9fd-46f4-9088-5e6600f2689v"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-abu4gm510ccd"), + // }, + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](3), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // Credentials: &armcontainerregistrytasks.Credentials{ + // CustomRegistries: map[string]*armcontainerregistrytasks.CustomRegistryCredentials{ + // }, + // }, + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // Step: &armcontainerregistrytasks.DockerBuildStep{ + // Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + // Arguments: []*armcontainerregistrytasks.Argument{ + // { + // Name: to.Ptr("mytestargument"), + // IsSecret: to.Ptr(false), + // Value: to.Ptr("mytestvalue"), + // }, + // }, + // ContextPath: to.Ptr("src"), + // DockerFilePath: to.Ptr("src/DockerFile"), + // ImageNames: []*string{ + // to.Ptr("azurerest:testtag1"), + // }, + // IsPushEnabled: to.Ptr(true), + // NoCache: to.Ptr(false), + // }, + // Trigger: &armcontainerregistrytasks.TriggerProperties{ + // BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + // Name: to.Ptr("myBaseImageTrigger"), + // BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // UpdateTriggerEndpoint: to.Ptr("https://user:pass@mycicd.webhook.com?token=foo"), + // UpdateTriggerPayloadType: to.Ptr(armcontainerregistrytasks.UpdateTriggerPayloadTypeToken), + // }, + // SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + // { + // Name: to.Ptr("mySourceTrigger"), + // SourceRepository: &armcontainerregistrytasks.SourceProperties{ + // Branch: to.Ptr("master"), + // RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + // SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + // }, + // SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + // to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + // { + // Name: to.Ptr("myTimerTrigger"), + // Schedule: to.Ptr("30 9 * * 1-5"), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/ManagedIdentity/TasksUpdate_WithLoginIdentity.json +func ExampleTasksClient_Update_tasksUpdateWithLoginIdentity() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Update(ctx, "myResourceGroup", "myRegistry", "myTask", armcontainerregistrytasks.TaskUpdateParameters{ + Properties: &armcontainerregistrytasks.TaskPropertiesUpdateParameters{ + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](3), + }, + Credentials: &armcontainerregistrytasks.Credentials{ + SourceRegistry: &armcontainerregistrytasks.SourceRegistryCredentials{ + Identity: to.Ptr("[system]"), + }, + }, + Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + Step: &armcontainerregistrytasks.DockerBuildStepUpdateParameters{ + Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + DockerFilePath: to.Ptr("src/DockerFile"), + ImageNames: []*string{ + to.Ptr("azurerest:testtag1"), + }, + }, + Trigger: &armcontainerregistrytasks.TriggerUpdateParameters{ + SourceTriggers: []*armcontainerregistrytasks.SourceTriggerUpdateParameters{ + { + Name: to.Ptr("mySourceTrigger"), + SourceRepository: &armcontainerregistrytasks.SourceUpdateParameters{ + SourceControlAuthProperties: &armcontainerregistrytasks.AuthInfoUpdateParameters{ + Token: to.Ptr("xxxxx"), + TokenType: to.Ptr(armcontainerregistrytasks.TokenTypePAT), + }, + }, + SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + }, + }, + }, + }, + }, + Tags: map[string]*string{ + "testkey": to.Ptr("value"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientUpdateResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Name: to.Ptr("myTask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Identity: &armcontainerregistrytasks.IdentityProperties{ + // Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("fa153151-b9fd-46f4-9088-5e6600f2689v"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-abu4gm510ccd"), + // }, + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](3), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // Credentials: &armcontainerregistrytasks.Credentials{ + // SourceRegistry: &armcontainerregistrytasks.SourceRegistryCredentials{ + // Identity: to.Ptr("[system]"), + // }, + // }, + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // Step: &armcontainerregistrytasks.DockerBuildStep{ + // Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + // Arguments: []*armcontainerregistrytasks.Argument{ + // { + // Name: to.Ptr("mytestargument"), + // IsSecret: to.Ptr(false), + // Value: to.Ptr("mytestvalue"), + // }, + // }, + // ContextPath: to.Ptr("src"), + // DockerFilePath: to.Ptr("src/DockerFile"), + // ImageNames: []*string{ + // to.Ptr("azurerest:testtag1"), + // }, + // IsPushEnabled: to.Ptr(true), + // NoCache: to.Ptr(false), + // }, + // Trigger: &armcontainerregistrytasks.TriggerProperties{ + // BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + // Name: to.Ptr("myBaseImageTrigger"), + // BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + // { + // Name: to.Ptr("mySourceTrigger"), + // SourceRepository: &armcontainerregistrytasks.SourceProperties{ + // Branch: to.Ptr("master"), + // RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + // SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + // }, + // SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + // to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + // { + // Name: to.Ptr("myTimerTrigger"), + // Schedule: to.Ptr("30 9 * * 1-5"), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/ManagedIdentity/TasksUpdate_WithMSICustomCredentials.json +func ExampleTasksClient_Update_tasksUpdateWithMsiCustomCredentials() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Update(ctx, "myResourceGroup", "myRegistry", "myTask", armcontainerregistrytasks.TaskUpdateParameters{ + Properties: &armcontainerregistrytasks.TaskPropertiesUpdateParameters{ + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](3), + }, + Credentials: &armcontainerregistrytasks.Credentials{ + CustomRegistries: map[string]*armcontainerregistrytasks.CustomRegistryCredentials{ + "myregistry.azurecr.io": { + Identity: to.Ptr("[system]"), + }, + }, + }, + Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + Step: &armcontainerregistrytasks.DockerBuildStepUpdateParameters{ + Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + DockerFilePath: to.Ptr("src/DockerFile"), + ImageNames: []*string{ + to.Ptr("azurerest:testtag1"), + }, + }, + Trigger: &armcontainerregistrytasks.TriggerUpdateParameters{ + SourceTriggers: []*armcontainerregistrytasks.SourceTriggerUpdateParameters{ + { + Name: to.Ptr("mySourceTrigger"), + SourceRepository: &armcontainerregistrytasks.SourceUpdateParameters{ + SourceControlAuthProperties: &armcontainerregistrytasks.AuthInfoUpdateParameters{ + Token: to.Ptr("xxxxx"), + TokenType: to.Ptr(armcontainerregistrytasks.TokenTypePAT), + }, + }, + SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + }, + }, + }, + }, + }, + Tags: map[string]*string{ + "testkey": to.Ptr("value"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientUpdateResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Name: to.Ptr("myTask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Identity: &armcontainerregistrytasks.IdentityProperties{ + // Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("fa153151-b9fd-46f4-9088-5e6600f2689v"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-abu4gm510ccd"), + // }, + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](3), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // Credentials: &armcontainerregistrytasks.Credentials{ + // CustomRegistries: map[string]*armcontainerregistrytasks.CustomRegistryCredentials{ + // }, + // }, + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // Step: &armcontainerregistrytasks.DockerBuildStep{ + // Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + // Arguments: []*armcontainerregistrytasks.Argument{ + // { + // Name: to.Ptr("mytestargument"), + // IsSecret: to.Ptr(false), + // Value: to.Ptr("mytestvalue"), + // }, + // }, + // ContextPath: to.Ptr("src"), + // DockerFilePath: to.Ptr("src/DockerFile"), + // ImageNames: []*string{ + // to.Ptr("azurerest:testtag1"), + // }, + // IsPushEnabled: to.Ptr(true), + // NoCache: to.Ptr(false), + // }, + // Trigger: &armcontainerregistrytasks.TriggerProperties{ + // BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + // Name: to.Ptr("myBaseImageTrigger"), + // BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + // { + // Name: to.Ptr("mySourceTrigger"), + // SourceRepository: &armcontainerregistrytasks.SourceProperties{ + // Branch: to.Ptr("master"), + // RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + // SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + // }, + // SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + // to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + // { + // Name: to.Ptr("myTimerTrigger"), + // Schedule: to.Ptr("30 9 * * 1-5"), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/TasksUpdate.json +func ExampleTasksClient_Update_tasksUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Update(ctx, "myResourceGroup", "myRegistry", "myTask", armcontainerregistrytasks.TaskUpdateParameters{ + Properties: &armcontainerregistrytasks.TaskPropertiesUpdateParameters{ + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](3), + }, + Credentials: &armcontainerregistrytasks.Credentials{ + CustomRegistries: map[string]*armcontainerregistrytasks.CustomRegistryCredentials{ + "myregistry.azurecr.io": { + Identity: to.Ptr("[system]"), + Password: &armcontainerregistrytasks.SecretObject{ + Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeVaultsecret), + Value: to.Ptr("https://myacbvault.vault.azure.net/secrets/password"), + }, + UserName: &armcontainerregistrytasks.SecretObject{ + Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeOpaque), + Value: to.Ptr("username"), + }, + }, + }, + }, + LogTemplate: to.Ptr("acr/tasks:{{.Run.OS}}"), + Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + Step: &armcontainerregistrytasks.DockerBuildStepUpdateParameters{ + Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + DockerFilePath: to.Ptr("src/DockerFile"), + ImageNames: []*string{ + to.Ptr("azurerest:testtag1"), + }, + }, + Trigger: &armcontainerregistrytasks.TriggerUpdateParameters{ + SourceTriggers: []*armcontainerregistrytasks.SourceTriggerUpdateParameters{ + { + Name: to.Ptr("mySourceTrigger"), + SourceRepository: &armcontainerregistrytasks.SourceUpdateParameters{ + SourceControlAuthProperties: &armcontainerregistrytasks.AuthInfoUpdateParameters{ + Token: to.Ptr("xxxxx"), + TokenType: to.Ptr(armcontainerregistrytasks.TokenTypePAT), + }, + }, + SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + }, + }, + }, + }, + }, + Tags: map[string]*string{ + "testkey": to.Ptr("value"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientUpdateResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Name: to.Ptr("myTask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Identity: &armcontainerregistrytasks.IdentityProperties{ + // Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("fa153151-b9fd-46f4-9088-5e6600f2689v"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-abu4gm510ccd"), + // }, + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](3), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // Credentials: &armcontainerregistrytasks.Credentials{ + // CustomRegistries: map[string]*armcontainerregistrytasks.CustomRegistryCredentials{ + // }, + // }, + // LogTemplate: to.Ptr("acr/tasks:{{.Run.OS}}"), + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // Step: &armcontainerregistrytasks.DockerBuildStep{ + // Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + // Arguments: []*armcontainerregistrytasks.Argument{ + // { + // Name: to.Ptr("mytestargument"), + // IsSecret: to.Ptr(false), + // Value: to.Ptr("mytestvalue"), + // }, + // }, + // ContextPath: to.Ptr("src"), + // DockerFilePath: to.Ptr("src/DockerFile"), + // ImageNames: []*string{ + // to.Ptr("azurerest:testtag1"), + // }, + // IsPushEnabled: to.Ptr(true), + // NoCache: to.Ptr(false), + // }, + // Trigger: &armcontainerregistrytasks.TriggerProperties{ + // BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + // Name: to.Ptr("myBaseImageTrigger"), + // BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // UpdateTriggerPayloadType: to.Ptr(armcontainerregistrytasks.UpdateTriggerPayloadTypeDefault), + // }, + // SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + // { + // Name: to.Ptr("mySourceTrigger"), + // SourceRepository: &armcontainerregistrytasks.SourceProperties{ + // Branch: to.Ptr("master"), + // RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + // SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + // }, + // SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + // to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + // { + // Name: to.Ptr("myTimerTrigger"), + // Schedule: to.Ptr("30 9 * * 1-5"), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/TasksUpdate_QuickTask.json +func ExampleTasksClient_Update_tasksUpdateQuickTask() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Update(ctx, "myResourceGroup", "myRegistry", "quicktask", armcontainerregistrytasks.TaskUpdateParameters{ + Properties: &armcontainerregistrytasks.TaskPropertiesUpdateParameters{ + LogTemplate: to.Ptr("acr/tasks:{{.Run.OS}}"), + Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + }, + Tags: map[string]*string{ + "testkey": to.Ptr("value"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientUpdateResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Name: to.Ptr("myTask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // LogTemplate: to.Ptr("acr/tasks:{{.Run.OS}}"), + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01-preview/TasksUpdate_WithOpaqueCustomCredentials.json +func ExampleTasksClient_Update_tasksUpdateWithOpaqueCustomCredentials() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcontainerregistrytasks.NewClientFactory("4385cf00-2d3a-425a-832f-f4285b1c9dce", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTasksClient().Update(ctx, "myResourceGroup", "myRegistry", "myTask", armcontainerregistrytasks.TaskUpdateParameters{ + Properties: &armcontainerregistrytasks.TaskPropertiesUpdateParameters{ + AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + CPU: to.Ptr[int32](3), + }, + Credentials: &armcontainerregistrytasks.Credentials{ + CustomRegistries: map[string]*armcontainerregistrytasks.CustomRegistryCredentials{ + "myregistry.azurecr.io": { + Password: &armcontainerregistrytasks.SecretObject{ + Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeOpaque), + Value: to.Ptr("***"), + }, + UserName: &armcontainerregistrytasks.SecretObject{ + Type: to.Ptr(armcontainerregistrytasks.SecretObjectTypeOpaque), + Value: to.Ptr("username"), + }, + }, + }, + }, + Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + Step: &armcontainerregistrytasks.DockerBuildStepUpdateParameters{ + Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + DockerFilePath: to.Ptr("src/DockerFile"), + ImageNames: []*string{ + to.Ptr("azurerest:testtag1"), + }, + }, + Trigger: &armcontainerregistrytasks.TriggerUpdateParameters{ + SourceTriggers: []*armcontainerregistrytasks.SourceTriggerUpdateParameters{ + { + Name: to.Ptr("mySourceTrigger"), + SourceRepository: &armcontainerregistrytasks.SourceUpdateParameters{ + SourceControlAuthProperties: &armcontainerregistrytasks.AuthInfoUpdateParameters{ + Token: to.Ptr("xxxxx"), + TokenType: to.Ptr(armcontainerregistrytasks.TokenTypePAT), + }, + }, + SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + }, + }, + }, + }, + }, + Tags: map[string]*string{ + "testkey": to.Ptr("value"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcontainerregistrytasks.TasksClientUpdateResponse{ + // Task: &armcontainerregistrytasks.Task{ + // Name: to.Ptr("myTask"), + // Type: to.Ptr("Microsoft.ContainerRegistry/registries/tasks"), + // ID: to.Ptr("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tasks/myTask"), + // Identity: &armcontainerregistrytasks.IdentityProperties{ + // Type: to.Ptr(armcontainerregistrytasks.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("fa153151-b9fd-46f4-9088-5e6600f2689v"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-abu4gm510ccd"), + // }, + // Location: to.Ptr("eastus"), + // Properties: &armcontainerregistrytasks.TaskProperties{ + // AgentConfiguration: &armcontainerregistrytasks.AgentProperties{ + // CPU: to.Ptr[int32](3), + // }, + // CreationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T06:54:23.536Z"); return t}()), + // Credentials: &armcontainerregistrytasks.Credentials{ + // CustomRegistries: map[string]*armcontainerregistrytasks.CustomRegistryCredentials{ + // }, + // }, + // Platform: &armcontainerregistrytasks.PlatformProperties{ + // Architecture: to.Ptr(armcontainerregistrytasks.ArchitectureAmd64), + // OS: to.Ptr(armcontainerregistrytasks.OSLinux), + // }, + // ProvisioningState: to.Ptr(armcontainerregistrytasks.ProvisioningStateSucceeded), + // Status: to.Ptr(armcontainerregistrytasks.TaskStatusEnabled), + // Step: &armcontainerregistrytasks.DockerBuildStep{ + // Type: to.Ptr(armcontainerregistrytasks.StepTypeDocker), + // Arguments: []*armcontainerregistrytasks.Argument{ + // { + // Name: to.Ptr("mytestargument"), + // IsSecret: to.Ptr(false), + // Value: to.Ptr("mytestvalue"), + // }, + // }, + // ContextPath: to.Ptr("src"), + // DockerFilePath: to.Ptr("src/DockerFile"), + // ImageNames: []*string{ + // to.Ptr("azurerest:testtag1"), + // }, + // IsPushEnabled: to.Ptr(true), + // NoCache: to.Ptr(false), + // }, + // Trigger: &armcontainerregistrytasks.TriggerProperties{ + // BaseImageTrigger: &armcontainerregistrytasks.BaseImageTrigger{ + // Name: to.Ptr("myBaseImageTrigger"), + // BaseImageTriggerType: to.Ptr(armcontainerregistrytasks.BaseImageTriggerTypeRuntime), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // SourceTriggers: []*armcontainerregistrytasks.SourceTrigger{ + // { + // Name: to.Ptr("mySourceTrigger"), + // SourceRepository: &armcontainerregistrytasks.SourceProperties{ + // Branch: to.Ptr("master"), + // RepositoryURL: to.Ptr("https://github.com/Azure/azure-rest-api-specs"), + // SourceControlType: to.Ptr(armcontainerregistrytasks.SourceControlTypeGithub), + // }, + // SourceTriggerEvents: []*armcontainerregistrytasks.SourceTriggerEvent{ + // to.Ptr(armcontainerregistrytasks.SourceTriggerEventCommit), + // }, + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // TimerTriggers: []*armcontainerregistrytasks.TimerTrigger{ + // { + // Name: to.Ptr("myTimerTrigger"), + // Schedule: to.Ptr("30 9 * * 1-5"), + // Status: to.Ptr(armcontainerregistrytasks.TriggerStatusEnabled), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "testkey": to.Ptr("value"), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/testdata/_metadata.json b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/testdata/_metadata.json new file mode 100644 index 000000000000..dfb40e3fe34f --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/testdata/_metadata.json @@ -0,0 +1,4 @@ +{ + "apiVersion": "2025-03-01-preview", + "emitterVersion": "0.9.1" +} diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/tsp-location.yaml b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/tsp-location.yaml new file mode 100644 index 000000000000..2ba13bf18d81 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/RegistryTasks +commit: 3f223d61b02c0496581dfb71c78104761b448d5e +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/version.go b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/version.go new file mode 100644 index 000000000000..479e30ed7fb2 --- /dev/null +++ b/sdk/resourcemanager/containerregistry/armcontainerregistrytasks/version.go @@ -0,0 +1,10 @@ +// 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) Go Code Generator. + +package armcontainerregistrytasks + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistrytasks" + moduleVersion = "v0.1.0" +)