From 732e1aceea19003cc42336d9df8fbb6292517dc6 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Wed, 24 Dec 2025 01:13:27 +0000 Subject: [PATCH] Configurations: 'specification/cdn/resource-manager/Microsoft.Cdn/EdgeActions/tspconfig.yaml', API Version: 2025-09-01-preview, SDK Release Type: beta, and CommitSHA: 'be46becafeb29aa993898709e35759d3643b2809' in SpecRepo: 'https://github.com/Azure/azure-rest-api-specs' Pipeline run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=5699257 Refer to https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites to prepare for SDK release. --- .../edgeactions/armedgeactions/CHANGELOG.md | 8 + .../edgeactions/armedgeactions/LICENSE.txt | 21 + .../edgeactions/armedgeactions/README.md | 90 +++ .../edgeactions/armedgeactions/ci.yml | 27 + .../edgeactions/armedgeactions/client.go | 611 ++++++++++++++++ .../armedgeactions/client_example_test.go | 340 +++++++++ .../armedgeactions/client_factory.go | 57 ++ .../edgeactions/armedgeactions/constants.go | 113 +++ .../edgeactionexecutionfilters_client.go | 427 +++++++++++ ...ionexecutionfilters_client_example_test.go | 215 ++++++ .../edgeactionversions_client.go | 673 ++++++++++++++++++ .../edgeactionversions_client_example_test.go | 301 ++++++++ .../fake/edgeactionexecutionfilters_server.go | 353 +++++++++ .../fake/edgeactionversions_server.go | 525 ++++++++++++++ .../armedgeactions/fake/internal.go | 65 ++ .../edgeactions/armedgeactions/fake/server.go | 486 +++++++++++++ .../armedgeactions/fake/server_factory.go | 90 +++ .../edgeactions/armedgeactions/go.mod | 21 + .../edgeactions/armedgeactions/go.sum | 39 + .../edgeactions/armedgeactions/models.go | 209 ++++++ .../armedgeactions/models_serde.go | 566 +++++++++++++++ .../edgeactions/armedgeactions/options.go | 136 ++++ .../edgeactions/armedgeactions/responses.go | 126 ++++ .../armedgeactions/testdata/_metadata.json | 4 + .../armedgeactions/time_rfc3339.go | 109 +++ .../armedgeactions/tsp-location.yaml | 4 + .../edgeactions/armedgeactions/version.go | 10 + 27 files changed, 5626 insertions(+) create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/CHANGELOG.md create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/LICENSE.txt create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/README.md create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/ci.yml create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/client.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/client_example_test.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/client_factory.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/constants.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/edgeactionexecutionfilters_client.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/edgeactionexecutionfilters_client_example_test.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/edgeactionversions_client.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/edgeactionversions_client_example_test.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/fake/edgeactionexecutionfilters_server.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/fake/edgeactionversions_server.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/fake/internal.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/fake/server.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/fake/server_factory.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/go.mod create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/go.sum create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/models.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/models_serde.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/options.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/responses.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/testdata/_metadata.json create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/time_rfc3339.go create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/tsp-location.yaml create mode 100644 sdk/resourcemanager/edgeactions/armedgeactions/version.go diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/CHANGELOG.md b/sdk/resourcemanager/edgeactions/armedgeactions/CHANGELOG.md new file mode 100644 index 000000000000..c9df5427c0da --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-12-24) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgeactions/armedgeactions` 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/edgeactions/armedgeactions/LICENSE.txt b/sdk/resourcemanager/edgeactions/armedgeactions/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/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/edgeactions/armedgeactions/README.md b/sdk/resourcemanager/edgeactions/armedgeactions/README.md new file mode 100644 index 000000000000..4fe472fb3819 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/README.md @@ -0,0 +1,90 @@ +# Azure Edgeactions Module for Go + +The `armedgeactions` module provides operations for working with Azure Edgeactions. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/edgeactions/armedgeactions) + +# 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 Edgeactions module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgeactions/armedgeactions +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Edgeactions. 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 Edgeactions 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 := armedgeactions.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 := armedgeactions.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.NewClient() +``` + +## 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 `Edgeactions` 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/edgeactions/armedgeactions/ci.yml b/sdk/resourcemanager/edgeactions/armedgeactions/ci.yml new file mode 100644 index 000000000000..00589189c3ee --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/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/edgeactions/armedgeactions/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/edgeactions/armedgeactions/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/edgeactions/armedgeactions' diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/client.go b/sdk/resourcemanager/edgeactions/armedgeactions/client.go new file mode 100644 index 000000000000..71432e759e28 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/client.go @@ -0,0 +1,611 @@ +// 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 armedgeactions + +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" +) + +// Client contains the methods for the service. +// Don't use this type directly, use NewClient() instead. +type Client struct { + internal *arm.Client + subscriptionID string +} + +// NewClient creates a new instance of Client 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 NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &Client{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginAddAttachment - A long-running resource action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - body - The content of the action request +// - options - ClientBeginAddAttachmentOptions contains the optional parameters for the Client.BeginAddAttachment method. +func (client *Client) BeginAddAttachment(ctx context.Context, resourceGroupName string, edgeActionName string, body EdgeActionAttachment, options *ClientBeginAddAttachmentOptions) (*runtime.Poller[ClientAddAttachmentResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.addAttachment(ctx, resourceGroupName, edgeActionName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientAddAttachmentResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientAddAttachmentResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// AddAttachment - A long-running resource action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *Client) addAttachment(ctx context.Context, resourceGroupName string, edgeActionName string, body EdgeActionAttachment, options *ClientBeginAddAttachmentOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginAddAttachment" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.addAttachmentCreateRequest(ctx, resourceGroupName, edgeActionName, body, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// addAttachmentCreateRequest creates the AddAttachment request. +func (client *Client) addAttachmentCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, body EdgeActionAttachment, _ *ClientBeginAddAttachmentOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/addAttachment" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + 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-09-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, body); err != nil { + return nil, err + } + return req, nil +} + +// BeginCreate - Create a EdgeAction +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - resource - Resource create parameters. +// - options - ClientBeginCreateOptions contains the optional parameters for the Client.BeginCreate method. +func (client *Client) BeginCreate(ctx context.Context, resourceGroupName string, edgeActionName string, resource EdgeAction, options *ClientBeginCreateOptions) (*runtime.Poller[ClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, edgeActionName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Create a EdgeAction +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *Client) create(ctx context.Context, resourceGroupName string, edgeActionName string, resource EdgeAction, options *ClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "Client.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, edgeActionName, resource, 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 *Client) createCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, resource EdgeAction, _ *ClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + 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-09-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, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a EdgeAction +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - options - ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. +func (client *Client) BeginDelete(ctx context.Context, resourceGroupName string, edgeActionName string, options *ClientBeginDeleteOptions) (*runtime.Poller[ClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, edgeActionName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a EdgeAction +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *Client) deleteOperation(ctx context.Context, resourceGroupName string, edgeActionName string, options *ClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "Client.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, edgeActionName, 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 *Client) deleteCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, _ *ClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + 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-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// BeginDeleteAttachment - A long-running resource action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - body - The content of the action request +// - options - ClientBeginDeleteAttachmentOptions contains the optional parameters for the Client.BeginDeleteAttachment method. +func (client *Client) BeginDeleteAttachment(ctx context.Context, resourceGroupName string, edgeActionName string, body EdgeActionAttachment, options *ClientBeginDeleteAttachmentOptions) (*runtime.Poller[ClientDeleteAttachmentResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteAttachment(ctx, resourceGroupName, edgeActionName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteAttachmentResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientDeleteAttachmentResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DeleteAttachment - A long-running resource action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *Client) deleteAttachment(ctx context.Context, resourceGroupName string, edgeActionName string, body EdgeActionAttachment, options *ClientBeginDeleteAttachmentOptions) (*http.Response, error) { + var err error + const operationName = "Client.BeginDeleteAttachment" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteAttachmentCreateRequest(ctx, resourceGroupName, edgeActionName, body, 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 +} + +// deleteAttachmentCreateRequest creates the DeleteAttachment request. +func (client *Client) deleteAttachmentCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, body EdgeActionAttachment, _ *ClientBeginDeleteAttachmentOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/deleteAttachment" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + 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-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// Get - Get a EdgeAction +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - options - ClientGetOptions contains the optional parameters for the Client.Get method. +func (client *Client) Get(ctx context.Context, resourceGroupName string, edgeActionName string, options *ClientGetOptions) (ClientGetResponse, error) { + var err error + const operationName = "Client.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, edgeActionName, options) + if err != nil { + return ClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *Client) getCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, _ *ClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + 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-09-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 *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, error) { + result := ClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EdgeAction); err != nil { + return ClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List EdgeAction resources by resource group +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager +// method. +func (client *Client) NewListByResourceGroupPager(resourceGroupName string, options *ClientListByResourceGroupOptions) *runtime.Pager[ClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListByResourceGroupResponse]{ + More: func(page ClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListByResourceGroupResponse) (ClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListByResourceGroupPager") + 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.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return ClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *Client) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *ClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := 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-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *Client) listByResourceGroupHandleResponse(resp *http.Response) (ClientListByResourceGroupResponse, error) { + result := ClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EdgeActionListResult); err != nil { + return ClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List EdgeAction resources by subscription ID +// +// Generated from API version 2025-09-01-preview +// - options - ClientListBySubscriptionOptions contains the optional parameters for the Client.NewListBySubscriptionPager method. +func (client *Client) NewListBySubscriptionPager(options *ClientListBySubscriptionOptions) *runtime.Pager[ClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListBySubscriptionResponse]{ + More: func(page ClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListBySubscriptionResponse) (ClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "Client.NewListBySubscriptionPager") + 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.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return ClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *Client) listBySubscriptionCreateRequest(ctx context.Context, _ *ClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/edgeActions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *Client) listBySubscriptionHandleResponse(resp *http.Response) (ClientListBySubscriptionResponse, error) { + result := ClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EdgeActionListResult); err != nil { + return ClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a EdgeAction +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - properties - The resource properties to be updated. +// - options - ClientBeginUpdateOptions contains the optional parameters for the Client.BeginUpdate method. +func (client *Client) BeginUpdate(ctx context.Context, resourceGroupName string, edgeActionName string, properties EdgeAction, options *ClientBeginUpdateOptions) (*runtime.Poller[ClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, edgeActionName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a EdgeAction +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *Client) update(ctx context.Context, resourceGroupName string, edgeActionName string, properties EdgeAction, options *ClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "Client.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, edgeActionName, properties, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *Client) updateCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, properties EdgeAction, _ *ClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + 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-09-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, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/client_example_test.go b/sdk/resourcemanager/edgeactions/armedgeactions/client_example_test.go new file mode 100644 index 000000000000..70ac8697f3cf --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/client_example_test.go @@ -0,0 +1,340 @@ +// 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 armedgeactions_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/edgeactions/armedgeactions" + "log" +) + +// Generated from example definition: 2025-09-01-preview/EdgeActions_AddAttachment.json +func ExampleClient_BeginAddAttachment() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewClient().BeginAddAttachment(ctx, "testrg", "edgeAction1", armedgeactions.EdgeActionAttachment{ + AttachedResourceID: to.Ptr("/subscriptions/sub1/resourceGroups/rs1/providers/Microsoft.Cdn/Profiles/myProfile/afdEndpoints/ep1/routes/route1"), + }, 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 = armedgeactions.ClientAddAttachmentResponse{ + // EdgeActionAttachmentResponse: &armedgeactions.EdgeActionAttachmentResponse{ + // EdgeActionID: to.Ptr("someguid"), + // }, + // } +} + +// Generated from example definition: 2025-09-01-preview/EdgeActions_Create.json +func ExampleClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewClient().BeginCreate(ctx, "testrg", "edgeAction1", armedgeactions.EdgeAction{ + Location: to.Ptr("global"), + SKU: &armedgeactions.SKUType{ + Name: to.Ptr("Standard"), + Tier: to.Ptr("Standard"), + }, + }, 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 = armedgeactions.ClientCreateResponse{ + // EdgeAction: &armedgeactions.EdgeAction{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1"), + // Name: to.Ptr("edgeAction1"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions"), + // Location: to.Ptr("global"), + // SKU: &armedgeactions.SKUType{ + // Name: to.Ptr("Standard"), + // Tier: to.Ptr("Standard"), + // }, + // Properties: &armedgeactions.EdgeActionProperties{ + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // Attachments: []*armedgeactions.EdgeActionAttachment{ + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-09-01-preview/EdgeActions_Delete.json +func ExampleClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewClient().BeginDelete(ctx, "testrg", "edgeAction1", 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-09-01-preview/EdgeActions_DeleteAttachment.json +func ExampleClient_BeginDeleteAttachment() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewClient().BeginDeleteAttachment(ctx, "testrg", "edgeAction1", armedgeactions.EdgeActionAttachment{ + AttachedResourceID: to.Ptr("/subscriptions/sub1/resourceGroups/rs1/providers/Microsoft.Cdn/Profiles/myProfile/afdEndpoints/ep1/routes/route1"), + }, 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-09-01-preview/EdgeActions_Get.json +func ExampleClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().Get(ctx, "testrg", "edgeAction1", 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 = armedgeactions.ClientGetResponse{ + // EdgeAction: &armedgeactions.EdgeAction{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1"), + // Name: to.Ptr("edgeAction1"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions"), + // Location: to.Ptr("global"), + // SKU: &armedgeactions.SKUType{ + // Name: to.Ptr("Standard"), + // Tier: to.Ptr("Standard"), + // }, + // Properties: &armedgeactions.EdgeActionProperties{ + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // Attachments: []*armedgeactions.EdgeActionAttachment{ + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-09-01-preview/EdgeActions_ListByResourceGroup.json +func ExampleClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewClient().NewListByResourceGroupPager("testrg", 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 = armedgeactions.ClientListByResourceGroupResponse{ + // EdgeActionListResult: armedgeactions.EdgeActionListResult{ + // Value: []*armedgeactions.EdgeAction{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1"), + // Name: to.Ptr("edgeAction1"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions"), + // Location: to.Ptr("global"), + // SKU: &armedgeactions.SKUType{ + // Name: to.Ptr("Standard"), + // Tier: to.Ptr("Standard"), + // }, + // Properties: &armedgeactions.EdgeActionProperties{ + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // Attachments: []*armedgeactions.EdgeActionAttachment{ + // }, + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction2"), + // Name: to.Ptr("edgeAction2"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions"), + // Location: to.Ptr("global"), + // SKU: &armedgeactions.SKUType{ + // Name: to.Ptr("Standard"), + // Tier: to.Ptr("Standard"), + // }, + // Properties: &armedgeactions.EdgeActionProperties{ + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // Attachments: []*armedgeactions.EdgeActionAttachment{ + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-09-01-preview/EdgeActions_ListBySubscription.json +func ExampleClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewClient().NewListBySubscriptionPager(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 = armedgeactions.ClientListBySubscriptionResponse{ + // EdgeActionListResult: armedgeactions.EdgeActionListResult{ + // Value: []*armedgeactions.EdgeAction{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1"), + // Name: to.Ptr("edgeAction1"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions"), + // Location: to.Ptr("global"), + // SKU: &armedgeactions.SKUType{ + // Name: to.Ptr("Standard"), + // Tier: to.Ptr("Standard"), + // }, + // Properties: &armedgeactions.EdgeActionProperties{ + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // Attachments: []*armedgeactions.EdgeActionAttachment{ + // }, + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction2"), + // Name: to.Ptr("edgeAction2"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions"), + // Location: to.Ptr("global"), + // SKU: &armedgeactions.SKUType{ + // Name: to.Ptr("Standard"), + // Tier: to.Ptr("Standard"), + // }, + // Properties: &armedgeactions.EdgeActionProperties{ + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // Attachments: []*armedgeactions.EdgeActionAttachment{ + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-09-01-preview/EdgeActions_Update.json +func ExampleClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewClient().BeginUpdate(ctx, "testrg", "edgeAction1", armedgeactions.EdgeAction{ + SKU: &armedgeactions.SKUType{ + Name: to.Ptr("Standard"), + Tier: to.Ptr("Standard"), + }, + }, 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 = armedgeactions.ClientUpdateResponse{ + // EdgeAction: &armedgeactions.EdgeAction{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1"), + // Name: to.Ptr("edgeAction1"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions"), + // Location: to.Ptr("global"), + // SKU: &armedgeactions.SKUType{ + // Name: to.Ptr("Standard"), + // Tier: to.Ptr("Standard"), + // }, + // Properties: &armedgeactions.EdgeActionProperties{ + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // Attachments: []*armedgeactions.EdgeActionAttachment{ + // }, + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/client_factory.go b/sdk/resourcemanager/edgeactions/armedgeactions/client_factory.go new file mode 100644 index 000000000000..8f8b787655db --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/client_factory.go @@ -0,0 +1,57 @@ +// 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 armedgeactions + +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 +} + +// NewClient creates a new instance of Client. +func (c *ClientFactory) NewClient() *Client { + return &Client{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewEdgeActionExecutionFiltersClient creates a new instance of EdgeActionExecutionFiltersClient. +func (c *ClientFactory) NewEdgeActionExecutionFiltersClient() *EdgeActionExecutionFiltersClient { + return &EdgeActionExecutionFiltersClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewEdgeActionVersionsClient creates a new instance of EdgeActionVersionsClient. +func (c *ClientFactory) NewEdgeActionVersionsClient() *EdgeActionVersionsClient { + return &EdgeActionVersionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/constants.go b/sdk/resourcemanager/edgeactions/armedgeactions/constants.go new file mode 100644 index 000000000000..91c4e5ead2e3 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/constants.go @@ -0,0 +1,113 @@ +// 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 armedgeactions + +// 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, + } +} + +// EdgeActionIsDefaultVersion - Indicates whether this is the default version +type EdgeActionIsDefaultVersion string + +const ( + // EdgeActionIsDefaultVersionFalse - This is not the default version + EdgeActionIsDefaultVersionFalse EdgeActionIsDefaultVersion = "False" + // EdgeActionIsDefaultVersionTrue - This is the default version + EdgeActionIsDefaultVersionTrue EdgeActionIsDefaultVersion = "True" +) + +// PossibleEdgeActionIsDefaultVersionValues returns the possible values for the EdgeActionIsDefaultVersion const type. +func PossibleEdgeActionIsDefaultVersionValues() []EdgeActionIsDefaultVersion { + return []EdgeActionIsDefaultVersion{ + EdgeActionIsDefaultVersionFalse, + EdgeActionIsDefaultVersionTrue, + } +} + +// EdgeActionVersionDeploymentType - The deployment type for edge action versions +type EdgeActionVersionDeploymentType string + +const ( + // EdgeActionVersionDeploymentTypeFile - Single file deployment + EdgeActionVersionDeploymentTypeFile EdgeActionVersionDeploymentType = "file" + // EdgeActionVersionDeploymentTypeOthers - Other deployment types + EdgeActionVersionDeploymentTypeOthers EdgeActionVersionDeploymentType = "others" + // EdgeActionVersionDeploymentTypeZip - ZIP file deployment + EdgeActionVersionDeploymentTypeZip EdgeActionVersionDeploymentType = "zip" +) + +// PossibleEdgeActionVersionDeploymentTypeValues returns the possible values for the EdgeActionVersionDeploymentType const type. +func PossibleEdgeActionVersionDeploymentTypeValues() []EdgeActionVersionDeploymentType { + return []EdgeActionVersionDeploymentType{ + EdgeActionVersionDeploymentTypeFile, + EdgeActionVersionDeploymentTypeOthers, + EdgeActionVersionDeploymentTypeZip, + } +} + +// EdgeActionVersionValidationStatus - The validation status for edge action versions +type EdgeActionVersionValidationStatus string + +const ( + // EdgeActionVersionValidationStatusFailed - Validation failed + EdgeActionVersionValidationStatusFailed EdgeActionVersionValidationStatus = "Failed" + // EdgeActionVersionValidationStatusSucceeded - Validation succeeded + EdgeActionVersionValidationStatusSucceeded EdgeActionVersionValidationStatus = "Succeeded" +) + +// PossibleEdgeActionVersionValidationStatusValues returns the possible values for the EdgeActionVersionValidationStatus const type. +func PossibleEdgeActionVersionValidationStatusValues() []EdgeActionVersionValidationStatus { + return []EdgeActionVersionValidationStatus{ + EdgeActionVersionValidationStatusFailed, + EdgeActionVersionValidationStatusSucceeded, + } +} + +// ProvisioningState - The status of the current operation +type ProvisioningState string + +const ( + // ProvisioningStateCanceled - Resource creation was canceled. + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateFailed - Resource creation failed. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - Initial provisioning in progress + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Resource has been created. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpgrading - Upgrade in progress + ProvisioningStateUpgrading ProvisioningState = "Upgrading" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCanceled, + ProvisioningStateFailed, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + ProvisioningStateUpgrading, + } +} diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/edgeactionexecutionfilters_client.go b/sdk/resourcemanager/edgeactions/armedgeactions/edgeactionexecutionfilters_client.go new file mode 100644 index 000000000000..545d4f7d0975 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/edgeactionexecutionfilters_client.go @@ -0,0 +1,427 @@ +// 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 armedgeactions + +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" +) + +// EdgeActionExecutionFiltersClient contains the methods for the EdgeActionExecutionFilters group. +// Don't use this type directly, use NewEdgeActionExecutionFiltersClient() instead. +type EdgeActionExecutionFiltersClient struct { + internal *arm.Client + subscriptionID string +} + +// NewEdgeActionExecutionFiltersClient creates a new instance of EdgeActionExecutionFiltersClient 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 NewEdgeActionExecutionFiltersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EdgeActionExecutionFiltersClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &EdgeActionExecutionFiltersClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Create a EdgeActionExecutionFilter +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - executionFilter - The name of the execution filter +// - resource - Resource create parameters. +// - options - EdgeActionExecutionFiltersClientBeginCreateOptions contains the optional parameters for the EdgeActionExecutionFiltersClient.BeginCreate +// method. +func (client *EdgeActionExecutionFiltersClient) BeginCreate(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, resource EdgeActionExecutionFilter, options *EdgeActionExecutionFiltersClientBeginCreateOptions) (*runtime.Poller[EdgeActionExecutionFiltersClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, edgeActionName, executionFilter, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EdgeActionExecutionFiltersClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EdgeActionExecutionFiltersClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Create a EdgeActionExecutionFilter +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *EdgeActionExecutionFiltersClient) create(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, resource EdgeActionExecutionFilter, options *EdgeActionExecutionFiltersClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "EdgeActionExecutionFiltersClient.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, edgeActionName, executionFilter, resource, 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 *EdgeActionExecutionFiltersClient) createCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, resource EdgeActionExecutionFilter, _ *EdgeActionExecutionFiltersClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/executionFilters/{executionFilter}" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + if executionFilter == "" { + return nil, errors.New("parameter executionFilter cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{executionFilter}", url.PathEscape(executionFilter)) + 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-09-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, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a EdgeActionExecutionFilter +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - executionFilter - The name of the execution filter +// - options - EdgeActionExecutionFiltersClientBeginDeleteOptions contains the optional parameters for the EdgeActionExecutionFiltersClient.BeginDelete +// method. +func (client *EdgeActionExecutionFiltersClient) BeginDelete(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, options *EdgeActionExecutionFiltersClientBeginDeleteOptions) (*runtime.Poller[EdgeActionExecutionFiltersClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, edgeActionName, executionFilter, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EdgeActionExecutionFiltersClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EdgeActionExecutionFiltersClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a EdgeActionExecutionFilter +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *EdgeActionExecutionFiltersClient) deleteOperation(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, options *EdgeActionExecutionFiltersClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "EdgeActionExecutionFiltersClient.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, edgeActionName, executionFilter, 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 *EdgeActionExecutionFiltersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, _ *EdgeActionExecutionFiltersClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/executionFilters/{executionFilter}" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + if executionFilter == "" { + return nil, errors.New("parameter executionFilter cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{executionFilter}", url.PathEscape(executionFilter)) + 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-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Get a EdgeActionExecutionFilter +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - executionFilter - The name of the execution filter +// - options - EdgeActionExecutionFiltersClientGetOptions contains the optional parameters for the EdgeActionExecutionFiltersClient.Get +// method. +func (client *EdgeActionExecutionFiltersClient) Get(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, options *EdgeActionExecutionFiltersClientGetOptions) (EdgeActionExecutionFiltersClientGetResponse, error) { + var err error + const operationName = "EdgeActionExecutionFiltersClient.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, edgeActionName, executionFilter, options) + if err != nil { + return EdgeActionExecutionFiltersClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EdgeActionExecutionFiltersClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EdgeActionExecutionFiltersClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *EdgeActionExecutionFiltersClient) getCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, _ *EdgeActionExecutionFiltersClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/executionFilters/{executionFilter}" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + if executionFilter == "" { + return nil, errors.New("parameter executionFilter cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{executionFilter}", url.PathEscape(executionFilter)) + 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-09-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 *EdgeActionExecutionFiltersClient) getHandleResponse(resp *http.Response) (EdgeActionExecutionFiltersClientGetResponse, error) { + result := EdgeActionExecutionFiltersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EdgeActionExecutionFilter); err != nil { + return EdgeActionExecutionFiltersClientGetResponse{}, err + } + return result, nil +} + +// NewListByEdgeActionPager - List EdgeActionExecutionFilter resources by EdgeAction +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - options - EdgeActionExecutionFiltersClientListByEdgeActionOptions contains the optional parameters for the EdgeActionExecutionFiltersClient.NewListByEdgeActionPager +// method. +func (client *EdgeActionExecutionFiltersClient) NewListByEdgeActionPager(resourceGroupName string, edgeActionName string, options *EdgeActionExecutionFiltersClientListByEdgeActionOptions) *runtime.Pager[EdgeActionExecutionFiltersClientListByEdgeActionResponse] { + return runtime.NewPager(runtime.PagingHandler[EdgeActionExecutionFiltersClientListByEdgeActionResponse]{ + More: func(page EdgeActionExecutionFiltersClientListByEdgeActionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EdgeActionExecutionFiltersClientListByEdgeActionResponse) (EdgeActionExecutionFiltersClientListByEdgeActionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EdgeActionExecutionFiltersClient.NewListByEdgeActionPager") + 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.listByEdgeActionCreateRequest(ctx, resourceGroupName, edgeActionName, options) + }, nil) + if err != nil { + return EdgeActionExecutionFiltersClientListByEdgeActionResponse{}, err + } + return client.listByEdgeActionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByEdgeActionCreateRequest creates the ListByEdgeAction request. +func (client *EdgeActionExecutionFiltersClient) listByEdgeActionCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, _ *EdgeActionExecutionFiltersClientListByEdgeActionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/executionFilters" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + 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-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByEdgeActionHandleResponse handles the ListByEdgeAction response. +func (client *EdgeActionExecutionFiltersClient) listByEdgeActionHandleResponse(resp *http.Response) (EdgeActionExecutionFiltersClientListByEdgeActionResponse, error) { + result := EdgeActionExecutionFiltersClientListByEdgeActionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EdgeActionExecutionFilterListResult); err != nil { + return EdgeActionExecutionFiltersClientListByEdgeActionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a EdgeActionExecutionFilter +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - executionFilter - The name of the execution filter +// - properties - The resource properties to be updated. +// - options - EdgeActionExecutionFiltersClientBeginUpdateOptions contains the optional parameters for the EdgeActionExecutionFiltersClient.BeginUpdate +// method. +func (client *EdgeActionExecutionFiltersClient) BeginUpdate(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, properties EdgeActionExecutionFilter, options *EdgeActionExecutionFiltersClientBeginUpdateOptions) (*runtime.Poller[EdgeActionExecutionFiltersClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, edgeActionName, executionFilter, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EdgeActionExecutionFiltersClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EdgeActionExecutionFiltersClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a EdgeActionExecutionFilter +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *EdgeActionExecutionFiltersClient) update(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, properties EdgeActionExecutionFilter, options *EdgeActionExecutionFiltersClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "EdgeActionExecutionFiltersClient.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, edgeActionName, executionFilter, properties, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *EdgeActionExecutionFiltersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, properties EdgeActionExecutionFilter, _ *EdgeActionExecutionFiltersClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/executionFilters/{executionFilter}" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + if executionFilter == "" { + return nil, errors.New("parameter executionFilter cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{executionFilter}", url.PathEscape(executionFilter)) + 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-09-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, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/edgeactionexecutionfilters_client_example_test.go b/sdk/resourcemanager/edgeactions/armedgeactions/edgeactionexecutionfilters_client_example_test.go new file mode 100644 index 000000000000..90f75d7b816d --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/edgeactionexecutionfilters_client_example_test.go @@ -0,0 +1,215 @@ +// 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 armedgeactions_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/edgeactions/armedgeactions" + "log" +) + +// Generated from example definition: 2025-09-01-preview/EdgeActionExecutionFilters_Create.json +func ExampleEdgeActionExecutionFiltersClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEdgeActionExecutionFiltersClient().BeginCreate(ctx, "testrg", "edgeAction1", "executionFilter1", armedgeactions.EdgeActionExecutionFilter{ + Location: to.Ptr("global"), + Properties: &armedgeactions.EdgeActionExecutionFilterProperties{ + VersionID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/testrg/providers/Microsoft.Cdn/EdgeActions/edgeAction1/versions/version1"), + ExecutionFilterIdentifierHeaderName: to.Ptr("header-key"), + ExecutionFilterIdentifierHeaderValue: to.Ptr("header-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 = armedgeactions.EdgeActionExecutionFiltersClientCreateResponse{ + // EdgeActionExecutionFilter: &armedgeactions.EdgeActionExecutionFilter{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1/executionFilters/executionFilters1"), + // Name: to.Ptr("executionFilter1"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions/executionFilters"), + // Location: to.Ptr("global"), + // Properties: &armedgeactions.EdgeActionExecutionFilterProperties{ + // VersionID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/testrg/providers/Microsoft.Cdn/EdgeActions/edgeAction1/versions/version1"), + // ExecutionFilterIdentifierHeaderName: to.Ptr("header-key"), + // ExecutionFilterIdentifierHeaderValue: to.Ptr("header-value"), + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // LastUpdateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-25T15:19:23Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-09-01-preview/EdgeActionExecutionFilters_Delete.json +func ExampleEdgeActionExecutionFiltersClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEdgeActionExecutionFiltersClient().BeginDelete(ctx, "testrg", "edgeAction1", "executionFilter1", 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-09-01-preview/EdgeActionExecutionFilters_Get.json +func ExampleEdgeActionExecutionFiltersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEdgeActionExecutionFiltersClient().Get(ctx, "testrg", "edgeAction1", "executionFilter1", 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 = armedgeactions.EdgeActionExecutionFiltersClientGetResponse{ + // EdgeActionExecutionFilter: &armedgeactions.EdgeActionExecutionFilter{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1/executionFilters/executionFilters1"), + // Name: to.Ptr("executionFilter1"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions/executionFilters"), + // Location: to.Ptr("global"), + // Properties: &armedgeactions.EdgeActionExecutionFilterProperties{ + // VersionID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/testrg/providers/Microsoft.Cdn/EdgeActions/edgeAction1/versions/version1"), + // ExecutionFilterIdentifierHeaderName: to.Ptr("header-key"), + // ExecutionFilterIdentifierHeaderValue: to.Ptr("header-value"), + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // LastUpdateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-25T15:19:23Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-09-01-preview/EdgeActionExecutionFilters_ListByEdgeAction.json +func ExampleEdgeActionExecutionFiltersClient_NewListByEdgeActionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEdgeActionExecutionFiltersClient().NewListByEdgeActionPager("testrg", "edgeAction1", 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 = armedgeactions.EdgeActionExecutionFiltersClientListByEdgeActionResponse{ + // EdgeActionExecutionFilterListResult: armedgeactions.EdgeActionExecutionFilterListResult{ + // Value: []*armedgeactions.EdgeActionExecutionFilter{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1/executionFilters/executionFilters1"), + // Name: to.Ptr("executionFilter1"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions/executionFilters"), + // Location: to.Ptr("global"), + // Properties: &armedgeactions.EdgeActionExecutionFilterProperties{ + // VersionID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/testrg/providers/Microsoft.Cdn/EdgeActions/edgeAction1/versions/version1"), + // ExecutionFilterIdentifierHeaderName: to.Ptr("header-key"), + // ExecutionFilterIdentifierHeaderValue: to.Ptr("header-value"), + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // LastUpdateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-25T15:19:23Z"); return t}()), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1/executionFilters/executionFilters2"), + // Name: to.Ptr("executionFilter2"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions/executionFilters"), + // Location: to.Ptr("global"), + // Properties: &armedgeactions.EdgeActionExecutionFilterProperties{ + // VersionID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/testrg/providers/Microsoft.Cdn/EdgeActions/edgeAction1/versions/version2"), + // ExecutionFilterIdentifierHeaderName: to.Ptr("header-key2"), + // ExecutionFilterIdentifierHeaderValue: to.Ptr("header-value2"), + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // LastUpdateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-25T15:19:23Z"); return t}()), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-09-01-preview/EdgeActionExecutionFilters_Update.json +func ExampleEdgeActionExecutionFiltersClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEdgeActionExecutionFiltersClient().BeginUpdate(ctx, "testrg", "edgeAction1", "executionFilter1", armedgeactions.EdgeActionExecutionFilter{ + Properties: &armedgeactions.EdgeActionExecutionFilterProperties{ + ExecutionFilterIdentifierHeaderValue: to.Ptr("header-value2"), + }, + }, 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 = armedgeactions.EdgeActionExecutionFiltersClientUpdateResponse{ + // EdgeActionExecutionFilter: &armedgeactions.EdgeActionExecutionFilter{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1/slots/slot1"), + // Name: to.Ptr("executionFilter1"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions/executionFilters"), + // Location: to.Ptr("global"), + // Properties: &armedgeactions.EdgeActionExecutionFilterProperties{ + // VersionID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/testrg/providers/Microsoft.Cdn/EdgeActions/edgeAction1/versions/version1"), + // ExecutionFilterIdentifierHeaderName: to.Ptr("header-key"), + // ExecutionFilterIdentifierHeaderValue: to.Ptr("header-value2"), + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // LastUpdateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-25T15:19:23Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/edgeactionversions_client.go b/sdk/resourcemanager/edgeactions/armedgeactions/edgeactionversions_client.go new file mode 100644 index 000000000000..49b8d187b8c8 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/edgeactionversions_client.go @@ -0,0 +1,673 @@ +// 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 armedgeactions + +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" +) + +// EdgeActionVersionsClient contains the methods for the EdgeActionVersions group. +// Don't use this type directly, use NewEdgeActionVersionsClient() instead. +type EdgeActionVersionsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewEdgeActionVersionsClient creates a new instance of EdgeActionVersionsClient 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 NewEdgeActionVersionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EdgeActionVersionsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &EdgeActionVersionsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Create a EdgeActionVersion +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - version - The name of the Edge Action version +// - resource - Resource create parameters. +// - options - EdgeActionVersionsClientBeginCreateOptions contains the optional parameters for the EdgeActionVersionsClient.BeginCreate +// method. +func (client *EdgeActionVersionsClient) BeginCreate(ctx context.Context, resourceGroupName string, edgeActionName string, version string, resource EdgeActionVersion, options *EdgeActionVersionsClientBeginCreateOptions) (*runtime.Poller[EdgeActionVersionsClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, edgeActionName, version, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EdgeActionVersionsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EdgeActionVersionsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Create a EdgeActionVersion +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *EdgeActionVersionsClient) create(ctx context.Context, resourceGroupName string, edgeActionName string, version string, resource EdgeActionVersion, options *EdgeActionVersionsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "EdgeActionVersionsClient.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, edgeActionName, version, resource, 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 *EdgeActionVersionsClient) createCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, version string, resource EdgeActionVersion, _ *EdgeActionVersionsClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/versions/{version}" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + if version == "" { + return nil, errors.New("parameter version cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{version}", url.PathEscape(version)) + 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-09-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, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a EdgeActionVersion +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - version - The name of the Edge Action version +// - options - EdgeActionVersionsClientBeginDeleteOptions contains the optional parameters for the EdgeActionVersionsClient.BeginDelete +// method. +func (client *EdgeActionVersionsClient) BeginDelete(ctx context.Context, resourceGroupName string, edgeActionName string, version string, options *EdgeActionVersionsClientBeginDeleteOptions) (*runtime.Poller[EdgeActionVersionsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, edgeActionName, version, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EdgeActionVersionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EdgeActionVersionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a EdgeActionVersion +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *EdgeActionVersionsClient) deleteOperation(ctx context.Context, resourceGroupName string, edgeActionName string, version string, options *EdgeActionVersionsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "EdgeActionVersionsClient.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, edgeActionName, version, 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 *EdgeActionVersionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, version string, _ *EdgeActionVersionsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/versions/{version}" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + if version == "" { + return nil, errors.New("parameter version cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{version}", url.PathEscape(version)) + 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-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// BeginDeployVersionCode - A long-running resource action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - version - The name of the Edge Action version +// - body - The content of the action request +// - options - EdgeActionVersionsClientBeginDeployVersionCodeOptions contains the optional parameters for the EdgeActionVersionsClient.BeginDeployVersionCode +// method. +func (client *EdgeActionVersionsClient) BeginDeployVersionCode(ctx context.Context, resourceGroupName string, edgeActionName string, version string, body VersionCode, options *EdgeActionVersionsClientBeginDeployVersionCodeOptions) (*runtime.Poller[EdgeActionVersionsClientDeployVersionCodeResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deployVersionCode(ctx, resourceGroupName, edgeActionName, version, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EdgeActionVersionsClientDeployVersionCodeResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EdgeActionVersionsClientDeployVersionCodeResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DeployVersionCode - A long-running resource action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *EdgeActionVersionsClient) deployVersionCode(ctx context.Context, resourceGroupName string, edgeActionName string, version string, body VersionCode, options *EdgeActionVersionsClientBeginDeployVersionCodeOptions) (*http.Response, error) { + var err error + const operationName = "EdgeActionVersionsClient.BeginDeployVersionCode" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deployVersionCodeCreateRequest(ctx, resourceGroupName, edgeActionName, version, body, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deployVersionCodeCreateRequest creates the DeployVersionCode request. +func (client *EdgeActionVersionsClient) deployVersionCodeCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, version string, body VersionCode, _ *EdgeActionVersionsClientBeginDeployVersionCodeOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/versions/{version}/deployVersionCode" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + if version == "" { + return nil, errors.New("parameter version cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{version}", url.PathEscape(version)) + 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-09-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, body); err != nil { + return nil, err + } + return req, nil +} + +// Get - Get a EdgeActionVersion +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - version - The name of the Edge Action version +// - options - EdgeActionVersionsClientGetOptions contains the optional parameters for the EdgeActionVersionsClient.Get method. +func (client *EdgeActionVersionsClient) Get(ctx context.Context, resourceGroupName string, edgeActionName string, version string, options *EdgeActionVersionsClientGetOptions) (EdgeActionVersionsClientGetResponse, error) { + var err error + const operationName = "EdgeActionVersionsClient.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, edgeActionName, version, options) + if err != nil { + return EdgeActionVersionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EdgeActionVersionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EdgeActionVersionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *EdgeActionVersionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, version string, _ *EdgeActionVersionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/versions/{version}" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + if version == "" { + return nil, errors.New("parameter version cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{version}", url.PathEscape(version)) + 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-09-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 *EdgeActionVersionsClient) getHandleResponse(resp *http.Response) (EdgeActionVersionsClientGetResponse, error) { + result := EdgeActionVersionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EdgeActionVersion); err != nil { + return EdgeActionVersionsClientGetResponse{}, err + } + return result, nil +} + +// BeginGetVersionCode - A long-running resource action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - version - The name of the Edge Action version +// - options - EdgeActionVersionsClientBeginGetVersionCodeOptions contains the optional parameters for the EdgeActionVersionsClient.BeginGetVersionCode +// method. +func (client *EdgeActionVersionsClient) BeginGetVersionCode(ctx context.Context, resourceGroupName string, edgeActionName string, version string, options *EdgeActionVersionsClientBeginGetVersionCodeOptions) (*runtime.Poller[EdgeActionVersionsClientGetVersionCodeResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.getVersionCode(ctx, resourceGroupName, edgeActionName, version, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EdgeActionVersionsClientGetVersionCodeResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EdgeActionVersionsClientGetVersionCodeResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// GetVersionCode - A long-running resource action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *EdgeActionVersionsClient) getVersionCode(ctx context.Context, resourceGroupName string, edgeActionName string, version string, options *EdgeActionVersionsClientBeginGetVersionCodeOptions) (*http.Response, error) { + var err error + const operationName = "EdgeActionVersionsClient.BeginGetVersionCode" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getVersionCodeCreateRequest(ctx, resourceGroupName, edgeActionName, version, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// getVersionCodeCreateRequest creates the GetVersionCode request. +func (client *EdgeActionVersionsClient) getVersionCodeCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, version string, _ *EdgeActionVersionsClientBeginGetVersionCodeOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/versions/{version}/getVersionCode" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + if version == "" { + return nil, errors.New("parameter version cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{version}", url.PathEscape(version)) + 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-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// NewListByEdgeActionPager - List EdgeActionVersion resources by EdgeAction +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - options - EdgeActionVersionsClientListByEdgeActionOptions contains the optional parameters for the EdgeActionVersionsClient.NewListByEdgeActionPager +// method. +func (client *EdgeActionVersionsClient) NewListByEdgeActionPager(resourceGroupName string, edgeActionName string, options *EdgeActionVersionsClientListByEdgeActionOptions) *runtime.Pager[EdgeActionVersionsClientListByEdgeActionResponse] { + return runtime.NewPager(runtime.PagingHandler[EdgeActionVersionsClientListByEdgeActionResponse]{ + More: func(page EdgeActionVersionsClientListByEdgeActionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EdgeActionVersionsClientListByEdgeActionResponse) (EdgeActionVersionsClientListByEdgeActionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EdgeActionVersionsClient.NewListByEdgeActionPager") + 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.listByEdgeActionCreateRequest(ctx, resourceGroupName, edgeActionName, options) + }, nil) + if err != nil { + return EdgeActionVersionsClientListByEdgeActionResponse{}, err + } + return client.listByEdgeActionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByEdgeActionCreateRequest creates the ListByEdgeAction request. +func (client *EdgeActionVersionsClient) listByEdgeActionCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, _ *EdgeActionVersionsClientListByEdgeActionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/versions" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + 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-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByEdgeActionHandleResponse handles the ListByEdgeAction response. +func (client *EdgeActionVersionsClient) listByEdgeActionHandleResponse(resp *http.Response) (EdgeActionVersionsClientListByEdgeActionResponse, error) { + result := EdgeActionVersionsClientListByEdgeActionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EdgeActionVersionListResult); err != nil { + return EdgeActionVersionsClientListByEdgeActionResponse{}, err + } + return result, nil +} + +// BeginSwapDefault - A long-running resource action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - version - The name of the Edge Action version +// - options - EdgeActionVersionsClientBeginSwapDefaultOptions contains the optional parameters for the EdgeActionVersionsClient.BeginSwapDefault +// method. +func (client *EdgeActionVersionsClient) BeginSwapDefault(ctx context.Context, resourceGroupName string, edgeActionName string, version string, options *EdgeActionVersionsClientBeginSwapDefaultOptions) (*runtime.Poller[EdgeActionVersionsClientSwapDefaultResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.swapDefault(ctx, resourceGroupName, edgeActionName, version, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EdgeActionVersionsClientSwapDefaultResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EdgeActionVersionsClientSwapDefaultResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// SwapDefault - A long-running resource action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *EdgeActionVersionsClient) swapDefault(ctx context.Context, resourceGroupName string, edgeActionName string, version string, options *EdgeActionVersionsClientBeginSwapDefaultOptions) (*http.Response, error) { + var err error + const operationName = "EdgeActionVersionsClient.BeginSwapDefault" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.swapDefaultCreateRequest(ctx, resourceGroupName, edgeActionName, version, 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 +} + +// swapDefaultCreateRequest creates the SwapDefault request. +func (client *EdgeActionVersionsClient) swapDefaultCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, version string, _ *EdgeActionVersionsClientBeginSwapDefaultOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/versions/{version}/swapDefault" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + if version == "" { + return nil, errors.New("parameter version cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{version}", url.PathEscape(version)) + 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-09-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// BeginUpdate - Update a EdgeActionVersion +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - edgeActionName - The name of the Edge Action +// - version - The name of the Edge Action version +// - properties - The resource properties to be updated. +// - options - EdgeActionVersionsClientBeginUpdateOptions contains the optional parameters for the EdgeActionVersionsClient.BeginUpdate +// method. +func (client *EdgeActionVersionsClient) BeginUpdate(ctx context.Context, resourceGroupName string, edgeActionName string, version string, properties EdgeActionVersion, options *EdgeActionVersionsClientBeginUpdateOptions) (*runtime.Poller[EdgeActionVersionsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, edgeActionName, version, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EdgeActionVersionsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EdgeActionVersionsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a EdgeActionVersion +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-09-01-preview +func (client *EdgeActionVersionsClient) update(ctx context.Context, resourceGroupName string, edgeActionName string, version string, properties EdgeActionVersion, options *EdgeActionVersionsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "EdgeActionVersionsClient.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, edgeActionName, version, properties, 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.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *EdgeActionVersionsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, edgeActionName string, version string, properties EdgeActionVersion, _ *EdgeActionVersionsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/edgeActions/{edgeActionName}/versions/{version}" + 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 edgeActionName == "" { + return nil, errors.New("parameter edgeActionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{edgeActionName}", url.PathEscape(edgeActionName)) + if version == "" { + return nil, errors.New("parameter version cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{version}", url.PathEscape(version)) + 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-09-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, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/edgeactionversions_client_example_test.go b/sdk/resourcemanager/edgeactions/armedgeactions/edgeactionversions_client_example_test.go new file mode 100644 index 000000000000..e6a232d7427c --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/edgeactionversions_client_example_test.go @@ -0,0 +1,301 @@ +// 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 armedgeactions_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/edgeactions/armedgeactions" + "log" +) + +// Generated from example definition: 2025-09-01-preview/EdgeActionVersions_Create.json +func ExampleEdgeActionVersionsClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEdgeActionVersionsClient().BeginCreate(ctx, "testrg", "edgeAction1", "version2", armedgeactions.EdgeActionVersion{ + Location: to.Ptr("global"), + Properties: &armedgeactions.EdgeActionVersionProperties{ + DeploymentType: to.Ptr(armedgeactions.EdgeActionVersionDeploymentTypeZip), + IsDefaultVersion: to.Ptr(armedgeactions.EdgeActionIsDefaultVersionTrue), + }, + }, 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 = armedgeactions.EdgeActionVersionsClientCreateResponse{ + // EdgeActionVersion: &armedgeactions.EdgeActionVersion{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1/versions/version2"), + // Name: to.Ptr("version2"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions/versions"), + // Location: to.Ptr("global"), + // Properties: &armedgeactions.EdgeActionVersionProperties{ + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // DeploymentType: to.Ptr(armedgeactions.EdgeActionVersionDeploymentTypeZip), + // ValidationStatus: to.Ptr(armedgeactions.EdgeActionVersionValidationStatusSucceeded), + // IsDefaultVersion: to.Ptr(armedgeactions.EdgeActionIsDefaultVersionTrue), + // LastPackageUpdateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-05-25T16:19:23Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-09-01-preview/EdgeActionVersions_Delete.json +func ExampleEdgeActionVersionsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEdgeActionVersionsClient().BeginDelete(ctx, "testrg", "edgeAction1", "version1", 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-09-01-preview/EdgeActionVersions_DeployVersionCode.json +func ExampleEdgeActionVersionsClient_BeginDeployVersionCode() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEdgeActionVersionsClient().BeginDeployVersionCode(ctx, "testrg", "edgeAction1", "version2", armedgeactions.VersionCode{ + Name: to.Ptr("zippedFile"), + Content: to.Ptr("UEsDBBQAAAAIAI1NzkQAAAAABQAAAA=="), + }, 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 = armedgeactions.EdgeActionVersionsClientDeployVersionCodeResponse{ + // EdgeActionVersionProperties: &armedgeactions.EdgeActionVersionProperties{ + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // DeploymentType: to.Ptr(armedgeactions.EdgeActionVersionDeploymentTypeZip), + // ValidationStatus: to.Ptr(armedgeactions.EdgeActionVersionValidationStatusSucceeded), + // IsDefaultVersion: to.Ptr(armedgeactions.EdgeActionIsDefaultVersionTrue), + // LastPackageUpdateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-05-25T16:19:23Z"); return t}()), + // }, + // } +} + +// Generated from example definition: 2025-09-01-preview/EdgeActionVersions_Get.json +func ExampleEdgeActionVersionsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEdgeActionVersionsClient().Get(ctx, "testrg", "edgeAction1", "version1", 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 = armedgeactions.EdgeActionVersionsClientGetResponse{ + // EdgeActionVersion: &armedgeactions.EdgeActionVersion{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1/versions/version1"), + // Name: to.Ptr("version1"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions/versions"), + // Location: to.Ptr("global"), + // Properties: &armedgeactions.EdgeActionVersionProperties{ + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // DeploymentType: to.Ptr(armedgeactions.EdgeActionVersionDeploymentTypeZip), + // ValidationStatus: to.Ptr(armedgeactions.EdgeActionVersionValidationStatusSucceeded), + // IsDefaultVersion: to.Ptr(armedgeactions.EdgeActionIsDefaultVersionTrue), + // LastPackageUpdateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-05-25T16:19:23Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-09-01-preview/EdgeActionVersions_GetVersionCode.json +func ExampleEdgeActionVersionsClient_BeginGetVersionCode() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEdgeActionVersionsClient().BeginGetVersionCode(ctx, "testrg", "edgeAction1", "version1", 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 = armedgeactions.EdgeActionVersionsClientGetVersionCodeResponse{ + // VersionCode: &armedgeactions.VersionCode{ + // Name: to.Ptr("zipfile"), + // Content: to.Ptr("encodedzip"), + // }, + // } +} + +// Generated from example definition: 2025-09-01-preview/EdgeActionVersions_ListByEdgeAction.json +func ExampleEdgeActionVersionsClient_NewListByEdgeActionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEdgeActionVersionsClient().NewListByEdgeActionPager("testrg", "edgeAction1", 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 = armedgeactions.EdgeActionVersionsClientListByEdgeActionResponse{ + // EdgeActionVersionListResult: armedgeactions.EdgeActionVersionListResult{ + // Value: []*armedgeactions.EdgeActionVersion{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1/versions/version1"), + // Name: to.Ptr("version1"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions/versions"), + // Location: to.Ptr("global"), + // Properties: &armedgeactions.EdgeActionVersionProperties{ + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // DeploymentType: to.Ptr(armedgeactions.EdgeActionVersionDeploymentTypeZip), + // ValidationStatus: to.Ptr(armedgeactions.EdgeActionVersionValidationStatusSucceeded), + // IsDefaultVersion: to.Ptr(armedgeactions.EdgeActionIsDefaultVersionTrue), + // LastPackageUpdateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-05-25T16:19:23Z"); return t}()), + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1/versions/version2"), + // Name: to.Ptr("version2"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions/versions"), + // Location: to.Ptr("global"), + // Properties: &armedgeactions.EdgeActionVersionProperties{ + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // DeploymentType: to.Ptr(armedgeactions.EdgeActionVersionDeploymentTypeZip), + // ValidationStatus: to.Ptr(armedgeactions.EdgeActionVersionValidationStatusSucceeded), + // IsDefaultVersion: to.Ptr(armedgeactions.EdgeActionIsDefaultVersionFalse), + // LastPackageUpdateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-05-25T11:19:23Z"); return t}()), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-09-01-preview/EdgeActionVersions_SwapDefault.json +func ExampleEdgeActionVersionsClient_BeginSwapDefault() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEdgeActionVersionsClient().BeginSwapDefault(ctx, "testrg", "edgeAction1", "1.0", 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-09-01-preview/EdgeActionVersions_Update.json +func ExampleEdgeActionVersionsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeactions.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEdgeActionVersionsClient().BeginUpdate(ctx, "testrg", "edgeAction1", "version1", armedgeactions.EdgeActionVersion{ + Properties: &armedgeactions.EdgeActionVersionProperties{ + DeploymentType: to.Ptr(armedgeactions.EdgeActionVersionDeploymentTypeOthers), + }, + }, 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 = armedgeactions.EdgeActionVersionsClientUpdateResponse{ + // EdgeActionVersion: &armedgeactions.EdgeActionVersion{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Cdn/edgeActions/edgeAction1/versions/version1"), + // Name: to.Ptr("version1"), + // Type: to.Ptr("Microsoft.Cdn/edgeActions/versions"), + // Location: to.Ptr("global"), + // Properties: &armedgeactions.EdgeActionVersionProperties{ + // ProvisioningState: to.Ptr(armedgeactions.ProvisioningStateSucceeded), + // DeploymentType: to.Ptr(armedgeactions.EdgeActionVersionDeploymentTypeOthers), + // ValidationStatus: to.Ptr(armedgeactions.EdgeActionVersionValidationStatusSucceeded), + // IsDefaultVersion: to.Ptr(armedgeactions.EdgeActionIsDefaultVersionTrue), + // LastPackageUpdateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-05-25T16:19:23Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/fake/edgeactionexecutionfilters_server.go b/sdk/resourcemanager/edgeactions/armedgeactions/fake/edgeactionexecutionfilters_server.go new file mode 100644 index 000000000000..9450bdac93a4 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/fake/edgeactionexecutionfilters_server.go @@ -0,0 +1,353 @@ +// 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/edgeactions/armedgeactions" + "net/http" + "net/url" + "regexp" +) + +// EdgeActionExecutionFiltersServer is a fake server for instances of the armedgeactions.EdgeActionExecutionFiltersClient type. +type EdgeActionExecutionFiltersServer struct { + // BeginCreate is the fake for method EdgeActionExecutionFiltersClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, resource armedgeactions.EdgeActionExecutionFilter, options *armedgeactions.EdgeActionExecutionFiltersClientBeginCreateOptions) (resp azfake.PollerResponder[armedgeactions.EdgeActionExecutionFiltersClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method EdgeActionExecutionFiltersClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, options *armedgeactions.EdgeActionExecutionFiltersClientBeginDeleteOptions) (resp azfake.PollerResponder[armedgeactions.EdgeActionExecutionFiltersClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method EdgeActionExecutionFiltersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, options *armedgeactions.EdgeActionExecutionFiltersClientGetOptions) (resp azfake.Responder[armedgeactions.EdgeActionExecutionFiltersClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByEdgeActionPager is the fake for method EdgeActionExecutionFiltersClient.NewListByEdgeActionPager + // HTTP status codes to indicate success: http.StatusOK + NewListByEdgeActionPager func(resourceGroupName string, edgeActionName string, options *armedgeactions.EdgeActionExecutionFiltersClientListByEdgeActionOptions) (resp azfake.PagerResponder[armedgeactions.EdgeActionExecutionFiltersClientListByEdgeActionResponse]) + + // BeginUpdate is the fake for method EdgeActionExecutionFiltersClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, edgeActionName string, executionFilter string, properties armedgeactions.EdgeActionExecutionFilter, options *armedgeactions.EdgeActionExecutionFiltersClientBeginUpdateOptions) (resp azfake.PollerResponder[armedgeactions.EdgeActionExecutionFiltersClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewEdgeActionExecutionFiltersServerTransport creates a new instance of EdgeActionExecutionFiltersServerTransport with the provided implementation. +// The returned EdgeActionExecutionFiltersServerTransport instance is connected to an instance of armedgeactions.EdgeActionExecutionFiltersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewEdgeActionExecutionFiltersServerTransport(srv *EdgeActionExecutionFiltersServer) *EdgeActionExecutionFiltersServerTransport { + return &EdgeActionExecutionFiltersServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armedgeactions.EdgeActionExecutionFiltersClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armedgeactions.EdgeActionExecutionFiltersClientDeleteResponse]](), + newListByEdgeActionPager: newTracker[azfake.PagerResponder[armedgeactions.EdgeActionExecutionFiltersClientListByEdgeActionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armedgeactions.EdgeActionExecutionFiltersClientUpdateResponse]](), + } +} + +// EdgeActionExecutionFiltersServerTransport connects instances of armedgeactions.EdgeActionExecutionFiltersClient to instances of EdgeActionExecutionFiltersServer. +// Don't use this type directly, use NewEdgeActionExecutionFiltersServerTransport instead. +type EdgeActionExecutionFiltersServerTransport struct { + srv *EdgeActionExecutionFiltersServer + beginCreate *tracker[azfake.PollerResponder[armedgeactions.EdgeActionExecutionFiltersClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armedgeactions.EdgeActionExecutionFiltersClientDeleteResponse]] + newListByEdgeActionPager *tracker[azfake.PagerResponder[armedgeactions.EdgeActionExecutionFiltersClientListByEdgeActionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armedgeactions.EdgeActionExecutionFiltersClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for EdgeActionExecutionFiltersServerTransport. +func (e *EdgeActionExecutionFiltersServerTransport) 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 e.dispatchToMethodFake(req, method) +} + +func (e *EdgeActionExecutionFiltersServerTransport) 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 edgeActionExecutionFiltersServerTransportInterceptor != nil { + res.resp, res.err, intercepted = edgeActionExecutionFiltersServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "EdgeActionExecutionFiltersClient.BeginCreate": + res.resp, res.err = e.dispatchBeginCreate(req) + case "EdgeActionExecutionFiltersClient.BeginDelete": + res.resp, res.err = e.dispatchBeginDelete(req) + case "EdgeActionExecutionFiltersClient.Get": + res.resp, res.err = e.dispatchGet(req) + case "EdgeActionExecutionFiltersClient.NewListByEdgeActionPager": + res.resp, res.err = e.dispatchNewListByEdgeActionPager(req) + case "EdgeActionExecutionFiltersClient.BeginUpdate": + res.resp, res.err = e.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 (e *EdgeActionExecutionFiltersServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if e.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := e.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/executionFilters/(?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[armedgeactions.EdgeActionExecutionFilter](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + executionFilterParam, err := url.PathUnescape(matches[regex.SubexpIndex("executionFilter")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginCreate(req.Context(), resourceGroupNameParam, edgeActionNameParam, executionFilterParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + e.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) { + e.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) { + e.beginCreate.remove(req) + } + + return resp, nil +} + +func (e *EdgeActionExecutionFiltersServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if e.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := e.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/executionFilters/(?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 + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + executionFilterParam, err := url.PathUnescape(matches[regex.SubexpIndex("executionFilter")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginDelete(req.Context(), resourceGroupNameParam, edgeActionNameParam, executionFilterParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + e.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) { + e.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) { + e.beginDelete.remove(req) + } + + return resp, nil +} + +func (e *EdgeActionExecutionFiltersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if e.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\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/executionFilters/(?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 + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + executionFilterParam, err := url.PathUnescape(matches[regex.SubexpIndex("executionFilter")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameParam, edgeActionNameParam, executionFilterParam, 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).EdgeActionExecutionFilter, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EdgeActionExecutionFiltersServerTransport) dispatchNewListByEdgeActionPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListByEdgeActionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByEdgeActionPager not implemented")} + } + newListByEdgeActionPager := e.newListByEdgeActionPager.get(req) + if newListByEdgeActionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/executionFilters` + 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 + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + resp := e.srv.NewListByEdgeActionPager(resourceGroupNameParam, edgeActionNameParam, nil) + newListByEdgeActionPager = &resp + e.newListByEdgeActionPager.add(req, newListByEdgeActionPager) + server.PagerResponderInjectNextLinks(newListByEdgeActionPager, req, func(page *armedgeactions.EdgeActionExecutionFiltersClientListByEdgeActionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByEdgeActionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + e.newListByEdgeActionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByEdgeActionPager) { + e.newListByEdgeActionPager.remove(req) + } + return resp, nil +} + +func (e *EdgeActionExecutionFiltersServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if e.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := e.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/executionFilters/(?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[armedgeactions.EdgeActionExecutionFilter](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + executionFilterParam, err := url.PathUnescape(matches[regex.SubexpIndex("executionFilter")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginUpdate(req.Context(), resourceGroupNameParam, edgeActionNameParam, executionFilterParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + e.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + e.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + e.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to EdgeActionExecutionFiltersServerTransport +var edgeActionExecutionFiltersServerTransportInterceptor 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/edgeactions/armedgeactions/fake/edgeactionversions_server.go b/sdk/resourcemanager/edgeactions/armedgeactions/fake/edgeactionversions_server.go new file mode 100644 index 000000000000..0970f5657c6f --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/fake/edgeactionversions_server.go @@ -0,0 +1,525 @@ +// 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/edgeactions/armedgeactions" + "net/http" + "net/url" + "regexp" +) + +// EdgeActionVersionsServer is a fake server for instances of the armedgeactions.EdgeActionVersionsClient type. +type EdgeActionVersionsServer struct { + // BeginCreate is the fake for method EdgeActionVersionsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, edgeActionName string, version string, resource armedgeactions.EdgeActionVersion, options *armedgeactions.EdgeActionVersionsClientBeginCreateOptions) (resp azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method EdgeActionVersionsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, edgeActionName string, version string, options *armedgeactions.EdgeActionVersionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // BeginDeployVersionCode is the fake for method EdgeActionVersionsClient.BeginDeployVersionCode + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginDeployVersionCode func(ctx context.Context, resourceGroupName string, edgeActionName string, version string, body armedgeactions.VersionCode, options *armedgeactions.EdgeActionVersionsClientBeginDeployVersionCodeOptions) (resp azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientDeployVersionCodeResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method EdgeActionVersionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, edgeActionName string, version string, options *armedgeactions.EdgeActionVersionsClientGetOptions) (resp azfake.Responder[armedgeactions.EdgeActionVersionsClientGetResponse], errResp azfake.ErrorResponder) + + // BeginGetVersionCode is the fake for method EdgeActionVersionsClient.BeginGetVersionCode + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginGetVersionCode func(ctx context.Context, resourceGroupName string, edgeActionName string, version string, options *armedgeactions.EdgeActionVersionsClientBeginGetVersionCodeOptions) (resp azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientGetVersionCodeResponse], errResp azfake.ErrorResponder) + + // NewListByEdgeActionPager is the fake for method EdgeActionVersionsClient.NewListByEdgeActionPager + // HTTP status codes to indicate success: http.StatusOK + NewListByEdgeActionPager func(resourceGroupName string, edgeActionName string, options *armedgeactions.EdgeActionVersionsClientListByEdgeActionOptions) (resp azfake.PagerResponder[armedgeactions.EdgeActionVersionsClientListByEdgeActionResponse]) + + // BeginSwapDefault is the fake for method EdgeActionVersionsClient.BeginSwapDefault + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginSwapDefault func(ctx context.Context, resourceGroupName string, edgeActionName string, version string, options *armedgeactions.EdgeActionVersionsClientBeginSwapDefaultOptions) (resp azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientSwapDefaultResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method EdgeActionVersionsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, edgeActionName string, version string, properties armedgeactions.EdgeActionVersion, options *armedgeactions.EdgeActionVersionsClientBeginUpdateOptions) (resp azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewEdgeActionVersionsServerTransport creates a new instance of EdgeActionVersionsServerTransport with the provided implementation. +// The returned EdgeActionVersionsServerTransport instance is connected to an instance of armedgeactions.EdgeActionVersionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewEdgeActionVersionsServerTransport(srv *EdgeActionVersionsServer) *EdgeActionVersionsServerTransport { + return &EdgeActionVersionsServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientDeleteResponse]](), + beginDeployVersionCode: newTracker[azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientDeployVersionCodeResponse]](), + beginGetVersionCode: newTracker[azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientGetVersionCodeResponse]](), + newListByEdgeActionPager: newTracker[azfake.PagerResponder[armedgeactions.EdgeActionVersionsClientListByEdgeActionResponse]](), + beginSwapDefault: newTracker[azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientSwapDefaultResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientUpdateResponse]](), + } +} + +// EdgeActionVersionsServerTransport connects instances of armedgeactions.EdgeActionVersionsClient to instances of EdgeActionVersionsServer. +// Don't use this type directly, use NewEdgeActionVersionsServerTransport instead. +type EdgeActionVersionsServerTransport struct { + srv *EdgeActionVersionsServer + beginCreate *tracker[azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientDeleteResponse]] + beginDeployVersionCode *tracker[azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientDeployVersionCodeResponse]] + beginGetVersionCode *tracker[azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientGetVersionCodeResponse]] + newListByEdgeActionPager *tracker[azfake.PagerResponder[armedgeactions.EdgeActionVersionsClientListByEdgeActionResponse]] + beginSwapDefault *tracker[azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientSwapDefaultResponse]] + beginUpdate *tracker[azfake.PollerResponder[armedgeactions.EdgeActionVersionsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for EdgeActionVersionsServerTransport. +func (e *EdgeActionVersionsServerTransport) 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 e.dispatchToMethodFake(req, method) +} + +func (e *EdgeActionVersionsServerTransport) 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 edgeActionVersionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = edgeActionVersionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "EdgeActionVersionsClient.BeginCreate": + res.resp, res.err = e.dispatchBeginCreate(req) + case "EdgeActionVersionsClient.BeginDelete": + res.resp, res.err = e.dispatchBeginDelete(req) + case "EdgeActionVersionsClient.BeginDeployVersionCode": + res.resp, res.err = e.dispatchBeginDeployVersionCode(req) + case "EdgeActionVersionsClient.Get": + res.resp, res.err = e.dispatchGet(req) + case "EdgeActionVersionsClient.BeginGetVersionCode": + res.resp, res.err = e.dispatchBeginGetVersionCode(req) + case "EdgeActionVersionsClient.NewListByEdgeActionPager": + res.resp, res.err = e.dispatchNewListByEdgeActionPager(req) + case "EdgeActionVersionsClient.BeginSwapDefault": + res.resp, res.err = e.dispatchBeginSwapDefault(req) + case "EdgeActionVersionsClient.BeginUpdate": + res.resp, res.err = e.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 (e *EdgeActionVersionsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if e.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := e.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?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[armedgeactions.EdgeActionVersion](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + versionParam, err := url.PathUnescape(matches[regex.SubexpIndex("version")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginCreate(req.Context(), resourceGroupNameParam, edgeActionNameParam, versionParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + e.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) { + e.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) { + e.beginCreate.remove(req) + } + + return resp, nil +} + +func (e *EdgeActionVersionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if e.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := e.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?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 + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + versionParam, err := url.PathUnescape(matches[regex.SubexpIndex("version")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginDelete(req.Context(), resourceGroupNameParam, edgeActionNameParam, versionParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + e.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) { + e.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) { + e.beginDelete.remove(req) + } + + return resp, nil +} + +func (e *EdgeActionVersionsServerTransport) dispatchBeginDeployVersionCode(req *http.Request) (*http.Response, error) { + if e.srv.BeginDeployVersionCode == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDeployVersionCode not implemented")} + } + beginDeployVersionCode := e.beginDeployVersionCode.get(req) + if beginDeployVersionCode == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deployVersionCode` + 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[armedgeactions.VersionCode](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + versionParam, err := url.PathUnescape(matches[regex.SubexpIndex("version")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginDeployVersionCode(req.Context(), resourceGroupNameParam, edgeActionNameParam, versionParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDeployVersionCode = &respr + e.beginDeployVersionCode.add(req, beginDeployVersionCode) + } + + resp, err := server.PollerResponderNext(beginDeployVersionCode, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + e.beginDeployVersionCode.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDeployVersionCode) { + e.beginDeployVersionCode.remove(req) + } + + return resp, nil +} + +func (e *EdgeActionVersionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if e.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\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?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 + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + versionParam, err := url.PathUnescape(matches[regex.SubexpIndex("version")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameParam, edgeActionNameParam, versionParam, 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).EdgeActionVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EdgeActionVersionsServerTransport) dispatchBeginGetVersionCode(req *http.Request) (*http.Response, error) { + if e.srv.BeginGetVersionCode == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginGetVersionCode not implemented")} + } + beginGetVersionCode := e.beginGetVersionCode.get(req) + if beginGetVersionCode == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getVersionCode` + 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 + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + versionParam, err := url.PathUnescape(matches[regex.SubexpIndex("version")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginGetVersionCode(req.Context(), resourceGroupNameParam, edgeActionNameParam, versionParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginGetVersionCode = &respr + e.beginGetVersionCode.add(req, beginGetVersionCode) + } + + resp, err := server.PollerResponderNext(beginGetVersionCode, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + e.beginGetVersionCode.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginGetVersionCode) { + e.beginGetVersionCode.remove(req) + } + + return resp, nil +} + +func (e *EdgeActionVersionsServerTransport) dispatchNewListByEdgeActionPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListByEdgeActionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByEdgeActionPager not implemented")} + } + newListByEdgeActionPager := e.newListByEdgeActionPager.get(req) + if newListByEdgeActionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + 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 + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + resp := e.srv.NewListByEdgeActionPager(resourceGroupNameParam, edgeActionNameParam, nil) + newListByEdgeActionPager = &resp + e.newListByEdgeActionPager.add(req, newListByEdgeActionPager) + server.PagerResponderInjectNextLinks(newListByEdgeActionPager, req, func(page *armedgeactions.EdgeActionVersionsClientListByEdgeActionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByEdgeActionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + e.newListByEdgeActionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByEdgeActionPager) { + e.newListByEdgeActionPager.remove(req) + } + return resp, nil +} + +func (e *EdgeActionVersionsServerTransport) dispatchBeginSwapDefault(req *http.Request) (*http.Response, error) { + if e.srv.BeginSwapDefault == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginSwapDefault not implemented")} + } + beginSwapDefault := e.beginSwapDefault.get(req) + if beginSwapDefault == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/swapDefault` + 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 + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + versionParam, err := url.PathUnescape(matches[regex.SubexpIndex("version")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginSwapDefault(req.Context(), resourceGroupNameParam, edgeActionNameParam, versionParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginSwapDefault = &respr + e.beginSwapDefault.add(req, beginSwapDefault) + } + + resp, err := server.PollerResponderNext(beginSwapDefault, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + e.beginSwapDefault.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(beginSwapDefault) { + e.beginSwapDefault.remove(req) + } + + return resp, nil +} + +func (e *EdgeActionVersionsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if e.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := e.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?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[armedgeactions.EdgeActionVersion](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + versionParam, err := url.PathUnescape(matches[regex.SubexpIndex("version")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginUpdate(req.Context(), resourceGroupNameParam, edgeActionNameParam, versionParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + e.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + e.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + e.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to EdgeActionVersionsServerTransport +var edgeActionVersionsServerTransportInterceptor 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/edgeactions/armedgeactions/fake/internal.go b/sdk/resourcemanager/edgeactions/armedgeactions/fake/internal.go new file mode 100644 index 000000000000..7425b6a669e2 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/fake/internal.go @@ -0,0 +1,65 @@ +// 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" + "net/http" + "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 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/edgeactions/armedgeactions/fake/server.go b/sdk/resourcemanager/edgeactions/armedgeactions/fake/server.go new file mode 100644 index 000000000000..3f5f47041ffe --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/fake/server.go @@ -0,0 +1,486 @@ +// 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/edgeactions/armedgeactions" + "net/http" + "net/url" + "regexp" +) + +// Server is a fake server for instances of the armedgeactions.Client type. +type Server struct { + // BeginAddAttachment is the fake for method Client.BeginAddAttachment + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginAddAttachment func(ctx context.Context, resourceGroupName string, edgeActionName string, body armedgeactions.EdgeActionAttachment, options *armedgeactions.ClientBeginAddAttachmentOptions) (resp azfake.PollerResponder[armedgeactions.ClientAddAttachmentResponse], errResp azfake.ErrorResponder) + + // BeginCreate is the fake for method Client.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, edgeActionName string, resource armedgeactions.EdgeAction, options *armedgeactions.ClientBeginCreateOptions) (resp azfake.PollerResponder[armedgeactions.ClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method Client.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, edgeActionName string, options *armedgeactions.ClientBeginDeleteOptions) (resp azfake.PollerResponder[armedgeactions.ClientDeleteResponse], errResp azfake.ErrorResponder) + + // BeginDeleteAttachment is the fake for method Client.BeginDeleteAttachment + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDeleteAttachment func(ctx context.Context, resourceGroupName string, edgeActionName string, body armedgeactions.EdgeActionAttachment, options *armedgeactions.ClientBeginDeleteAttachmentOptions) (resp azfake.PollerResponder[armedgeactions.ClientDeleteAttachmentResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method Client.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, edgeActionName string, options *armedgeactions.ClientGetOptions) (resp azfake.Responder[armedgeactions.ClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method Client.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armedgeactions.ClientListByResourceGroupOptions) (resp azfake.PagerResponder[armedgeactions.ClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method Client.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armedgeactions.ClientListBySubscriptionOptions) (resp azfake.PagerResponder[armedgeactions.ClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method Client.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, edgeActionName string, properties armedgeactions.EdgeAction, options *armedgeactions.ClientBeginUpdateOptions) (resp azfake.PollerResponder[armedgeactions.ClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of armedgeactions.Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{ + srv: srv, + beginAddAttachment: newTracker[azfake.PollerResponder[armedgeactions.ClientAddAttachmentResponse]](), + beginCreate: newTracker[azfake.PollerResponder[armedgeactions.ClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armedgeactions.ClientDeleteResponse]](), + beginDeleteAttachment: newTracker[azfake.PollerResponder[armedgeactions.ClientDeleteAttachmentResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armedgeactions.ClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armedgeactions.ClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armedgeactions.ClientUpdateResponse]](), + } +} + +// ServerTransport connects instances of armedgeactions.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server + beginAddAttachment *tracker[azfake.PollerResponder[armedgeactions.ClientAddAttachmentResponse]] + beginCreate *tracker[azfake.PollerResponder[armedgeactions.ClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armedgeactions.ClientDeleteResponse]] + beginDeleteAttachment *tracker[azfake.PollerResponder[armedgeactions.ClientDeleteAttachmentResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armedgeactions.ClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armedgeactions.ClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armedgeactions.ClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) 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 s.dispatchToMethodFake(req, method) +} + +func (s *ServerTransport) 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 serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.BeginAddAttachment": + res.resp, res.err = s.dispatchBeginAddAttachment(req) + case "Client.BeginCreate": + res.resp, res.err = s.dispatchBeginCreate(req) + case "Client.BeginDelete": + res.resp, res.err = s.dispatchBeginDelete(req) + case "Client.BeginDeleteAttachment": + res.resp, res.err = s.dispatchBeginDeleteAttachment(req) + case "Client.Get": + res.resp, res.err = s.dispatchGet(req) + case "Client.NewListByResourceGroupPager": + res.resp, res.err = s.dispatchNewListByResourceGroupPager(req) + case "Client.NewListBySubscriptionPager": + res.resp, res.err = s.dispatchNewListBySubscriptionPager(req) + case "Client.BeginUpdate": + res.resp, res.err = s.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 (s *ServerTransport) dispatchBeginAddAttachment(req *http.Request) (*http.Response, error) { + if s.srv.BeginAddAttachment == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginAddAttachment not implemented")} + } + beginAddAttachment := s.beginAddAttachment.get(req) + if beginAddAttachment == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/addAttachment` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armedgeactions.EdgeActionAttachment](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginAddAttachment(req.Context(), resourceGroupNameParam, edgeActionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginAddAttachment = &respr + s.beginAddAttachment.add(req, beginAddAttachment) + } + + resp, err := server.PollerResponderNext(beginAddAttachment, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + s.beginAddAttachment.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginAddAttachment) { + s.beginAddAttachment.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := s.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armedgeactions.EdgeAction](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreate(req.Context(), resourceGroupNameParam, edgeActionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + s.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) { + s.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) { + s.beginCreate.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := s.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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 + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, edgeActionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + s.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) { + s.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) { + s.beginDelete.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchBeginDeleteAttachment(req *http.Request) (*http.Response, error) { + if s.srv.BeginDeleteAttachment == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDeleteAttachment not implemented")} + } + beginDeleteAttachment := s.beginDeleteAttachment.get(req) + if beginDeleteAttachment == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deleteAttachment` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armedgeactions.EdgeActionAttachment](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDeleteAttachment(req.Context(), resourceGroupNameParam, edgeActionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDeleteAttachment = &respr + s.beginDeleteAttachment.add(req, beginDeleteAttachment) + } + + resp, err := server.PollerResponderNext(beginDeleteAttachment, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + s.beginDeleteAttachment.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(beginDeleteAttachment) { + s.beginDeleteAttachment.remove(req) + } + + return resp, nil +} + +func (s *ServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.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\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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 + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, edgeActionNameParam, 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).EdgeAction, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := s.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 3 { + 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 + } + resp := s.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + s.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armedgeactions.ClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + s.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (s *ServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := s.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := s.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + s.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armedgeactions.ClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + s.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (s *ServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := s.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Cdn/edgeActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armedgeactions.EdgeAction](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + edgeActionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("edgeActionName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginUpdate(req.Context(), resourceGroupNameParam, edgeActionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + s.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + s.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + s.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor 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/edgeactions/armedgeactions/fake/server_factory.go b/sdk/resourcemanager/edgeactions/armedgeactions/fake/server_factory.go new file mode 100644 index 000000000000..9eebcc63c12f --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/fake/server_factory.go @@ -0,0 +1,90 @@ +// 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 armedgeactions.ClientFactory type. +type ServerFactory struct { + // Server contains the fakes for client Client + Server Server + + // EdgeActionExecutionFiltersServer contains the fakes for client EdgeActionExecutionFiltersClient + EdgeActionExecutionFiltersServer EdgeActionExecutionFiltersServer + + // EdgeActionVersionsServer contains the fakes for client EdgeActionVersionsClient + EdgeActionVersionsServer EdgeActionVersionsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armedgeactions.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 armedgeactions.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trServer *ServerTransport + trEdgeActionExecutionFiltersServer *EdgeActionExecutionFiltersServerTransport + trEdgeActionVersionsServer *EdgeActionVersionsServerTransport +} + +// 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 "Client": + initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) + resp, err = s.trServer.Do(req) + case "EdgeActionExecutionFiltersClient": + initServer(s, &s.trEdgeActionExecutionFiltersServer, func() *EdgeActionExecutionFiltersServerTransport { + return NewEdgeActionExecutionFiltersServerTransport(&s.srv.EdgeActionExecutionFiltersServer) + }) + resp, err = s.trEdgeActionExecutionFiltersServer.Do(req) + case "EdgeActionVersionsClient": + initServer(s, &s.trEdgeActionVersionsServer, func() *EdgeActionVersionsServerTransport { + return NewEdgeActionVersionsServerTransport(&s.srv.EdgeActionVersionsServer) + }) + resp, err = s.trEdgeActionVersionsServer.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/edgeactions/armedgeactions/go.mod b/sdk/resourcemanager/edgeactions/armedgeactions/go.mod new file mode 100644 index 000000000000..2dbb86fb8c97 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgeactions/armedgeactions + +go 1.24.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.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.46.0 // indirect + golang.org/x/net v0.48.0 // indirect + golang.org/x/sys v0.39.0 // indirect + golang.org/x/text v0.32.0 // indirect +) diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/go.sum b/sdk/resourcemanager/edgeactions/armedgeactions/go.sum new file mode 100644 index 000000000000..0802a4a10167 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/go.sum @@ -0,0 +1,39 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 h1:JXg2dwJUmPB9JmtVmdEB16APJ7jurfbY5jnfXpJoRMc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0/go.mod h1:YD5h/ldMsG0XiIw7PdyNhLxaM317eFh5yNLccNfGdyw= +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.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU= +golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0= +golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= +golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= +golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= +golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= +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/edgeactions/armedgeactions/models.go b/sdk/resourcemanager/edgeactions/armedgeactions/models.go new file mode 100644 index 000000000000..3de66a71fcf7 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/models.go @@ -0,0 +1,209 @@ +// 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 armedgeactions + +import "time" + +// EdgeAction - Concrete tracked resource types can be created by aliasing this type using a specific property type. +type EdgeAction struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // REQUIRED; The sku type of the edge action + SKU *SKUType + + // The resource-specific properties for this resource. + Properties *EdgeActionProperties + + // 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 +} + +// EdgeActionAttachment - Edge action attachment information +type EdgeActionAttachment struct { + // REQUIRED; The attached resource Id + AttachedResourceID *string + + // READ-ONLY; The edge action attachment id + ID *string +} + +// EdgeActionAttachmentResponse - Edge action attachment response +type EdgeActionAttachmentResponse struct { + // REQUIRED; Non changing guid to identity edge action + EdgeActionID *string +} + +// EdgeActionExecutionFilter - Concrete tracked resource types can be created by aliasing this type using a specific property +// type. +type EdgeActionExecutionFilter struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *EdgeActionExecutionFilterProperties + + // 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 +} + +// EdgeActionExecutionFilterListResult - The response of a EdgeActionExecutionFilter list operation. +type EdgeActionExecutionFilterListResult struct { + // REQUIRED; The EdgeActionExecutionFilter items on this page + Value []*EdgeActionExecutionFilter + + // The link to the next page of items + NextLink *string +} + +// EdgeActionExecutionFilterProperties - Properties for edge action execution filter +type EdgeActionExecutionFilterProperties struct { + // REQUIRED; Custom Header Key associated with the execution filter + ExecutionFilterIdentifierHeaderName *string + + // REQUIRED; Custom Header Value associated with the execution filter + ExecutionFilterIdentifierHeaderValue *string + + // REQUIRED; The referenced versionId of the edgeaction version + VersionID *string + + // READ-ONLY; The last update time in UTC for the execution filter + LastUpdateTime *time.Time + + // READ-ONLY; The provisioning state + ProvisioningState *ProvisioningState +} + +// EdgeActionListResult - The response of a EdgeAction list operation. +type EdgeActionListResult struct { + // REQUIRED; The EdgeAction items on this page + Value []*EdgeAction + + // The link to the next page of items + NextLink *string +} + +// EdgeActionProperties - Represents an edge action properties +type EdgeActionProperties struct { + // READ-ONLY; A list of attachments for the edge action + Attachments []*EdgeActionAttachment + + // READ-ONLY; The provisioning state of the edge action + ProvisioningState *ProvisioningState +} + +// EdgeActionVersion - Concrete tracked resource types can be created by aliasing this type using a specific property type. +type EdgeActionVersion struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *EdgeActionVersionProperties + + // 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 +} + +// EdgeActionVersionListResult - The response of a EdgeActionVersion list operation. +type EdgeActionVersionListResult struct { + // REQUIRED; The EdgeActionVersion items on this page + Value []*EdgeActionVersion + + // The link to the next page of items + NextLink *string +} + +// EdgeActionVersionProperties - Represents an edge action version +type EdgeActionVersionProperties struct { + // REQUIRED; The deployment type + DeploymentType *EdgeActionVersionDeploymentType + + // REQUIRED; The active state + IsDefaultVersion *EdgeActionIsDefaultVersion + + // READ-ONLY; The last update time in UTC for package update + LastPackageUpdateTime *time.Time + + // READ-ONLY; The validation status + ValidationStatus *EdgeActionVersionValidationStatus + + // READ-ONLY; The provisioning state + ProvisioningState *ProvisioningState +} + +// SKUType - The SKU type for the edge action +type SKUType struct { + // REQUIRED; The name of the SKU + Name *string + + // REQUIRED; The tier of the SKU + Tier *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 +} + +// VersionCode - Version code information for edge action +type VersionCode struct { + // REQUIRED; The version code deployment content + Content *string + + // REQUIRED; The version code name + Name *string +} diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/models_serde.go b/sdk/resourcemanager/edgeactions/armedgeactions/models_serde.go new file mode 100644 index 000000000000..b9b8196eb885 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/models_serde.go @@ -0,0 +1,566 @@ +// 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 armedgeactions + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type EdgeAction. +func (e EdgeAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "location", e.Location) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "sku", e.SKU) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EdgeAction. +func (e *EdgeAction) 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 "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &e.SKU) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + 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 EdgeActionAttachment. +func (e EdgeActionAttachment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "attachedResourceId", e.AttachedResourceID) + populate(objectMap, "id", e.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EdgeActionAttachment. +func (e *EdgeActionAttachment) 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 "attachedResourceId": + err = unpopulate(val, "AttachedResourceID", &e.AttachedResourceID) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &e.ID) + 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 EdgeActionAttachmentResponse. +func (e EdgeActionAttachmentResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "edgeActionId", e.EdgeActionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EdgeActionAttachmentResponse. +func (e *EdgeActionAttachmentResponse) 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 "edgeActionId": + err = unpopulate(val, "EdgeActionID", &e.EdgeActionID) + 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 EdgeActionExecutionFilter. +func (e EdgeActionExecutionFilter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "location", e.Location) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EdgeActionExecutionFilter. +func (e *EdgeActionExecutionFilter) 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 "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + 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 EdgeActionExecutionFilterListResult. +func (e EdgeActionExecutionFilterListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EdgeActionExecutionFilterListResult. +func (e *EdgeActionExecutionFilterListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + 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 EdgeActionExecutionFilterProperties. +func (e EdgeActionExecutionFilterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "executionFilterIdentifierHeaderName", e.ExecutionFilterIdentifierHeaderName) + populate(objectMap, "executionFilterIdentifierHeaderValue", e.ExecutionFilterIdentifierHeaderValue) + populateDateTimeRFC3339(objectMap, "lastUpdateTime", e.LastUpdateTime) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "versionId", e.VersionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EdgeActionExecutionFilterProperties. +func (e *EdgeActionExecutionFilterProperties) 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 "executionFilterIdentifierHeaderName": + err = unpopulate(val, "ExecutionFilterIdentifierHeaderName", &e.ExecutionFilterIdentifierHeaderName) + delete(rawMsg, key) + case "executionFilterIdentifierHeaderValue": + err = unpopulate(val, "ExecutionFilterIdentifierHeaderValue", &e.ExecutionFilterIdentifierHeaderValue) + delete(rawMsg, key) + case "lastUpdateTime": + err = unpopulateDateTimeRFC3339(val, "LastUpdateTime", &e.LastUpdateTime) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "versionId": + err = unpopulate(val, "VersionID", &e.VersionID) + 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 EdgeActionListResult. +func (e EdgeActionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EdgeActionListResult. +func (e *EdgeActionListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + 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 EdgeActionProperties. +func (e EdgeActionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "attachments", e.Attachments) + populate(objectMap, "provisioningState", e.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EdgeActionProperties. +func (e *EdgeActionProperties) 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 "attachments": + err = unpopulate(val, "Attachments", &e.Attachments) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + 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 EdgeActionVersion. +func (e EdgeActionVersion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "location", e.Location) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EdgeActionVersion. +func (e *EdgeActionVersion) 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 "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + 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 EdgeActionVersionListResult. +func (e EdgeActionVersionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EdgeActionVersionListResult. +func (e *EdgeActionVersionListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + 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 EdgeActionVersionProperties. +func (e EdgeActionVersionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "deploymentType", e.DeploymentType) + populate(objectMap, "isDefaultVersion", e.IsDefaultVersion) + populateDateTimeRFC3339(objectMap, "lastPackageUpdateTime", e.LastPackageUpdateTime) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "validationStatus", e.ValidationStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EdgeActionVersionProperties. +func (e *EdgeActionVersionProperties) 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 "deploymentType": + err = unpopulate(val, "DeploymentType", &e.DeploymentType) + delete(rawMsg, key) + case "isDefaultVersion": + err = unpopulate(val, "IsDefaultVersion", &e.IsDefaultVersion) + delete(rawMsg, key) + case "lastPackageUpdateTime": + err = unpopulateDateTimeRFC3339(val, "LastPackageUpdateTime", &e.LastPackageUpdateTime) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "validationStatus": + err = unpopulate(val, "ValidationStatus", &e.ValidationStatus) + 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 SKUType. +func (s SKUType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKUType. +func (s *SKUType) 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 "tier": + err = unpopulate(val, "Tier", &s.Tier) + 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) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(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 = unpopulateDateTimeRFC3339(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 = unpopulateDateTimeRFC3339(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 VersionCode. +func (v VersionCode) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "content", v.Content) + populate(objectMap, "name", v.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VersionCode. +func (v *VersionCode) 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", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "content": + err = unpopulate(val, "Content", &v.Content) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, 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 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 +} diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/options.go b/sdk/resourcemanager/edgeactions/armedgeactions/options.go new file mode 100644 index 000000000000..6130a91300d7 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/options.go @@ -0,0 +1,136 @@ +// 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 armedgeactions + +// ClientBeginAddAttachmentOptions contains the optional parameters for the Client.BeginAddAttachment method. +type ClientBeginAddAttachmentOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginCreateOptions contains the optional parameters for the Client.BeginCreate method. +type ClientBeginCreateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginDeleteAttachmentOptions contains the optional parameters for the Client.BeginDeleteAttachment method. +type ClientBeginDeleteAttachmentOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. +type ClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientBeginUpdateOptions contains the optional parameters for the Client.BeginUpdate method. +type ClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ClientGetOptions contains the optional parameters for the Client.Get method. +type ClientGetOptions struct { + // placeholder for future optional parameters +} + +// ClientListByResourceGroupOptions contains the optional parameters for the Client.NewListByResourceGroupPager method. +type ClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientListBySubscriptionOptions contains the optional parameters for the Client.NewListBySubscriptionPager method. +type ClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// EdgeActionExecutionFiltersClientBeginCreateOptions contains the optional parameters for the EdgeActionExecutionFiltersClient.BeginCreate +// method. +type EdgeActionExecutionFiltersClientBeginCreateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EdgeActionExecutionFiltersClientBeginDeleteOptions contains the optional parameters for the EdgeActionExecutionFiltersClient.BeginDelete +// method. +type EdgeActionExecutionFiltersClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EdgeActionExecutionFiltersClientBeginUpdateOptions contains the optional parameters for the EdgeActionExecutionFiltersClient.BeginUpdate +// method. +type EdgeActionExecutionFiltersClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EdgeActionExecutionFiltersClientGetOptions contains the optional parameters for the EdgeActionExecutionFiltersClient.Get +// method. +type EdgeActionExecutionFiltersClientGetOptions struct { + // placeholder for future optional parameters +} + +// EdgeActionExecutionFiltersClientListByEdgeActionOptions contains the optional parameters for the EdgeActionExecutionFiltersClient.NewListByEdgeActionPager +// method. +type EdgeActionExecutionFiltersClientListByEdgeActionOptions struct { + // placeholder for future optional parameters +} + +// EdgeActionVersionsClientBeginCreateOptions contains the optional parameters for the EdgeActionVersionsClient.BeginCreate +// method. +type EdgeActionVersionsClientBeginCreateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EdgeActionVersionsClientBeginDeleteOptions contains the optional parameters for the EdgeActionVersionsClient.BeginDelete +// method. +type EdgeActionVersionsClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EdgeActionVersionsClientBeginDeployVersionCodeOptions contains the optional parameters for the EdgeActionVersionsClient.BeginDeployVersionCode +// method. +type EdgeActionVersionsClientBeginDeployVersionCodeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EdgeActionVersionsClientBeginGetVersionCodeOptions contains the optional parameters for the EdgeActionVersionsClient.BeginGetVersionCode +// method. +type EdgeActionVersionsClientBeginGetVersionCodeOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EdgeActionVersionsClientBeginSwapDefaultOptions contains the optional parameters for the EdgeActionVersionsClient.BeginSwapDefault +// method. +type EdgeActionVersionsClientBeginSwapDefaultOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EdgeActionVersionsClientBeginUpdateOptions contains the optional parameters for the EdgeActionVersionsClient.BeginUpdate +// method. +type EdgeActionVersionsClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EdgeActionVersionsClientGetOptions contains the optional parameters for the EdgeActionVersionsClient.Get method. +type EdgeActionVersionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// EdgeActionVersionsClientListByEdgeActionOptions contains the optional parameters for the EdgeActionVersionsClient.NewListByEdgeActionPager +// method. +type EdgeActionVersionsClientListByEdgeActionOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/responses.go b/sdk/resourcemanager/edgeactions/armedgeactions/responses.go new file mode 100644 index 000000000000..f43ba1da2871 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/responses.go @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armedgeactions + +// ClientAddAttachmentResponse contains the response from method Client.BeginAddAttachment. +type ClientAddAttachmentResponse struct { + // Edge action attachment response + EdgeActionAttachmentResponse +} + +// ClientCreateResponse contains the response from method Client.BeginCreate. +type ClientCreateResponse struct { + // Concrete tracked resource types can be created by aliasing this type using a specific property type. + EdgeAction +} + +// ClientDeleteAttachmentResponse contains the response from method Client.BeginDeleteAttachment. +type ClientDeleteAttachmentResponse struct { + // placeholder for future response values +} + +// ClientDeleteResponse contains the response from method Client.BeginDelete. +type ClientDeleteResponse struct { + // placeholder for future response values +} + +// ClientGetResponse contains the response from method Client.Get. +type ClientGetResponse struct { + // Concrete tracked resource types can be created by aliasing this type using a specific property type. + EdgeAction +} + +// ClientListByResourceGroupResponse contains the response from method Client.NewListByResourceGroupPager. +type ClientListByResourceGroupResponse struct { + // The response of a EdgeAction list operation. + EdgeActionListResult +} + +// ClientListBySubscriptionResponse contains the response from method Client.NewListBySubscriptionPager. +type ClientListBySubscriptionResponse struct { + // The response of a EdgeAction list operation. + EdgeActionListResult +} + +// ClientUpdateResponse contains the response from method Client.BeginUpdate. +type ClientUpdateResponse struct { + // Concrete tracked resource types can be created by aliasing this type using a specific property type. + EdgeAction +} + +// EdgeActionExecutionFiltersClientCreateResponse contains the response from method EdgeActionExecutionFiltersClient.BeginCreate. +type EdgeActionExecutionFiltersClientCreateResponse struct { + // Concrete tracked resource types can be created by aliasing this type using a specific property type. + EdgeActionExecutionFilter +} + +// EdgeActionExecutionFiltersClientDeleteResponse contains the response from method EdgeActionExecutionFiltersClient.BeginDelete. +type EdgeActionExecutionFiltersClientDeleteResponse struct { + // placeholder for future response values +} + +// EdgeActionExecutionFiltersClientGetResponse contains the response from method EdgeActionExecutionFiltersClient.Get. +type EdgeActionExecutionFiltersClientGetResponse struct { + // Concrete tracked resource types can be created by aliasing this type using a specific property type. + EdgeActionExecutionFilter +} + +// EdgeActionExecutionFiltersClientListByEdgeActionResponse contains the response from method EdgeActionExecutionFiltersClient.NewListByEdgeActionPager. +type EdgeActionExecutionFiltersClientListByEdgeActionResponse struct { + // The response of a EdgeActionExecutionFilter list operation. + EdgeActionExecutionFilterListResult +} + +// EdgeActionExecutionFiltersClientUpdateResponse contains the response from method EdgeActionExecutionFiltersClient.BeginUpdate. +type EdgeActionExecutionFiltersClientUpdateResponse struct { + // Concrete tracked resource types can be created by aliasing this type using a specific property type. + EdgeActionExecutionFilter +} + +// EdgeActionVersionsClientCreateResponse contains the response from method EdgeActionVersionsClient.BeginCreate. +type EdgeActionVersionsClientCreateResponse struct { + // Concrete tracked resource types can be created by aliasing this type using a specific property type. + EdgeActionVersion +} + +// EdgeActionVersionsClientDeleteResponse contains the response from method EdgeActionVersionsClient.BeginDelete. +type EdgeActionVersionsClientDeleteResponse struct { + // placeholder for future response values +} + +// EdgeActionVersionsClientDeployVersionCodeResponse contains the response from method EdgeActionVersionsClient.BeginDeployVersionCode. +type EdgeActionVersionsClientDeployVersionCodeResponse struct { + // Represents an edge action version + EdgeActionVersionProperties +} + +// EdgeActionVersionsClientGetResponse contains the response from method EdgeActionVersionsClient.Get. +type EdgeActionVersionsClientGetResponse struct { + // Concrete tracked resource types can be created by aliasing this type using a specific property type. + EdgeActionVersion +} + +// EdgeActionVersionsClientGetVersionCodeResponse contains the response from method EdgeActionVersionsClient.BeginGetVersionCode. +type EdgeActionVersionsClientGetVersionCodeResponse struct { + // Version code information for edge action + VersionCode +} + +// EdgeActionVersionsClientListByEdgeActionResponse contains the response from method EdgeActionVersionsClient.NewListByEdgeActionPager. +type EdgeActionVersionsClientListByEdgeActionResponse struct { + // The response of a EdgeActionVersion list operation. + EdgeActionVersionListResult +} + +// EdgeActionVersionsClientSwapDefaultResponse contains the response from method EdgeActionVersionsClient.BeginSwapDefault. +type EdgeActionVersionsClientSwapDefaultResponse struct { + // placeholder for future response values +} + +// EdgeActionVersionsClientUpdateResponse contains the response from method EdgeActionVersionsClient.BeginUpdate. +type EdgeActionVersionsClientUpdateResponse struct { + // Concrete tracked resource types can be created by aliasing this type using a specific property type. + EdgeActionVersion +} diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/testdata/_metadata.json b/sdk/resourcemanager/edgeactions/armedgeactions/testdata/_metadata.json new file mode 100644 index 000000000000..ce2e1cb41cd4 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/testdata/_metadata.json @@ -0,0 +1,4 @@ +{ + "apiVersion": "2025-09-01-preview", + "emitterVersion": "0.8.8" +} \ No newline at end of file diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/time_rfc3339.go b/sdk/resourcemanager/edgeactions/armedgeactions/time_rfc3339.go new file mode 100644 index 000000000000..a47c3316f6fc --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/time_rfc3339.go @@ -0,0 +1,109 @@ +// 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 armedgeactions + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/tsp-location.yaml b/sdk/resourcemanager/edgeactions/armedgeactions/tsp-location.yaml new file mode 100644 index 000000000000..e3849c629d91 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/cdn/resource-manager/Microsoft.Cdn/EdgeActions +commit: be46becafeb29aa993898709e35759d3643b2809 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/resourcemanager/edgeactions/armedgeactions/version.go b/sdk/resourcemanager/edgeactions/armedgeactions/version.go new file mode 100644 index 000000000000..86665ef6c0e1 --- /dev/null +++ b/sdk/resourcemanager/edgeactions/armedgeactions/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 armedgeactions + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgeactions/armedgeactions" + moduleVersion = "v0.1.0" +)