diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/CHANGELOG.md b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/CHANGELOG.md new file mode 100644 index 000000000000..072ca6cc83c1 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-10-16) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/virtualenclaves/armvirtualenclaves` 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/virtualenclaves/armvirtualenclaves/LICENSE.txt b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/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/virtualenclaves/armvirtualenclaves/README.md b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/README.md new file mode 100644 index 000000000000..8564ab19519f --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/README.md @@ -0,0 +1,90 @@ +# Azure Virtual Enclaves Module for Go + +The `armvirtualenclaves` module provides operations for working with Azure Virtual Enclaves. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/virtualenclaves/armvirtualenclaves) + +# 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 Virtual Enclaves module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/virtualenclaves/armvirtualenclaves +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Virtual Enclaves. 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 Virtual Enclaves 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 := armvirtualenclaves.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 := armvirtualenclaves.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.NewCommunityClient() +``` + +## 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 `Virtual Enclaves` 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/virtualenclaves/armvirtualenclaves/approval_client.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/approval_client.go new file mode 100644 index 000000000000..2169bc5cdf66 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/approval_client.go @@ -0,0 +1,454 @@ +// 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 armvirtualenclaves + +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" +) + +// ApprovalClient - Approval Interface +// Don't use this type directly, use NewApprovalClient() instead. +type ApprovalClient struct { + internal *arm.Client +} + +// NewApprovalClient creates a new instance of ApprovalClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - Contains optional client configuration. Pass nil to accept the default values. +func NewApprovalClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ApprovalClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ApprovalClient{ + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a ApprovalResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - approvalName - The name of the approvals resource. +// - resource - Resource create parameters. +// - options - ApprovalClientBeginCreateOrUpdateOptions contains the optional parameters for the ApprovalClient.BeginCreateOrUpdate +// method. +func (client *ApprovalClient) BeginCreateOrUpdate(ctx context.Context, resourceURI string, approvalName string, resource ApprovalResource, options *ApprovalClientBeginCreateOrUpdateOptions) (*runtime.Poller[ApprovalClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceURI, approvalName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ApprovalClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ApprovalClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a ApprovalResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *ApprovalClient) createOrUpdate(ctx context.Context, resourceURI string, approvalName string, resource ApprovalResource, options *ApprovalClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "ApprovalClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceURI, approvalName, 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 +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ApprovalClient) createOrUpdateCreateRequest(ctx context.Context, resourceURI string, approvalName string, resource ApprovalResource, _ *ApprovalClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName}" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if approvalName == "" { + return nil, errors.New("parameter approvalName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{approvalName}", url.PathEscape(approvalName)) + 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-05-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 ApprovalResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - approvalName - The name of the approvals resource. +// - options - ApprovalClientBeginDeleteOptions contains the optional parameters for the ApprovalClient.BeginDelete method. +func (client *ApprovalClient) BeginDelete(ctx context.Context, resourceURI string, approvalName string, options *ApprovalClientBeginDeleteOptions) (*runtime.Poller[ApprovalClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceURI, approvalName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ApprovalClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ApprovalClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a ApprovalResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *ApprovalClient) deleteOperation(ctx context.Context, resourceURI string, approvalName string, options *ApprovalClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "ApprovalClient.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, resourceURI, approvalName, 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 *ApprovalClient) deleteCreateRequest(ctx context.Context, resourceURI string, approvalName string, _ *ApprovalClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName}" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if approvalName == "" { + return nil, errors.New("parameter approvalName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{approvalName}", url.PathEscape(approvalName)) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Get a ApprovalResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - approvalName - The name of the approvals resource. +// - options - ApprovalClientGetOptions contains the optional parameters for the ApprovalClient.Get method. +func (client *ApprovalClient) Get(ctx context.Context, resourceURI string, approvalName string, options *ApprovalClientGetOptions) (ApprovalClientGetResponse, error) { + var err error + const operationName = "ApprovalClient.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, resourceURI, approvalName, options) + if err != nil { + return ApprovalClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApprovalClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ApprovalClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ApprovalClient) getCreateRequest(ctx context.Context, resourceURI string, approvalName string, _ *ApprovalClientGetOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName}" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if approvalName == "" { + return nil, errors.New("parameter approvalName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{approvalName}", url.PathEscape(approvalName)) + 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-05-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 *ApprovalClient) getHandleResponse(resp *http.Response) (ApprovalClientGetResponse, error) { + result := ApprovalClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApprovalResource); err != nil { + return ApprovalClientGetResponse{}, err + } + return result, nil +} + +// NewListByParentPager - List ApprovalResource resources by parent +// +// Generated from API version 2025-05-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - options - ApprovalClientListByParentOptions contains the optional parameters for the ApprovalClient.NewListByParentPager +// method. +func (client *ApprovalClient) NewListByParentPager(resourceURI string, options *ApprovalClientListByParentOptions) *runtime.Pager[ApprovalClientListByParentResponse] { + return runtime.NewPager(runtime.PagingHandler[ApprovalClientListByParentResponse]{ + More: func(page ApprovalClientListByParentResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ApprovalClientListByParentResponse) (ApprovalClientListByParentResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ApprovalClient.NewListByParentPager") + 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.listByParentCreateRequest(ctx, resourceURI, options) + }, nil) + if err != nil { + return ApprovalClientListByParentResponse{}, err + } + return client.listByParentHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByParentCreateRequest creates the ListByParent request. +func (client *ApprovalClient) listByParentCreateRequest(ctx context.Context, resourceURI string, _ *ApprovalClientListByParentOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Mission/approvals" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByParentHandleResponse handles the ListByParent response. +func (client *ApprovalClient) listByParentHandleResponse(resp *http.Response) (ApprovalClientListByParentResponse, error) { + result := ApprovalClientListByParentResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApprovalResourceListResult); err != nil { + return ApprovalClientListByParentResponse{}, err + } + return result, nil +} + +// BeginNotifyInitiator - Upon receiving approval or rejection from approver, this facilitates actions on approval resource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - approvalName - The name of the approvals resource. +// - body - The content of the action request +// - options - ApprovalClientBeginNotifyInitiatorOptions contains the optional parameters for the ApprovalClient.BeginNotifyInitiator +// method. +func (client *ApprovalClient) BeginNotifyInitiator(ctx context.Context, resourceURI string, approvalName string, body ApprovalActionRequest, options *ApprovalClientBeginNotifyInitiatorOptions) (*runtime.Poller[ApprovalClientNotifyInitiatorResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.notifyInitiator(ctx, resourceURI, approvalName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ApprovalClientNotifyInitiatorResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ApprovalClientNotifyInitiatorResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// NotifyInitiator - Upon receiving approval or rejection from approver, this facilitates actions on approval resource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *ApprovalClient) notifyInitiator(ctx context.Context, resourceURI string, approvalName string, body ApprovalActionRequest, options *ApprovalClientBeginNotifyInitiatorOptions) (*http.Response, error) { + var err error + const operationName = "ApprovalClient.BeginNotifyInitiator" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.notifyInitiatorCreateRequest(ctx, resourceURI, approvalName, 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 +} + +// notifyInitiatorCreateRequest creates the NotifyInitiator request. +func (client *ApprovalClient) notifyInitiatorCreateRequest(ctx context.Context, resourceURI string, approvalName string, body ApprovalActionRequest, _ *ApprovalClientBeginNotifyInitiatorOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName}/notifyInitiator" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if approvalName == "" { + return nil, errors.New("parameter approvalName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{approvalName}", url.PathEscape(approvalName)) + 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-05-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 +} + +// BeginUpdate - Update a ApprovalResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceURI - The fully qualified Azure Resource manager identifier of the resource. +// - approvalName - The name of the approvals resource. +// - properties - The resource properties to be updated. +// - options - ApprovalClientBeginUpdateOptions contains the optional parameters for the ApprovalClient.BeginUpdate method. +func (client *ApprovalClient) BeginUpdate(ctx context.Context, resourceURI string, approvalName string, properties ApprovalPatchModel, options *ApprovalClientBeginUpdateOptions) (*runtime.Poller[ApprovalClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceURI, approvalName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ApprovalClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ApprovalClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a ApprovalResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *ApprovalClient) update(ctx context.Context, resourceURI string, approvalName string, properties ApprovalPatchModel, options *ApprovalClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "ApprovalClient.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, resourceURI, approvalName, 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 *ApprovalClient) updateCreateRequest(ctx context.Context, resourceURI string, approvalName string, properties ApprovalPatchModel, _ *ApprovalClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/{resourceUri}/providers/Microsoft.Mission/approvals/{approvalName}" + if resourceURI == "" { + return nil, errors.New("parameter resourceURI cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceUri}", resourceURI) + if approvalName == "" { + return nil, errors.New("parameter approvalName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{approvalName}", url.PathEscape(approvalName)) + 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-05-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/virtualenclaves/armvirtualenclaves/approval_client_example_test.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/approval_client_example_test.go new file mode 100644 index 000000000000..9414f41cce9e --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/approval_client_example_test.go @@ -0,0 +1,348 @@ +// 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 armvirtualenclaves_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/virtualenclaves/armvirtualenclaves" + "log" + "time" +) + +// Generated from example definition: 2025-05-01-preview/Approvals_CreateOrUpdate.json +func ExampleApprovalClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewApprovalClient().BeginCreateOrUpdate(ctx, "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection", "TestApprovals", armvirtualenclaves.ApprovalResource{ + Properties: &armvirtualenclaves.ApprovalProperties{ + ParentResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + GrandparentResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + RequestMetadata: &armvirtualenclaves.RequestMetadata{ + ResourceAction: to.Ptr("string"), + ApprovalStatus: to.Ptr(armvirtualenclaves.ApprovalStatusApproved), + ApprovalCallbackRoute: to.Ptr("approvalCallback"), + ApprovalCallbackPayload: to.Ptr("{\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n}"), + }, + Approvers: []*armvirtualenclaves.Approver{ + { + ApproverEntraID: to.Ptr("00000000-0000-0000-0000-000000000000"), + ActionPerformed: to.Ptr(armvirtualenclaves.ActionPerformedApproved), + LastUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t }()), + }, + }, + TicketID: to.Ptr("string"), + CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t }()), + StateChangedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t }()), + }, + }, 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 = armvirtualenclaves.ApprovalClientCreateOrUpdateResponse{ + // ApprovalResource: &armvirtualenclaves.ApprovalResource{ + // Properties: &armvirtualenclaves.ApprovalProperties{ + // ParentResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // GrandparentResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // RequestMetadata: &armvirtualenclaves.RequestMetadata{ + // ResourceAction: to.Ptr("string"), + // ApprovalStatus: to.Ptr(armvirtualenclaves.ApprovalStatusApproved), + // ApprovalCallbackRoute: to.Ptr("approvalCallback"), + // ApprovalCallbackPayload: to.Ptr("{\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n}"), + // }, + // Approvers: []*armvirtualenclaves.Approver{ + // { + // ApproverEntraID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ActionPerformed: to.Ptr(armvirtualenclaves.ActionPerformedApproved), + // LastUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // TicketID: to.Ptr("string"), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // StateChangedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/approvals/TestApprovals"), + // Name: to.Ptr("TestApprovals"), + // Type: to.Ptr("Microsoft.Mission/approvals"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/Approvals_Delete.json +func ExampleApprovalClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewApprovalClient().BeginDelete(ctx, "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection", "TestApprovals", 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-05-01-preview/Approvals_Get.json +func ExampleApprovalClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApprovalClient().Get(ctx, "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection", "TestApprovals", 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 = armvirtualenclaves.ApprovalClientGetResponse{ + // ApprovalResource: &armvirtualenclaves.ApprovalResource{ + // Properties: &armvirtualenclaves.ApprovalProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // ParentResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // GrandparentResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // RequestMetadata: &armvirtualenclaves.RequestMetadata{ + // ResourceAction: to.Ptr("string"), + // ApprovalStatus: to.Ptr(armvirtualenclaves.ApprovalStatusApproved), + // ApprovalCallbackRoute: to.Ptr("approvalCallback"), + // ApprovalCallbackPayload: to.Ptr("{\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n}"), + // }, + // Approvers: []*armvirtualenclaves.Approver{ + // { + // ApproverEntraID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ActionPerformed: to.Ptr(armvirtualenclaves.ActionPerformedApproved), + // LastUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // TicketID: to.Ptr("string"), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // StateChangedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/approvals/TestApprovals"), + // Name: to.Ptr("TestApprovals"), + // Type: to.Ptr("Microsoft.Mission/approvals"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/Approvals_ListByParent.json +func ExampleApprovalClient_NewListByParentPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewApprovalClient().NewListByParentPager("subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection", 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 = armvirtualenclaves.ApprovalClientListByParentResponse{ + // ApprovalResourceListResult: armvirtualenclaves.ApprovalResourceListResult{ + // Value: []*armvirtualenclaves.ApprovalResource{ + // { + // Properties: &armvirtualenclaves.ApprovalProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // ParentResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // GrandparentResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // RequestMetadata: &armvirtualenclaves.RequestMetadata{ + // ResourceAction: to.Ptr("string"), + // ApprovalStatus: to.Ptr(armvirtualenclaves.ApprovalStatusApproved), + // ApprovalCallbackRoute: to.Ptr("approvalCallback"), + // ApprovalCallbackPayload: to.Ptr("{\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n}"), + // }, + // Approvers: []*armvirtualenclaves.Approver{ + // { + // ApproverEntraID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ActionPerformed: to.Ptr(armvirtualenclaves.ActionPerformedApproved), + // LastUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // TicketID: to.Ptr("string"), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // StateChangedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/approvals/TestApprovals"), + // Name: to.Ptr("TestApprovals"), + // Type: to.Ptr("Microsoft.Mission/approvals"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/Approvals_NotifyInitiator.json +func ExampleApprovalClient_BeginNotifyInitiator() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewApprovalClient().BeginNotifyInitiator(ctx, "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection", "TestApprovals", armvirtualenclaves.ApprovalActionRequest{ + ApprovalStatus: to.Ptr(armvirtualenclaves.ApprovalActionRequestApprovalStatusApproved), + }, 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 = armvirtualenclaves.ApprovalClientNotifyInitiatorResponse{ + // ApprovalActionResponse: &armvirtualenclaves.ApprovalActionResponse{ + // Message: to.Ptr("Approved"), + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/Approvals_Update.json +func ExampleApprovalClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewApprovalClient().BeginUpdate(ctx, "subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection", "TestApprovals", armvirtualenclaves.ApprovalPatchModel{ + Properties: &armvirtualenclaves.ApprovalPatchProperties{ + ParentResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + GrandparentResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + RequestMetadata: &armvirtualenclaves.RequestMetadataUpdatableProperties{ + ResourceAction: to.Ptr("string"), + ApprovalStatus: to.Ptr(armvirtualenclaves.ApprovalStatusApproved), + ApprovalCallbackRoute: to.Ptr("approvalCallback"), + ApprovalCallbackPayload: to.Ptr("{\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n}"), + }, + Approvers: []*armvirtualenclaves.Approver{ + { + ApproverEntraID: to.Ptr("00000000-0000-0000-0000-000000000000"), + ActionPerformed: to.Ptr(armvirtualenclaves.ActionPerformedApproved), + LastUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t }()), + }, + }, + TicketID: to.Ptr("string"), + CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t }()), + StateChangedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t }()), + }, + }, 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 = armvirtualenclaves.ApprovalClientUpdateResponse{ + // ApprovalResource: &armvirtualenclaves.ApprovalResource{ + // Properties: &armvirtualenclaves.ApprovalProperties{ + // ParentResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // GrandparentResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // RequestMetadata: &armvirtualenclaves.RequestMetadata{ + // ResourceAction: to.Ptr("string"), + // ApprovalStatus: to.Ptr(armvirtualenclaves.ApprovalStatusApproved), + // ApprovalCallbackRoute: to.Ptr("approvalCallback"), + // ApprovalCallbackPayload: to.Ptr("{\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n}"), + // }, + // Approvers: []*armvirtualenclaves.Approver{ + // { + // ApproverEntraID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // ActionPerformed: to.Ptr(armvirtualenclaves.ActionPerformedApproved), + // LastUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // TicketID: to.Ptr("string"), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // StateChangedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/approvals/TestApprovals"), + // Name: to.Ptr("TestApprovals"), + // Type: to.Ptr("Microsoft.Mission/approvals"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/ci.yml b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/ci.yml new file mode 100644 index 000000000000..b18ee125c84b --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/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/virtualenclaves/armvirtualenclaves/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/virtualenclaves/armvirtualenclaves/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/virtualenclaves/armvirtualenclaves' diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/client_factory.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/client_factory.go new file mode 100644 index 000000000000..cf4272e682aa --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/client_factory.go @@ -0,0 +1,103 @@ +// 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 armvirtualenclaves + +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 +} + +// NewApprovalClient creates a new instance of ApprovalClient. +func (c *ClientFactory) NewApprovalClient() *ApprovalClient { + return &ApprovalClient{ + internal: c.internal, + } +} + +// NewCommunityClient creates a new instance of CommunityClient. +func (c *ClientFactory) NewCommunityClient() *CommunityClient { + return &CommunityClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewCommunityEndpointsClient creates a new instance of CommunityEndpointsClient. +func (c *ClientFactory) NewCommunityEndpointsClient() *CommunityEndpointsClient { + return &CommunityEndpointsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewEnclaveConnectionClient creates a new instance of EnclaveConnectionClient. +func (c *ClientFactory) NewEnclaveConnectionClient() *EnclaveConnectionClient { + return &EnclaveConnectionClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewEnclaveEndpointsClient creates a new instance of EnclaveEndpointsClient. +func (c *ClientFactory) NewEnclaveEndpointsClient() *EnclaveEndpointsClient { + return &EnclaveEndpointsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} + +// NewTransitHubClient creates a new instance of TransitHubClient. +func (c *ClientFactory) NewTransitHubClient() *TransitHubClient { + return &TransitHubClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewVirtualEnclaveClient creates a new instance of VirtualEnclaveClient. +func (c *ClientFactory) NewVirtualEnclaveClient() *VirtualEnclaveClient { + return &VirtualEnclaveClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewWorkloadClient creates a new instance of WorkloadClient. +func (c *ClientFactory) NewWorkloadClient() *WorkloadClient { + return &WorkloadClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/community_client.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/community_client.go new file mode 100644 index 000000000000..407454d89772 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/community_client.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 armvirtualenclaves + +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" +) + +// CommunityClient - Community Interface +// Don't use this type directly, use NewCommunityClient() instead. +type CommunityClient struct { + internal *arm.Client + subscriptionID string +} + +// NewCommunityClient creates a new instance of CommunityClient 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 NewCommunityClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CommunityClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &CommunityClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CheckAddressSpaceAvailability - Checks that the IP Address Space to be allocated for this Community is available. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - checkAddressSpaceAvailabilityRequest - Check IP Address Space request body. +// - options - CommunityClientCheckAddressSpaceAvailabilityOptions contains the optional parameters for the CommunityClient.CheckAddressSpaceAvailability +// method. +func (client *CommunityClient) CheckAddressSpaceAvailability(ctx context.Context, resourceGroupName string, communityName string, checkAddressSpaceAvailabilityRequest CheckAddressSpaceAvailabilityRequest, options *CommunityClientCheckAddressSpaceAvailabilityOptions) (CommunityClientCheckAddressSpaceAvailabilityResponse, error) { + var err error + const operationName = "CommunityClient.CheckAddressSpaceAvailability" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkAddressSpaceAvailabilityCreateRequest(ctx, resourceGroupName, communityName, checkAddressSpaceAvailabilityRequest, options) + if err != nil { + return CommunityClientCheckAddressSpaceAvailabilityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CommunityClientCheckAddressSpaceAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CommunityClientCheckAddressSpaceAvailabilityResponse{}, err + } + resp, err := client.checkAddressSpaceAvailabilityHandleResponse(httpResp) + return resp, err +} + +// checkAddressSpaceAvailabilityCreateRequest creates the CheckAddressSpaceAvailability request. +func (client *CommunityClient) checkAddressSpaceAvailabilityCreateRequest(ctx context.Context, resourceGroupName string, communityName string, checkAddressSpaceAvailabilityRequest CheckAddressSpaceAvailabilityRequest, _ *CommunityClientCheckAddressSpaceAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/checkAddressSpaceAvailability" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + 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-05-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, checkAddressSpaceAvailabilityRequest); err != nil { + return nil, err + } + return req, nil +} + +// checkAddressSpaceAvailabilityHandleResponse handles the CheckAddressSpaceAvailability response. +func (client *CommunityClient) checkAddressSpaceAvailabilityHandleResponse(resp *http.Response) (CommunityClientCheckAddressSpaceAvailabilityResponse, error) { + result := CommunityClientCheckAddressSpaceAvailabilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckAddressSpaceAvailabilityResponse); err != nil { + return CommunityClientCheckAddressSpaceAvailabilityResponse{}, err + } + return result, nil +} + +// BeginCreateOrUpdate - Create a CommunityResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - resource - Resource create parameters. +// - options - CommunityClientBeginCreateOrUpdateOptions contains the optional parameters for the CommunityClient.BeginCreateOrUpdate +// method. +func (client *CommunityClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, communityName string, resource CommunityResource, options *CommunityClientBeginCreateOrUpdateOptions) (*runtime.Poller[CommunityClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, communityName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommunityClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CommunityClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a CommunityResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *CommunityClient) createOrUpdate(ctx context.Context, resourceGroupName string, communityName string, resource CommunityResource, options *CommunityClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "CommunityClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, communityName, 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 +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CommunityClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, communityName string, resource CommunityResource, _ *CommunityClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + 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-05-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 CommunityResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - options - CommunityClientBeginDeleteOptions contains the optional parameters for the CommunityClient.BeginDelete method. +func (client *CommunityClient) BeginDelete(ctx context.Context, resourceGroupName string, communityName string, options *CommunityClientBeginDeleteOptions) (*runtime.Poller[CommunityClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, communityName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommunityClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CommunityClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a CommunityResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *CommunityClient) deleteOperation(ctx context.Context, resourceGroupName string, communityName string, options *CommunityClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "CommunityClient.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, communityName, 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 *CommunityClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, communityName string, _ *CommunityClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Get a CommunityResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - options - CommunityClientGetOptions contains the optional parameters for the CommunityClient.Get method. +func (client *CommunityClient) Get(ctx context.Context, resourceGroupName string, communityName string, options *CommunityClientGetOptions) (CommunityClientGetResponse, error) { + var err error + const operationName = "CommunityClient.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, communityName, options) + if err != nil { + return CommunityClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CommunityClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CommunityClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *CommunityClient) getCreateRequest(ctx context.Context, resourceGroupName string, communityName string, _ *CommunityClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + 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-05-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 *CommunityClient) getHandleResponse(resp *http.Response) (CommunityClientGetResponse, error) { + result := CommunityClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CommunityResource); err != nil { + return CommunityClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List CommunityResource resources by resource group +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - CommunityClientListByResourceGroupOptions contains the optional parameters for the CommunityClient.NewListByResourceGroupPager +// method. +func (client *CommunityClient) NewListByResourceGroupPager(resourceGroupName string, options *CommunityClientListByResourceGroupOptions) *runtime.Pager[CommunityClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[CommunityClientListByResourceGroupResponse]{ + More: func(page CommunityClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CommunityClientListByResourceGroupResponse) (CommunityClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CommunityClient.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 CommunityClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *CommunityClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *CommunityClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities" + 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-05-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 *CommunityClient) listByResourceGroupHandleResponse(resp *http.Response) (CommunityClientListByResourceGroupResponse, error) { + result := CommunityClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CommunityResourceListResult); err != nil { + return CommunityClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List CommunityResource resources by subscription ID +// +// Generated from API version 2025-05-01-preview +// - options - CommunityClientListBySubscriptionOptions contains the optional parameters for the CommunityClient.NewListBySubscriptionPager +// method. +func (client *CommunityClient) NewListBySubscriptionPager(options *CommunityClientListBySubscriptionOptions) *runtime.Pager[CommunityClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[CommunityClientListBySubscriptionResponse]{ + More: func(page CommunityClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CommunityClientListBySubscriptionResponse) (CommunityClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CommunityClient.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 CommunityClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *CommunityClient) listBySubscriptionCreateRequest(ctx context.Context, _ *CommunityClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities" + 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-05-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 *CommunityClient) listBySubscriptionHandleResponse(resp *http.Response) (CommunityClientListBySubscriptionResponse, error) { + result := CommunityClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CommunityResourceListResult); err != nil { + return CommunityClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a CommunityResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - properties - The resource properties to be updated. +// - options - CommunityClientBeginUpdateOptions contains the optional parameters for the CommunityClient.BeginUpdate method. +func (client *CommunityClient) BeginUpdate(ctx context.Context, resourceGroupName string, communityName string, properties CommunityPatchModel, options *CommunityClientBeginUpdateOptions) (*runtime.Poller[CommunityClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, communityName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommunityClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CommunityClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a CommunityResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *CommunityClient) update(ctx context.Context, resourceGroupName string, communityName string, properties CommunityPatchModel, options *CommunityClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "CommunityClient.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, communityName, 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 *CommunityClient) updateCreateRequest(ctx context.Context, resourceGroupName string, communityName string, properties CommunityPatchModel, _ *CommunityClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + 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-05-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/virtualenclaves/armvirtualenclaves/community_client_example_test.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/community_client_example_test.go new file mode 100644 index 000000000000..933868db059a --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/community_client_example_test.go @@ -0,0 +1,1595 @@ +// 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 armvirtualenclaves_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/virtualenclaves/armvirtualenclaves" + "log" +) + +// Generated from example definition: 2025-05-01-preview/Community_PostCheckAddressSpaceAvailability.json +func ExampleCommunityClient_CheckAddressSpaceAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCommunityClient().CheckAddressSpaceAvailability(ctx, "rgopenapi", "TestMyCommunity", armvirtualenclaves.CheckAddressSpaceAvailabilityRequest{ + CommunityResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/communities/TestMyCommunity"), + EnclaveVirtualNetwork: &armvirtualenclaves.EnclaveVirtualNetworkModel{ + NetworkSize: to.Ptr("small"), + CustomCidrRange: to.Ptr("10.0.0.0/24"), + SubnetConfigurations: []*armvirtualenclaves.SubnetConfiguration{ + { + SubnetName: to.Ptr("test"), + NetworkPrefixSize: to.Ptr[int32](26), + }, + }, + AllowSubnetCommunication: to.Ptr(true), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armvirtualenclaves.CommunityClientCheckAddressSpaceAvailabilityResponse{ + // CheckAddressSpaceAvailabilityResponse: &armvirtualenclaves.CheckAddressSpaceAvailabilityResponse{ + // Value: to.Ptr(true), + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/Community_CreateOrUpdate.json +func ExampleCommunityClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCommunityClient().BeginCreateOrUpdate(ctx, "rgopenapi", "TestMyCommunity", armvirtualenclaves.CommunityResource{ + Identity: &armvirtualenclaves.ManagedServiceIdentity{ + Type: to.Ptr(armvirtualenclaves.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + UserAssignedIdentities: map[string]*armvirtualenclaves.UserAssignedIdentity{ + "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, + }, + }, + Properties: &armvirtualenclaves.CommunityProperties{ + AddressSpace: to.Ptr("10.0.0.0/24"), + DNSServers: []*string{ + to.Ptr("azure.net"), + }, + GovernedServiceList: []*armvirtualenclaves.GovernedServiceItem{ + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAKS), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAppService), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierContainerRegistry), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierCosmosDB), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierKeyVault), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMicrosoftSQL), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMonitoring), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOption("Not Applicable")), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPostgreSQL), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierServiceBus), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierStorage), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAzureFirewalls), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierInsights), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierLogic), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPrivateDNSZones), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierDataConnectors), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + }, + CommunityRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + { + RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + }, + { + ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + }, + }, + }, + { + RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + }, + }, + }, + }, + ApprovalSettings: &armvirtualenclaves.ApprovalSettings{ + EndpointCreation: to.Ptr(armvirtualenclaves.ApprovalPolicyNotRequired), + EndpointUpdate: to.Ptr(armvirtualenclaves.ApprovalPolicyRequired), + EndpointDeletion: to.Ptr(armvirtualenclaves.ApprovalPolicyNotRequired), + ConnectionCreation: to.Ptr(armvirtualenclaves.ApprovalPolicyRequired), + ConnectionUpdate: to.Ptr(armvirtualenclaves.ApprovalPolicyRequired), + ConnectionDeletion: to.Ptr(armvirtualenclaves.ApprovalPolicyNotRequired), + EnclaveCreation: to.Ptr(armvirtualenclaves.ApprovalPolicyNotRequired), + EnclaveDeletion: to.Ptr(armvirtualenclaves.ApprovalPolicyNotRequired), + MaintenanceMode: to.Ptr(armvirtualenclaves.ApprovalPolicyNotRequired), + ServiceCatalogDeployment: to.Ptr(armvirtualenclaves.ApprovalPolicyNotRequired), + NotificationOnApprovalCreation: to.Ptr(armvirtualenclaves.ApprovalPolicyNotRequired), + NotificationOnApprovalAction: to.Ptr(armvirtualenclaves.ApprovalPolicyNotRequired), + NotificationOnApprovalDeletion: to.Ptr(armvirtualenclaves.ApprovalPolicyNotRequired), + MandatoryApprovers: []*armvirtualenclaves.MandatoryApprover{ + { + ApproverEntraID: to.Ptr("00000000-0000-0000-0000-000000000000"), + }, + }, + MinimumApproversRequired: to.Ptr[int64](0), + }, + MaintenanceModeConfiguration: &armvirtualenclaves.MaintenanceModeConfigurationModel{ + Mode: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelModeOff), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + }, + }, + Justification: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelJustificationOff), + }, + FirewallSKU: to.Ptr(armvirtualenclaves.FirewallSKUStandard), + }, + Tags: map[string]*string{ + "sampletag": to.Ptr("samplevalue"), + }, + Location: to.Ptr("westcentralus"), + }, 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 = armvirtualenclaves.CommunityClientCreateOrUpdateResponse{ + // CommunityResource: &armvirtualenclaves.CommunityResource{ + // Identity: &armvirtualenclaves.ManagedServiceIdentity{ + // Type: to.Ptr(armvirtualenclaves.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + // PrincipalID: to.Ptr("1a2e532b-9900-414c-8600-cfc6126628d7"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), + // UserAssignedIdentities: map[string]*armvirtualenclaves.UserAssignedIdentity{ + // "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armvirtualenclaves.UserAssignedIdentity{ + // PrincipalID: to.Ptr("f4aa4954-a564-4933-a7e1-502019d807c2"), + // ClientID: to.Ptr("b82bf757-ee7f-4632-9df1-5e52a720fdd2"), + // }, + // }, + // }, + // Properties: &armvirtualenclaves.CommunityProperties{ + // AddressSpace: to.Ptr("10.0.0.0/24"), + // DNSServers: []*string{ + // to.Ptr("azure.net"), + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // GovernedServiceList: []*armvirtualenclaves.GovernedServiceItem{ + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAKS), + // ServiceName: to.Ptr("AKS"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("d300338e-65d1-4be3-b18e-fb4ce5715a8f"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAppService), + // ServiceName: to.Ptr("App Service"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("528d78c5-246c-4f26-ade6-d30798705411"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierContainerRegistry), + // ServiceName: to.Ptr("Container Registry"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("b3fe25eb-cdc6-475f-96a5-04ac270f630d"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierCosmosDB), + // ServiceName: to.Ptr("CosmosDB"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("6bd484ca-ae8d-46cf-9b33-e1feef84bfba"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierKeyVault), + // ServiceName: to.Ptr("Key Vault"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("4f4dba0f-a5ee-494b-8df7-f9727dea6f37"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMicrosoftSQL), + // ServiceName: to.Ptr("Microsoft SQL"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("0fbe78a5-1722-4f1b-83a5-89c14151fa60"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMonitoring), + // ServiceName: to.Ptr("Monitoring"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOption("Not Applicable")), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("0a9ea1cb-7925-47fc-b0fe-8bb0a8190423"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPostgreSQL), + // ServiceName: to.Ptr("PostgreSQL"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("5eaa16b4-81f2-4354-aef3-2d77288e396e"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierServiceBus), + // ServiceName: to.Ptr("Service Bus"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("8fcdb3f1-1369-426d-9917-81edfee903ab"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierStorage), + // ServiceName: to.Ptr("Storage"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("ca122c06-05f6-4423-9018-ccb523168eb2"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAzureFirewalls), + // ServiceName: to.Ptr("Azure Firewalls"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierInsights), + // ServiceName: to.Ptr("Insights"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierLogic), + // ServiceName: to.Ptr("Logic"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPrivateDNSZones), + // ServiceName: to.Ptr("Private DNS Zones"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierDataConnectors), + // ServiceName: to.Ptr("Data Connectors"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // }, + // CommunityRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // }, + // MaintenanceModeConfiguration: &armvirtualenclaves.MaintenanceModeConfigurationModel{ + // Mode: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelModeOff), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // Justification: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelJustificationOff), + // }, + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // Name: to.Ptr("TestMyCommunity"), + // Type: to.Ptr("Microsoft.Mission/communities"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/Community_Delete.json +func ExampleCommunityClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCommunityClient().BeginDelete(ctx, "rgopenapi", "TestMyCommunity", 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-05-01-preview/Community_Get.json +func ExampleCommunityClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCommunityClient().Get(ctx, "rgopenapi", "TestMyCommunity", 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 = armvirtualenclaves.CommunityClientGetResponse{ + // CommunityResource: &armvirtualenclaves.CommunityResource{ + // Identity: &armvirtualenclaves.ManagedServiceIdentity{ + // Type: to.Ptr(armvirtualenclaves.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + // PrincipalID: to.Ptr("1a2e532b-9900-414c-8600-cfc6126628d7"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), + // UserAssignedIdentities: map[string]*armvirtualenclaves.UserAssignedIdentity{ + // "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armvirtualenclaves.UserAssignedIdentity{ + // PrincipalID: to.Ptr("f4aa4954-a564-4933-a7e1-502019d807c2"), + // ClientID: to.Ptr("b82bf757-ee7f-4632-9df1-5e52a720fdd2"), + // }, + // }, + // }, + // Properties: &armvirtualenclaves.CommunityProperties{ + // AddressSpace: to.Ptr("10.0.0.0/24"), + // DNSServers: []*string{ + // to.Ptr("azure.net"), + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // ManagedOnBehalfOfConfiguration: &armvirtualenclaves.ManagedOnBehalfOfConfiguration{ + // MoboBrokerResources: []*armvirtualenclaves.MoboBrokerResource{ + // { + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Resources/moboBrokers/bnthrkwfkfeorrzvtdxbfz"), + // }, + // }, + // }, + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // GovernedServiceList: []*armvirtualenclaves.GovernedServiceItem{ + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAKS), + // ServiceName: to.Ptr("AKS"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("d300338e-65d1-4be3-b18e-fb4ce5715a8f"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAppService), + // ServiceName: to.Ptr("App Service"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("528d78c5-246c-4f26-ade6-d30798705411"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierContainerRegistry), + // ServiceName: to.Ptr("Container Registry"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("b3fe25eb-cdc6-475f-96a5-04ac270f630d"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierCosmosDB), + // ServiceName: to.Ptr("CosmosDB"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("6bd484ca-ae8d-46cf-9b33-e1feef84bfba"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierKeyVault), + // ServiceName: to.Ptr("Key Vault"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("4f4dba0f-a5ee-494b-8df7-f9727dea6f37"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMicrosoftSQL), + // ServiceName: to.Ptr("Microsoft SQL"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("0fbe78a5-1722-4f1b-83a5-89c14151fa60"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMonitoring), + // ServiceName: to.Ptr("Monitoring"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOption("Not Applicable")), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("0a9ea1cb-7925-47fc-b0fe-8bb0a8190423"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPostgreSQL), + // ServiceName: to.Ptr("PostgreSQL"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("5eaa16b4-81f2-4354-aef3-2d77288e396e"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierServiceBus), + // ServiceName: to.Ptr("Service Bus"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("8fcdb3f1-1369-426d-9917-81edfee903ab"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierStorage), + // ServiceName: to.Ptr("Storage"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("ca122c06-05f6-4423-9018-ccb523168eb2"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAzureFirewalls), + // ServiceName: to.Ptr("Azure Firewalls"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierInsights), + // ServiceName: to.Ptr("Insights"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierLogic), + // ServiceName: to.Ptr("Logic"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPrivateDNSZones), + // ServiceName: to.Ptr("Private DNS Zones"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierDataConnectors), + // ServiceName: to.Ptr("Data Connectors"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // }, + // CommunityRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // }, + // MaintenanceModeConfiguration: &armvirtualenclaves.MaintenanceModeConfigurationModel{ + // Mode: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelModeOff), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // Justification: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelJustificationOff), + // }, + // FirewallSKU: to.Ptr(armvirtualenclaves.FirewallSKUStandard), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // Name: to.Ptr("TestMyCommunity"), + // Type: to.Ptr("Microsoft.Mission/communities"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/Community_ListByResourceGroup.json +func ExampleCommunityClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCommunityClient().NewListByResourceGroupPager("rgopenapi", 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 = armvirtualenclaves.CommunityClientListByResourceGroupResponse{ + // CommunityResourceListResult: armvirtualenclaves.CommunityResourceListResult{ + // Value: []*armvirtualenclaves.CommunityResource{ + // { + // Identity: &armvirtualenclaves.ManagedServiceIdentity{ + // Type: to.Ptr(armvirtualenclaves.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + // PrincipalID: to.Ptr("1a2e532b-9900-414c-8600-cfc6126628d7"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), + // UserAssignedIdentities: map[string]*armvirtualenclaves.UserAssignedIdentity{ + // "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armvirtualenclaves.UserAssignedIdentity{ + // PrincipalID: to.Ptr("f4aa4954-a564-4933-a7e1-502019d807c2"), + // ClientID: to.Ptr("b82bf757-ee7f-4632-9df1-5e52a720fdd2"), + // }, + // }, + // }, + // Properties: &armvirtualenclaves.CommunityProperties{ + // AddressSpace: to.Ptr("10.0.0.0/24"), + // DNSServers: []*string{ + // to.Ptr("azure.net"), + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // GovernedServiceList: []*armvirtualenclaves.GovernedServiceItem{ + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAKS), + // ServiceName: to.Ptr("AKS"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("d300338e-65d1-4be3-b18e-fb4ce5715a8f"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAppService), + // ServiceName: to.Ptr("App Service"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("528d78c5-246c-4f26-ade6-d30798705411"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierContainerRegistry), + // ServiceName: to.Ptr("Container Registry"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("b3fe25eb-cdc6-475f-96a5-04ac270f630d"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierCosmosDB), + // ServiceName: to.Ptr("CosmosDB"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("6bd484ca-ae8d-46cf-9b33-e1feef84bfba"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierKeyVault), + // ServiceName: to.Ptr("Key Vault"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("4f4dba0f-a5ee-494b-8df7-f9727dea6f37"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMicrosoftSQL), + // ServiceName: to.Ptr("Microsoft SQL"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("0fbe78a5-1722-4f1b-83a5-89c14151fa60"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMonitoring), + // ServiceName: to.Ptr("Monitoring"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOption("Not Applicable")), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("0a9ea1cb-7925-47fc-b0fe-8bb0a8190423"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPostgreSQL), + // ServiceName: to.Ptr("PostgreSQL"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("5eaa16b4-81f2-4354-aef3-2d77288e396e"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierServiceBus), + // ServiceName: to.Ptr("Service Bus"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("8fcdb3f1-1369-426d-9917-81edfee903ab"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierStorage), + // ServiceName: to.Ptr("Storage"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("ca122c06-05f6-4423-9018-ccb523168eb2"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAzureFirewalls), + // ServiceName: to.Ptr("Azure Firewalls"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierInsights), + // ServiceName: to.Ptr("Insights"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierLogic), + // ServiceName: to.Ptr("Logic"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPrivateDNSZones), + // ServiceName: to.Ptr("Private DNS Zones"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierDataConnectors), + // ServiceName: to.Ptr("Data Connectors"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // }, + // CommunityRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // }, + // MaintenanceModeConfiguration: &armvirtualenclaves.MaintenanceModeConfigurationModel{ + // Mode: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelModeOff), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // Justification: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelJustificationOff), + // }, + // FirewallSKU: to.Ptr(armvirtualenclaves.FirewallSKUStandard), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // Name: to.Ptr("TestMyCommunity"), + // Type: to.Ptr("Microsoft.Mission/communities"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/Community_ListBySubscription.json +func ExampleCommunityClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCommunityClient().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 = armvirtualenclaves.CommunityClientListBySubscriptionResponse{ + // CommunityResourceListResult: armvirtualenclaves.CommunityResourceListResult{ + // Value: []*armvirtualenclaves.CommunityResource{ + // { + // Identity: &armvirtualenclaves.ManagedServiceIdentity{ + // Type: to.Ptr(armvirtualenclaves.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + // PrincipalID: to.Ptr("1a2e532b-9900-414c-8600-cfc6126628d7"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), + // UserAssignedIdentities: map[string]*armvirtualenclaves.UserAssignedIdentity{ + // "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armvirtualenclaves.UserAssignedIdentity{ + // PrincipalID: to.Ptr("f4aa4954-a564-4933-a7e1-502019d807c2"), + // ClientID: to.Ptr("b82bf757-ee7f-4632-9df1-5e52a720fdd2"), + // }, + // }, + // }, + // Properties: &armvirtualenclaves.CommunityProperties{ + // AddressSpace: to.Ptr("10.0.0.0/24"), + // DNSServers: []*string{ + // to.Ptr("azure.net"), + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // GovernedServiceList: []*armvirtualenclaves.GovernedServiceItem{ + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAKS), + // ServiceName: to.Ptr("AKS"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("d300338e-65d1-4be3-b18e-fb4ce5715a8f"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAppService), + // ServiceName: to.Ptr("App Service"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("528d78c5-246c-4f26-ade6-d30798705411"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierContainerRegistry), + // ServiceName: to.Ptr("Container Registry"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("b3fe25eb-cdc6-475f-96a5-04ac270f630d"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierCosmosDB), + // ServiceName: to.Ptr("CosmosDB"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("6bd484ca-ae8d-46cf-9b33-e1feef84bfba"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierKeyVault), + // ServiceName: to.Ptr("Key Vault"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("4f4dba0f-a5ee-494b-8df7-f9727dea6f37"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMicrosoftSQL), + // ServiceName: to.Ptr("Microsoft SQL"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("0fbe78a5-1722-4f1b-83a5-89c14151fa60"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMonitoring), + // ServiceName: to.Ptr("Monitoring"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOption("Not Applicable")), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("0a9ea1cb-7925-47fc-b0fe-8bb0a8190423"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPostgreSQL), + // ServiceName: to.Ptr("PostgreSQL"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("5eaa16b4-81f2-4354-aef3-2d77288e396e"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierServiceBus), + // ServiceName: to.Ptr("Service Bus"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("8fcdb3f1-1369-426d-9917-81edfee903ab"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierStorage), + // ServiceName: to.Ptr("Storage"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("ca122c06-05f6-4423-9018-ccb523168eb2"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAzureFirewalls), + // ServiceName: to.Ptr("Azure Firewalls"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierInsights), + // ServiceName: to.Ptr("Insights"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierLogic), + // ServiceName: to.Ptr("Logic"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPrivateDNSZones), + // ServiceName: to.Ptr("Private DNS Zones"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierDataConnectors), + // ServiceName: to.Ptr("Data Connectors"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // }, + // CommunityRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // }, + // MaintenanceModeConfiguration: &armvirtualenclaves.MaintenanceModeConfigurationModel{ + // Mode: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelModeOff), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // Justification: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelJustificationOff), + // }, + // FirewallSKU: to.Ptr(armvirtualenclaves.FirewallSKUStandard), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // Name: to.Ptr("TestMyCommunity"), + // Type: to.Ptr("Microsoft.Mission/communities"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/Community_Update.json +func ExampleCommunityClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCommunityClient().BeginUpdate(ctx, "rgopenapi", "TestMyCommunity", armvirtualenclaves.CommunityPatchModel{ + Tags: map[string]*string{ + "sampletag": to.Ptr("samplevalue"), + }, + Properties: &armvirtualenclaves.CommunityPatchProperties{ + DNSServers: []*string{ + to.Ptr("azure.net"), + }, + GovernedServiceList: []*armvirtualenclaves.GovernedServiceItem{ + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAKS), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAppService), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierContainerRegistry), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierCosmosDB), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierKeyVault), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMicrosoftSQL), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMonitoring), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOption("Not Applicable")), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPostgreSQL), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierServiceBus), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierStorage), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAzureFirewalls), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierInsights), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierLogic), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPrivateDNSZones), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + { + ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierDataConnectors), + Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + }, + }, + CommunityRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + { + RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + }, + { + ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + }, + }, + }, + { + RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + }, + }, + }, + }, + }, + }, 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 = armvirtualenclaves.CommunityClientUpdateResponse{ + // CommunityResource: &armvirtualenclaves.CommunityResource{ + // Identity: &armvirtualenclaves.ManagedServiceIdentity{ + // Type: to.Ptr(armvirtualenclaves.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + // PrincipalID: to.Ptr("1a2e532b-9900-414c-8600-cfc6126628d7"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), + // UserAssignedIdentities: map[string]*armvirtualenclaves.UserAssignedIdentity{ + // "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armvirtualenclaves.UserAssignedIdentity{ + // PrincipalID: to.Ptr("f4aa4954-a564-4933-a7e1-502019d807c2"), + // ClientID: to.Ptr("b82bf757-ee7f-4632-9df1-5e52a720fdd2"), + // }, + // }, + // }, + // Properties: &armvirtualenclaves.CommunityProperties{ + // AddressSpace: to.Ptr("10.0.0.0/24"), + // DNSServers: []*string{ + // to.Ptr("azure.net"), + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // GovernedServiceList: []*armvirtualenclaves.GovernedServiceItem{ + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAKS), + // ServiceName: to.Ptr("AKS"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("d300338e-65d1-4be3-b18e-fb4ce5715a8f"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAppService), + // ServiceName: to.Ptr("App Service"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("528d78c5-246c-4f26-ade6-d30798705411"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierContainerRegistry), + // ServiceName: to.Ptr("Container Registry"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("b3fe25eb-cdc6-475f-96a5-04ac270f630d"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierCosmosDB), + // ServiceName: to.Ptr("CosmosDB"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("6bd484ca-ae8d-46cf-9b33-e1feef84bfba"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierKeyVault), + // ServiceName: to.Ptr("Key Vault"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("4f4dba0f-a5ee-494b-8df7-f9727dea6f37"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMicrosoftSQL), + // ServiceName: to.Ptr("Microsoft SQL"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("0fbe78a5-1722-4f1b-83a5-89c14151fa60"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierMonitoring), + // ServiceName: to.Ptr("Monitoring"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOption("Not Applicable")), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("0a9ea1cb-7925-47fc-b0fe-8bb0a8190423"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPostgreSQL), + // ServiceName: to.Ptr("PostgreSQL"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("5eaa16b4-81f2-4354-aef3-2d77288e396e"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierServiceBus), + // ServiceName: to.Ptr("Service Bus"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("8fcdb3f1-1369-426d-9917-81edfee903ab"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierStorage), + // ServiceName: to.Ptr("Storage"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // to.Ptr("ca122c06-05f6-4423-9018-ccb523168eb2"), + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierAzureFirewalls), + // ServiceName: to.Ptr("Azure Firewalls"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierInsights), + // ServiceName: to.Ptr("Insights"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierLogic), + // ServiceName: to.Ptr("Logic"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierPrivateDNSZones), + // ServiceName: to.Ptr("Private DNS Zones"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // { + // ServiceID: to.Ptr(armvirtualenclaves.ServiceIdentifierDataConnectors), + // ServiceName: to.Ptr("Data Connectors"), + // Option: to.Ptr(armvirtualenclaves.GovernedServiceItemOptionAllow), + // Enforcement: to.Ptr(armvirtualenclaves.GovernedServiceItemEnforcementEnabled), + // PolicyAction: to.Ptr(armvirtualenclaves.GovernedServiceItemPolicyActionNone), + // Initiatives: []*string{ + // }, + // }, + // }, + // CommunityRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // Name: to.Ptr("TestMyCommunity"), + // Type: to.Ptr("Microsoft.Mission/communities"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/communityendpoints_client.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/communityendpoints_client.go new file mode 100644 index 000000000000..7b04a7c321af --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/communityendpoints_client.go @@ -0,0 +1,659 @@ +// 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 armvirtualenclaves + +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" +) + +// CommunityEndpointsClient - Community Endpoint Interface +// Don't use this type directly, use NewCommunityEndpointsClient() instead. +type CommunityEndpointsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewCommunityEndpointsClient creates a new instance of CommunityEndpointsClient 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 NewCommunityEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CommunityEndpointsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &CommunityEndpointsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a CommunityEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - communityEndpointName - The name of the Community Endpoint Resource +// - resource - Resource create parameters. +// - options - CommunityEndpointsClientBeginCreateOrUpdateOptions contains the optional parameters for the CommunityEndpointsClient.BeginCreateOrUpdate +// method. +func (client *CommunityEndpointsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, resource CommunityEndpointResource, options *CommunityEndpointsClientBeginCreateOrUpdateOptions) (*runtime.Poller[CommunityEndpointsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, communityName, communityEndpointName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommunityEndpointsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CommunityEndpointsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a CommunityEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *CommunityEndpointsClient) createOrUpdate(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, resource CommunityEndpointResource, options *CommunityEndpointsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "CommunityEndpointsClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, communityName, communityEndpointName, 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 +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CommunityEndpointsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, resource CommunityEndpointResource, _ *CommunityEndpointsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName}" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + if communityEndpointName == "" { + return nil, errors.New("parameter communityEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityEndpointName}", url.PathEscape(communityEndpointName)) + 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-05-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 CommunityEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - communityEndpointName - The name of the Community Endpoint Resource +// - options - CommunityEndpointsClientBeginDeleteOptions contains the optional parameters for the CommunityEndpointsClient.BeginDelete +// method. +func (client *CommunityEndpointsClient) BeginDelete(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, options *CommunityEndpointsClientBeginDeleteOptions) (*runtime.Poller[CommunityEndpointsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, communityName, communityEndpointName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommunityEndpointsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CommunityEndpointsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a CommunityEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *CommunityEndpointsClient) deleteOperation(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, options *CommunityEndpointsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "CommunityEndpointsClient.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, communityName, communityEndpointName, 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 *CommunityEndpointsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, _ *CommunityEndpointsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName}" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + if communityEndpointName == "" { + return nil, errors.New("parameter communityEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityEndpointName}", url.PathEscape(communityEndpointName)) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Get a CommunityEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - communityEndpointName - The name of the Community Endpoint Resource +// - options - CommunityEndpointsClientGetOptions contains the optional parameters for the CommunityEndpointsClient.Get method. +func (client *CommunityEndpointsClient) Get(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, options *CommunityEndpointsClientGetOptions) (CommunityEndpointsClientGetResponse, error) { + var err error + const operationName = "CommunityEndpointsClient.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, communityName, communityEndpointName, options) + if err != nil { + return CommunityEndpointsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CommunityEndpointsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CommunityEndpointsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *CommunityEndpointsClient) getCreateRequest(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, _ *CommunityEndpointsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName}" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + if communityEndpointName == "" { + return nil, errors.New("parameter communityEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityEndpointName}", url.PathEscape(communityEndpointName)) + 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-05-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 *CommunityEndpointsClient) getHandleResponse(resp *http.Response) (CommunityEndpointsClientGetResponse, error) { + result := CommunityEndpointsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CommunityEndpointResource); err != nil { + return CommunityEndpointsClientGetResponse{}, err + } + return result, nil +} + +// BeginHandleApprovalCreation - Callback that triggers on approval state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - communityEndpointName - The name of the Community Endpoint Resource +// - body - The content of the action request +// - options - CommunityEndpointsClientBeginHandleApprovalCreationOptions contains the optional parameters for the CommunityEndpointsClient.BeginHandleApprovalCreation +// method. +func (client *CommunityEndpointsClient) BeginHandleApprovalCreation(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, body ApprovalCallbackRequest, options *CommunityEndpointsClientBeginHandleApprovalCreationOptions) (*runtime.Poller[CommunityEndpointsClientHandleApprovalCreationResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.handleApprovalCreation(ctx, resourceGroupName, communityName, communityEndpointName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommunityEndpointsClientHandleApprovalCreationResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CommunityEndpointsClientHandleApprovalCreationResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// HandleApprovalCreation - Callback that triggers on approval state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *CommunityEndpointsClient) handleApprovalCreation(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, body ApprovalCallbackRequest, options *CommunityEndpointsClientBeginHandleApprovalCreationOptions) (*http.Response, error) { + var err error + const operationName = "CommunityEndpointsClient.BeginHandleApprovalCreation" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.handleApprovalCreationCreateRequest(ctx, resourceGroupName, communityName, communityEndpointName, 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 +} + +// handleApprovalCreationCreateRequest creates the HandleApprovalCreation request. +func (client *CommunityEndpointsClient) handleApprovalCreationCreateRequest(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, body ApprovalCallbackRequest, _ *CommunityEndpointsClientBeginHandleApprovalCreationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName}/handleApprovalCreation" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + if communityEndpointName == "" { + return nil, errors.New("parameter communityEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityEndpointName}", url.PathEscape(communityEndpointName)) + 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-05-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 +} + +// BeginHandleApprovalDeletion - Callback that triggers on approval deletion state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - communityEndpointName - The name of the Community Endpoint Resource +// - body - The content of the action request +// - options - CommunityEndpointsClientBeginHandleApprovalDeletionOptions contains the optional parameters for the CommunityEndpointsClient.BeginHandleApprovalDeletion +// method. +func (client *CommunityEndpointsClient) BeginHandleApprovalDeletion(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, body ApprovalDeletionCallbackRequest, options *CommunityEndpointsClientBeginHandleApprovalDeletionOptions) (*runtime.Poller[CommunityEndpointsClientHandleApprovalDeletionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.handleApprovalDeletion(ctx, resourceGroupName, communityName, communityEndpointName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommunityEndpointsClientHandleApprovalDeletionResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CommunityEndpointsClientHandleApprovalDeletionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// HandleApprovalDeletion - Callback that triggers on approval deletion state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *CommunityEndpointsClient) handleApprovalDeletion(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, body ApprovalDeletionCallbackRequest, options *CommunityEndpointsClientBeginHandleApprovalDeletionOptions) (*http.Response, error) { + var err error + const operationName = "CommunityEndpointsClient.BeginHandleApprovalDeletion" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.handleApprovalDeletionCreateRequest(ctx, resourceGroupName, communityName, communityEndpointName, 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 +} + +// handleApprovalDeletionCreateRequest creates the HandleApprovalDeletion request. +func (client *CommunityEndpointsClient) handleApprovalDeletionCreateRequest(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, body ApprovalDeletionCallbackRequest, _ *CommunityEndpointsClientBeginHandleApprovalDeletionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName}/handleApprovalDeletion" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + if communityEndpointName == "" { + return nil, errors.New("parameter communityEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityEndpointName}", url.PathEscape(communityEndpointName)) + 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-05-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 +} + +// NewListByCommunityResourcePager - List CommunityEndpointResource resources by CommunityResource +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - options - CommunityEndpointsClientListByCommunityResourceOptions contains the optional parameters for the CommunityEndpointsClient.NewListByCommunityResourcePager +// method. +func (client *CommunityEndpointsClient) NewListByCommunityResourcePager(resourceGroupName string, communityName string, options *CommunityEndpointsClientListByCommunityResourceOptions) *runtime.Pager[CommunityEndpointsClientListByCommunityResourceResponse] { + return runtime.NewPager(runtime.PagingHandler[CommunityEndpointsClientListByCommunityResourceResponse]{ + More: func(page CommunityEndpointsClientListByCommunityResourceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CommunityEndpointsClientListByCommunityResourceResponse) (CommunityEndpointsClientListByCommunityResourceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CommunityEndpointsClient.NewListByCommunityResourcePager") + 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.listByCommunityResourceCreateRequest(ctx, resourceGroupName, communityName, options) + }, nil) + if err != nil { + return CommunityEndpointsClientListByCommunityResourceResponse{}, err + } + return client.listByCommunityResourceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByCommunityResourceCreateRequest creates the ListByCommunityResource request. +func (client *CommunityEndpointsClient) listByCommunityResourceCreateRequest(ctx context.Context, resourceGroupName string, communityName string, _ *CommunityEndpointsClientListByCommunityResourceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByCommunityResourceHandleResponse handles the ListByCommunityResource response. +func (client *CommunityEndpointsClient) listByCommunityResourceHandleResponse(resp *http.Response) (CommunityEndpointsClientListByCommunityResourceResponse, error) { + result := CommunityEndpointsClientListByCommunityResourceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CommunityEndpointResourceListResult); err != nil { + return CommunityEndpointsClientListByCommunityResourceResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List CommunityEndpointResource resources by subscription ID +// +// Generated from API version 2025-05-01-preview +// - communityName - The name of the communityResource Resource +// - options - CommunityEndpointsClientListBySubscriptionOptions contains the optional parameters for the CommunityEndpointsClient.NewListBySubscriptionPager +// method. +func (client *CommunityEndpointsClient) NewListBySubscriptionPager(communityName string, options *CommunityEndpointsClientListBySubscriptionOptions) *runtime.Pager[CommunityEndpointsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[CommunityEndpointsClientListBySubscriptionResponse]{ + More: func(page CommunityEndpointsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CommunityEndpointsClientListBySubscriptionResponse) (CommunityEndpointsClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CommunityEndpointsClient.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, communityName, options) + }, nil) + if err != nil { + return CommunityEndpointsClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *CommunityEndpointsClient) listBySubscriptionCreateRequest(ctx context.Context, communityName string, _ *CommunityEndpointsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + 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-05-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 *CommunityEndpointsClient) listBySubscriptionHandleResponse(resp *http.Response) (CommunityEndpointsClientListBySubscriptionResponse, error) { + result := CommunityEndpointsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CommunityEndpointResourceListResult); err != nil { + return CommunityEndpointsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a CommunityEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - communityEndpointName - The name of the Community Endpoint Resource +// - properties - The resource properties to be updated. +// - options - CommunityEndpointsClientBeginUpdateOptions contains the optional parameters for the CommunityEndpointsClient.BeginUpdate +// method. +func (client *CommunityEndpointsClient) BeginUpdate(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, properties CommunityEndpointPatchModel, options *CommunityEndpointsClientBeginUpdateOptions) (*runtime.Poller[CommunityEndpointsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, communityName, communityEndpointName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CommunityEndpointsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[CommunityEndpointsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a CommunityEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *CommunityEndpointsClient) update(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, properties CommunityEndpointPatchModel, options *CommunityEndpointsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "CommunityEndpointsClient.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, communityName, communityEndpointName, 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 *CommunityEndpointsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, properties CommunityEndpointPatchModel, _ *CommunityEndpointsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/communityEndpoints/{communityEndpointName}" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + if communityEndpointName == "" { + return nil, errors.New("parameter communityEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityEndpointName}", url.PathEscape(communityEndpointName)) + 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-05-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/virtualenclaves/armvirtualenclaves/communityendpoints_client_example_test.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/communityendpoints_client_example_test.go new file mode 100644 index 000000000000..4c86ee6db18e --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/communityendpoints_client_example_test.go @@ -0,0 +1,425 @@ +// 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 armvirtualenclaves_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/virtualenclaves/armvirtualenclaves" + "log" +) + +// Generated from example definition: 2025-05-01-preview/CommunityEndpoints_CreateOrUpdate.json +func ExampleCommunityEndpointsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCommunityEndpointsClient().BeginCreateOrUpdate(ctx, "rgopenapi", "TestMyCommunity", "TestMyCommunityEndpoint", armvirtualenclaves.CommunityEndpointResource{ + Properties: &armvirtualenclaves.CommunityEndpointProperties{ + RuleCollection: []*armvirtualenclaves.CommunityEndpointDestinationRule{ + { + DestinationType: to.Ptr(armvirtualenclaves.DestinationTypeFQDNTag), + Destination: to.Ptr("foo.example.com"), + Ports: to.Ptr("443"), + Protocols: []*armvirtualenclaves.CommunityEndpointProtocol{ + to.Ptr(armvirtualenclaves.CommunityEndpointProtocolTCP), + }, + TransitHubResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), + }, + }, + }, + Tags: map[string]*string{ + "sampletag": to.Ptr("samplevalue"), + }, + Location: to.Ptr("West US"), + }, 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 = armvirtualenclaves.CommunityEndpointsClientCreateOrUpdateResponse{ + // CommunityEndpointResource: &armvirtualenclaves.CommunityEndpointResource{ + // Properties: &armvirtualenclaves.CommunityEndpointProperties{ + // RuleCollection: []*armvirtualenclaves.CommunityEndpointDestinationRule{ + // { + // DestinationType: to.Ptr(armvirtualenclaves.DestinationTypeFQDNTag), + // Destination: to.Ptr("foo.example.com"), + // Ports: to.Ptr("443"), + // Protocols: []*armvirtualenclaves.CommunityEndpointProtocol{ + // to.Ptr(armvirtualenclaves.CommunityEndpointProtocolTCP), + // }, + // TransitHubResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), + // }, + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/communities/TestMyCommunity/communityendpoints/TestMyCommunityEndpoint"), + // Name: to.Ptr("TestMyCommunityEndpoint"), + // Type: to.Ptr("Microsoft.Mission/communties/communityendpoints"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/CommunityEndpoints_Delete.json +func ExampleCommunityEndpointsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCommunityEndpointsClient().BeginDelete(ctx, "rgopenapi", "TestMyCommunity", "TestMyCommunityEndpoint", 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-05-01-preview/CommunityEndpoints_Get.json +func ExampleCommunityEndpointsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCommunityEndpointsClient().Get(ctx, "rgopenapi", "TestMyCommunity", "TestMyCommunityEndpoint", 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 = armvirtualenclaves.CommunityEndpointsClientGetResponse{ + // CommunityEndpointResource: &armvirtualenclaves.CommunityEndpointResource{ + // Properties: &armvirtualenclaves.CommunityEndpointProperties{ + // RuleCollection: []*armvirtualenclaves.CommunityEndpointDestinationRule{ + // { + // DestinationType: to.Ptr(armvirtualenclaves.DestinationTypeFQDN), + // Destination: to.Ptr("foo.example.com"), + // Ports: to.Ptr("443"), + // Protocols: []*armvirtualenclaves.CommunityEndpointProtocol{ + // to.Ptr(armvirtualenclaves.CommunityEndpointProtocolTCP), + // }, + // TransitHubResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), + // }, + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/communities/TestMyCommunity/communityendpoints/TestMyCommunityEndpoint"), + // Name: to.Ptr("TestMyCommunityEndpoint"), + // Type: to.Ptr("Microsoft.Mission/communities/communityendpoints"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/CommunityEndpoints_HandleApprovalCreation.json +func ExampleCommunityEndpointsClient_BeginHandleApprovalCreation() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCommunityEndpointsClient().BeginHandleApprovalCreation(ctx, "rgopenapi", "TestMyCommunity", "TestMyCommunityEndpoint", armvirtualenclaves.ApprovalCallbackRequest{ + ResourceRequestAction: to.Ptr(armvirtualenclaves.ApprovalCallbackRequestResourceRequestActionCreate), + ApprovalStatus: to.Ptr(armvirtualenclaves.ApprovalCallbackRequestApprovalStatusApproved), + }, 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 = armvirtualenclaves.CommunityEndpointsClientHandleApprovalCreationResponse{ + // ApprovalActionResponse: &armvirtualenclaves.ApprovalActionResponse{ + // Message: to.Ptr("Approval state change handled successfully."), + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/CommunityEndpoints_HandleApprovalDeletion.json +func ExampleCommunityEndpointsClient_BeginHandleApprovalDeletion() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCommunityEndpointsClient().BeginHandleApprovalDeletion(ctx, "rgopenapi", "TestMyCommunity", "TestMyCommunityEndpoint", armvirtualenclaves.ApprovalDeletionCallbackRequest{ + ResourceRequestAction: to.Ptr(armvirtualenclaves.ApprovalDeletionCallbackRequestResourceRequestActionCreate), + }, 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 = armvirtualenclaves.CommunityEndpointsClientHandleApprovalDeletionResponse{ + // ApprovalActionResponse: &armvirtualenclaves.ApprovalActionResponse{ + // Message: to.Ptr("Approval state change handled successfully."), + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/CommunityEndpoints_ListByCommunityResource.json +func ExampleCommunityEndpointsClient_NewListByCommunityResourcePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCommunityEndpointsClient().NewListByCommunityResourcePager("rgopenapi", "TestMyCommunity", 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 = armvirtualenclaves.CommunityEndpointsClientListByCommunityResourceResponse{ + // CommunityEndpointResourceListResult: armvirtualenclaves.CommunityEndpointResourceListResult{ + // Value: []*armvirtualenclaves.CommunityEndpointResource{ + // { + // Properties: &armvirtualenclaves.CommunityEndpointProperties{ + // RuleCollection: []*armvirtualenclaves.CommunityEndpointDestinationRule{ + // { + // DestinationType: to.Ptr(armvirtualenclaves.DestinationTypeFQDN), + // Destination: to.Ptr("foo.example.com"), + // Ports: to.Ptr("443"), + // Protocols: []*armvirtualenclaves.CommunityEndpointProtocol{ + // to.Ptr(armvirtualenclaves.CommunityEndpointProtocolTCP), + // }, + // TransitHubResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), + // }, + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/communities/TestMyCommunity/communityendpoints/TestMyCommunityEndpoint"), + // Name: to.Ptr("TestMyCommunityEndpoint"), + // Type: to.Ptr("Microsoft.Mission/communities/communityendpoints"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/CommunityEndpoints_ListBySubscription.json +func ExampleCommunityEndpointsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCommunityEndpointsClient().NewListBySubscriptionPager("TestMyCommunity", 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 = armvirtualenclaves.CommunityEndpointsClientListBySubscriptionResponse{ + // CommunityEndpointResourceListResult: armvirtualenclaves.CommunityEndpointResourceListResult{ + // Value: []*armvirtualenclaves.CommunityEndpointResource{ + // { + // Properties: &armvirtualenclaves.CommunityEndpointProperties{ + // RuleCollection: []*armvirtualenclaves.CommunityEndpointDestinationRule{ + // { + // DestinationType: to.Ptr(armvirtualenclaves.DestinationTypeFQDN), + // Destination: to.Ptr("foo.example.com"), + // Ports: to.Ptr("443"), + // Protocols: []*armvirtualenclaves.CommunityEndpointProtocol{ + // to.Ptr(armvirtualenclaves.CommunityEndpointProtocolTCP), + // }, + // TransitHubResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), + // }, + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/communities/TestMyCommunity/communityendpoints/TestMyCommunityEndpoint"), + // Name: to.Ptr("TestMyCommunityEndpoint"), + // Type: to.Ptr("Microsoft.Mission/communities/communityendpoints"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/CommunityEndpoints_Update.json +func ExampleCommunityEndpointsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCommunityEndpointsClient().BeginUpdate(ctx, "rgopenapi", "TestMyCommunity", "TestMyCommunityEndpoint", armvirtualenclaves.CommunityEndpointPatchModel{ + Tags: map[string]*string{ + "sampletag": to.Ptr("samplevalue"), + }, + Properties: &armvirtualenclaves.CommunityEndpointPatchProperties{ + RuleCollection: []*armvirtualenclaves.CommunityEndpointDestinationRule{ + { + DestinationType: to.Ptr(armvirtualenclaves.DestinationTypeFQDN), + Destination: to.Ptr("foo.example.com"), + Ports: to.Ptr("443"), + Protocols: []*armvirtualenclaves.CommunityEndpointProtocol{ + to.Ptr(armvirtualenclaves.CommunityEndpointProtocolTCP), + }, + TransitHubResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), + }, + }, + }, + }, 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 = armvirtualenclaves.CommunityEndpointsClientUpdateResponse{ + // CommunityEndpointResource: &armvirtualenclaves.CommunityEndpointResource{ + // Properties: &armvirtualenclaves.CommunityEndpointProperties{ + // RuleCollection: []*armvirtualenclaves.CommunityEndpointDestinationRule{ + // { + // DestinationType: to.Ptr(armvirtualenclaves.DestinationTypeFQDN), + // Destination: to.Ptr("foo.example.com"), + // Ports: to.Ptr("443"), + // Protocols: []*armvirtualenclaves.CommunityEndpointProtocol{ + // to.Ptr(armvirtualenclaves.CommunityEndpointProtocolTCP), + // }, + // TransitHubResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), + // }, + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/communities/TestMyCommunity/communityendpoints/TestMyCommunityEndpoint"), + // Name: to.Ptr("TestMyCommunityEndpoint"), + // Type: to.Ptr("Microsoft.Mission/communities/communityendpoints"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/constants.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/constants.go new file mode 100644 index 000000000000..80a42a2b8928 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/constants.go @@ -0,0 +1,649 @@ +// 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 armvirtualenclaves + +// ActionPerformed - Specifies the action performed by the approver +type ActionPerformed string + +const ( + // ActionPerformedApproved - Action was Approved + ActionPerformedApproved ActionPerformed = "Approved" + // ActionPerformedRejected - Action was Rejected + ActionPerformedRejected ActionPerformed = "Rejected" +) + +// PossibleActionPerformedValues returns the possible values for the ActionPerformed const type. +func PossibleActionPerformedValues() []ActionPerformed { + return []ActionPerformed{ + ActionPerformedApproved, + ActionPerformedRejected, + } +} + +// ActionType - Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + // ActionTypeInternal - Actions are for internal-only APIs. + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +type ApprovalActionRequestApprovalStatus string + +const ( + ApprovalActionRequestApprovalStatusApproved ApprovalActionRequestApprovalStatus = "Approved" + ApprovalActionRequestApprovalStatusRejected ApprovalActionRequestApprovalStatus = "Rejected" +) + +// PossibleApprovalActionRequestApprovalStatusValues returns the possible values for the ApprovalActionRequestApprovalStatus const type. +func PossibleApprovalActionRequestApprovalStatusValues() []ApprovalActionRequestApprovalStatus { + return []ApprovalActionRequestApprovalStatus{ + ApprovalActionRequestApprovalStatusApproved, + ApprovalActionRequestApprovalStatusRejected, + } +} + +type ApprovalCallbackRequestApprovalStatus string + +const ( + ApprovalCallbackRequestApprovalStatusApproved ApprovalCallbackRequestApprovalStatus = "Approved" + ApprovalCallbackRequestApprovalStatusRejected ApprovalCallbackRequestApprovalStatus = "Rejected" +) + +// PossibleApprovalCallbackRequestApprovalStatusValues returns the possible values for the ApprovalCallbackRequestApprovalStatus const type. +func PossibleApprovalCallbackRequestApprovalStatusValues() []ApprovalCallbackRequestApprovalStatus { + return []ApprovalCallbackRequestApprovalStatus{ + ApprovalCallbackRequestApprovalStatusApproved, + ApprovalCallbackRequestApprovalStatusRejected, + } +} + +type ApprovalCallbackRequestResourceRequestAction string + +const ( + ApprovalCallbackRequestResourceRequestActionCreate ApprovalCallbackRequestResourceRequestAction = "Create" + ApprovalCallbackRequestResourceRequestActionDelete ApprovalCallbackRequestResourceRequestAction = "Delete" + ApprovalCallbackRequestResourceRequestActionReset ApprovalCallbackRequestResourceRequestAction = "Reset" + ApprovalCallbackRequestResourceRequestActionUpdate ApprovalCallbackRequestResourceRequestAction = "Update" +) + +// PossibleApprovalCallbackRequestResourceRequestActionValues returns the possible values for the ApprovalCallbackRequestResourceRequestAction const type. +func PossibleApprovalCallbackRequestResourceRequestActionValues() []ApprovalCallbackRequestResourceRequestAction { + return []ApprovalCallbackRequestResourceRequestAction{ + ApprovalCallbackRequestResourceRequestActionCreate, + ApprovalCallbackRequestResourceRequestActionDelete, + ApprovalCallbackRequestResourceRequestActionReset, + ApprovalCallbackRequestResourceRequestActionUpdate, + } +} + +type ApprovalDeletionCallbackRequestResourceRequestAction string + +const ( + ApprovalDeletionCallbackRequestResourceRequestActionCreate ApprovalDeletionCallbackRequestResourceRequestAction = "Create" + ApprovalDeletionCallbackRequestResourceRequestActionDelete ApprovalDeletionCallbackRequestResourceRequestAction = "Delete" + ApprovalDeletionCallbackRequestResourceRequestActionUpdate ApprovalDeletionCallbackRequestResourceRequestAction = "Update" +) + +// PossibleApprovalDeletionCallbackRequestResourceRequestActionValues returns the possible values for the ApprovalDeletionCallbackRequestResourceRequestAction const type. +func PossibleApprovalDeletionCallbackRequestResourceRequestActionValues() []ApprovalDeletionCallbackRequestResourceRequestAction { + return []ApprovalDeletionCallbackRequestResourceRequestAction{ + ApprovalDeletionCallbackRequestResourceRequestActionCreate, + ApprovalDeletionCallbackRequestResourceRequestActionDelete, + ApprovalDeletionCallbackRequestResourceRequestActionUpdate, + } +} + +// ApprovalPolicy - Approval Policy. +type ApprovalPolicy string + +const ( + // ApprovalPolicyNotRequired - Approval will not be required for the specified action. + ApprovalPolicyNotRequired ApprovalPolicy = "NotRequired" + // ApprovalPolicyRequired - Approval will be required for the specified action. + ApprovalPolicyRequired ApprovalPolicy = "Required" +) + +// PossibleApprovalPolicyValues returns the possible values for the ApprovalPolicy const type. +func PossibleApprovalPolicyValues() []ApprovalPolicy { + return []ApprovalPolicy{ + ApprovalPolicyNotRequired, + ApprovalPolicyRequired, + } +} + +// ApprovalStatus - Approval Status. It can be Approved, Rejected, Pending, Deleted or Expired. +type ApprovalStatus string + +const ( + // ApprovalStatusApproved - ApprovalStatus Type Approved + ApprovalStatusApproved ApprovalStatus = "Approved" + // ApprovalStatusDeleted - ApprovalStatus Type Deleted + ApprovalStatusDeleted ApprovalStatus = "Deleted" + // ApprovalStatusExpired - ApprovalStatus Type Expired + ApprovalStatusExpired ApprovalStatus = "Expired" + // ApprovalStatusPending - ApprovalStatus Type Pending + ApprovalStatusPending ApprovalStatus = "Pending" + // ApprovalStatusRejected - ApprovalStatus Type Rejected + ApprovalStatusRejected ApprovalStatus = "Rejected" +) + +// PossibleApprovalStatusValues returns the possible values for the ApprovalStatus const type. +func PossibleApprovalStatusValues() []ApprovalStatus { + return []ApprovalStatus{ + ApprovalStatusApproved, + ApprovalStatusDeleted, + ApprovalStatusExpired, + ApprovalStatusPending, + ApprovalStatusRejected, + } +} + +// CommunityEndpointProtocol - Community Endpoint Protocol Enum +type CommunityEndpointProtocol string + +const ( + // CommunityEndpointProtocolAH - CommunityEndpointProtocol Type AH + CommunityEndpointProtocolAH CommunityEndpointProtocol = "AH" + // CommunityEndpointProtocolANY - CommunityEndpointProtocol Type ANY + CommunityEndpointProtocolANY CommunityEndpointProtocol = "ANY" + // CommunityEndpointProtocolESP - CommunityEndpointProtocol Type ESP + CommunityEndpointProtocolESP CommunityEndpointProtocol = "ESP" + // CommunityEndpointProtocolHTTP - CommunityEndpointProtocol Type HTTP + CommunityEndpointProtocolHTTP CommunityEndpointProtocol = "HTTP" + // CommunityEndpointProtocolHTTPS - CommunityEndpointProtocol Type HTTPS + CommunityEndpointProtocolHTTPS CommunityEndpointProtocol = "HTTPS" + // CommunityEndpointProtocolICMP - CommunityEndpointProtocol Type ICMP + CommunityEndpointProtocolICMP CommunityEndpointProtocol = "ICMP" + // CommunityEndpointProtocolTCP - CommunityEndpointProtocol Type TCP + CommunityEndpointProtocolTCP CommunityEndpointProtocol = "TCP" + // CommunityEndpointProtocolUDP - CommunityEndpointProtocol Type UDP + CommunityEndpointProtocolUDP CommunityEndpointProtocol = "UDP" +) + +// PossibleCommunityEndpointProtocolValues returns the possible values for the CommunityEndpointProtocol const type. +func PossibleCommunityEndpointProtocolValues() []CommunityEndpointProtocol { + return []CommunityEndpointProtocol{ + CommunityEndpointProtocolAH, + CommunityEndpointProtocolANY, + CommunityEndpointProtocolESP, + CommunityEndpointProtocolHTTP, + CommunityEndpointProtocolHTTPS, + CommunityEndpointProtocolICMP, + CommunityEndpointProtocolTCP, + CommunityEndpointProtocolUDP, + } +} + +type CommunityPropertiesPolicyOverride string + +const ( + CommunityPropertiesPolicyOverrideEnclave CommunityPropertiesPolicyOverride = "Enclave" + CommunityPropertiesPolicyOverrideNone CommunityPropertiesPolicyOverride = "None" +) + +// PossibleCommunityPropertiesPolicyOverrideValues returns the possible values for the CommunityPropertiesPolicyOverride const type. +func PossibleCommunityPropertiesPolicyOverrideValues() []CommunityPropertiesPolicyOverride { + return []CommunityPropertiesPolicyOverride{ + CommunityPropertiesPolicyOverrideEnclave, + CommunityPropertiesPolicyOverrideNone, + } +} + +// 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, + } +} + +// DestinationType - Destination Type Enum +type DestinationType string + +const ( + // DestinationTypeFQDN - DestinationType Type FQDN + DestinationTypeFQDN DestinationType = "FQDN" + // DestinationTypeFQDNTag - DestinationType Type FQDNTag + DestinationTypeFQDNTag DestinationType = "FQDNTag" + // DestinationTypeIPAddress - DestinationType Type IPAddress + DestinationTypeIPAddress DestinationType = "IPAddress" + // DestinationTypePrivateNetwork - DestinationType Type PrivateNetwork + DestinationTypePrivateNetwork DestinationType = "PrivateNetwork" +) + +// PossibleDestinationTypeValues returns the possible values for the DestinationType const type. +func PossibleDestinationTypeValues() []DestinationType { + return []DestinationType{ + DestinationTypeFQDN, + DestinationTypeFQDNTag, + DestinationTypeIPAddress, + DestinationTypePrivateNetwork, + } +} + +// DiagnosticDestination - Specifies the destination of where to store diagnostic logs. +type DiagnosticDestination string + +const ( + // DiagnosticDestinationBoth - DiagnosticDestination Type Both + DiagnosticDestinationBoth DiagnosticDestination = "Both" + // DiagnosticDestinationCommunityOnly - DiagnosticDestination Type CommunityOnly + DiagnosticDestinationCommunityOnly DiagnosticDestination = "CommunityOnly" + // DiagnosticDestinationEnclaveOnly - DiagnosticDestination Type EnclaveOnly + DiagnosticDestinationEnclaveOnly DiagnosticDestination = "EnclaveOnly" +) + +// PossibleDiagnosticDestinationValues returns the possible values for the DiagnosticDestination const type. +func PossibleDiagnosticDestinationValues() []DiagnosticDestination { + return []DiagnosticDestination{ + DiagnosticDestinationBoth, + DiagnosticDestinationCommunityOnly, + DiagnosticDestinationEnclaveOnly, + } +} + +// EnclaveConnectionState - Specifies the state of the enclave connection. +type EnclaveConnectionState string + +const ( + // EnclaveConnectionStateActive - EnclaveConnectionState Type Active + EnclaveConnectionStateActive EnclaveConnectionState = "Active" + // EnclaveConnectionStateApproved - EnclaveConnectionState Type Approved + EnclaveConnectionStateApproved EnclaveConnectionState = "Approved" + // EnclaveConnectionStateConnected - EnclaveConnectionState Type Connected + EnclaveConnectionStateConnected EnclaveConnectionState = "Connected" + // EnclaveConnectionStateDisconnected - EnclaveConnectionState Type Disconnected + EnclaveConnectionStateDisconnected EnclaveConnectionState = "Disconnected" + // EnclaveConnectionStateFailed - EnclaveConnectionState Type Failed + EnclaveConnectionStateFailed EnclaveConnectionState = "Failed" + // EnclaveConnectionStatePendingApproval - EnclaveConnectionState Type Pending Approval + EnclaveConnectionStatePendingApproval EnclaveConnectionState = "PendingApproval" + // EnclaveConnectionStatePendingUpdate - EnclaveConnectionState Type Pending Update + EnclaveConnectionStatePendingUpdate EnclaveConnectionState = "PendingUpdate" +) + +// PossibleEnclaveConnectionStateValues returns the possible values for the EnclaveConnectionState const type. +func PossibleEnclaveConnectionStateValues() []EnclaveConnectionState { + return []EnclaveConnectionState{ + EnclaveConnectionStateActive, + EnclaveConnectionStateApproved, + EnclaveConnectionStateConnected, + EnclaveConnectionStateDisconnected, + EnclaveConnectionStateFailed, + EnclaveConnectionStatePendingApproval, + EnclaveConnectionStatePendingUpdate, + } +} + +// EnclaveEndpointProtocol - Enclave Endpoint Protocol Enum +type EnclaveEndpointProtocol string + +const ( + // EnclaveEndpointProtocolAH - EndpointProtocol Type AH + EnclaveEndpointProtocolAH EnclaveEndpointProtocol = "AH" + // EnclaveEndpointProtocolANY - EndpointProtocol Type ANY + EnclaveEndpointProtocolANY EnclaveEndpointProtocol = "ANY" + // EnclaveEndpointProtocolESP - EndpointProtocol Type ESP + EnclaveEndpointProtocolESP EnclaveEndpointProtocol = "ESP" + // EnclaveEndpointProtocolICMP - EndpointProtocol Type ICMP + EnclaveEndpointProtocolICMP EnclaveEndpointProtocol = "ICMP" + // EnclaveEndpointProtocolTCP - EndpointProtocol Type TCP + EnclaveEndpointProtocolTCP EnclaveEndpointProtocol = "TCP" + // EnclaveEndpointProtocolUDP - EndpointProtocol Type UDP + EnclaveEndpointProtocolUDP EnclaveEndpointProtocol = "UDP" +) + +// PossibleEnclaveEndpointProtocolValues returns the possible values for the EnclaveEndpointProtocol const type. +func PossibleEnclaveEndpointProtocolValues() []EnclaveEndpointProtocol { + return []EnclaveEndpointProtocol{ + EnclaveEndpointProtocolAH, + EnclaveEndpointProtocolANY, + EnclaveEndpointProtocolESP, + EnclaveEndpointProtocolICMP, + EnclaveEndpointProtocolTCP, + EnclaveEndpointProtocolUDP, + } +} + +// FirewallSKU - Azure Firewall SKU +type FirewallSKU string + +const ( + // FirewallSKUBasic - FirewallSKU Basic + FirewallSKUBasic FirewallSKU = "Basic" + // FirewallSKUPremium - FirewallSKU Premium + FirewallSKUPremium FirewallSKU = "Premium" + // FirewallSKUStandard - FirwallSKU Standard + FirewallSKUStandard FirewallSKU = "Standard" +) + +// PossibleFirewallSKUValues returns the possible values for the FirewallSKU const type. +func PossibleFirewallSKUValues() []FirewallSKU { + return []FirewallSKU{ + FirewallSKUBasic, + FirewallSKUPremium, + FirewallSKUStandard, + } +} + +type GovernedServiceItemEnforcement string + +const ( + GovernedServiceItemEnforcementDisabled GovernedServiceItemEnforcement = "Disabled" + GovernedServiceItemEnforcementEnabled GovernedServiceItemEnforcement = "Enabled" +) + +// PossibleGovernedServiceItemEnforcementValues returns the possible values for the GovernedServiceItemEnforcement const type. +func PossibleGovernedServiceItemEnforcementValues() []GovernedServiceItemEnforcement { + return []GovernedServiceItemEnforcement{ + GovernedServiceItemEnforcementDisabled, + GovernedServiceItemEnforcementEnabled, + } +} + +type GovernedServiceItemOption string + +const ( + GovernedServiceItemOptionAllow GovernedServiceItemOption = "Allow" + GovernedServiceItemOptionDeny GovernedServiceItemOption = "Deny" + GovernedServiceItemOptionExceptionOnly GovernedServiceItemOption = "ExceptionOnly" + GovernedServiceItemOptionNotApplicable GovernedServiceItemOption = "NotApplicable" +) + +// PossibleGovernedServiceItemOptionValues returns the possible values for the GovernedServiceItemOption const type. +func PossibleGovernedServiceItemOptionValues() []GovernedServiceItemOption { + return []GovernedServiceItemOption{ + GovernedServiceItemOptionAllow, + GovernedServiceItemOptionDeny, + GovernedServiceItemOptionExceptionOnly, + GovernedServiceItemOptionNotApplicable, + } +} + +type GovernedServiceItemPolicyAction string + +const ( + GovernedServiceItemPolicyActionAuditOnly GovernedServiceItemPolicyAction = "AuditOnly" + GovernedServiceItemPolicyActionEnforce GovernedServiceItemPolicyAction = "Enforce" + GovernedServiceItemPolicyActionNone GovernedServiceItemPolicyAction = "None" +) + +// PossibleGovernedServiceItemPolicyActionValues returns the possible values for the GovernedServiceItemPolicyAction const type. +func PossibleGovernedServiceItemPolicyActionValues() []GovernedServiceItemPolicyAction { + return []GovernedServiceItemPolicyAction{ + GovernedServiceItemPolicyActionAuditOnly, + GovernedServiceItemPolicyActionEnforce, + GovernedServiceItemPolicyActionNone, + } +} + +type MaintenanceModeConfigurationModelJustification string + +const ( + MaintenanceModeConfigurationModelJustificationGovernance MaintenanceModeConfigurationModelJustification = "Governance" + MaintenanceModeConfigurationModelJustificationNetworking MaintenanceModeConfigurationModelJustification = "Networking" + MaintenanceModeConfigurationModelJustificationOff MaintenanceModeConfigurationModelJustification = "Off" +) + +// PossibleMaintenanceModeConfigurationModelJustificationValues returns the possible values for the MaintenanceModeConfigurationModelJustification const type. +func PossibleMaintenanceModeConfigurationModelJustificationValues() []MaintenanceModeConfigurationModelJustification { + return []MaintenanceModeConfigurationModelJustification{ + MaintenanceModeConfigurationModelJustificationGovernance, + MaintenanceModeConfigurationModelJustificationNetworking, + MaintenanceModeConfigurationModelJustificationOff, + } +} + +type MaintenanceModeConfigurationModelMode string + +const ( + MaintenanceModeConfigurationModelModeAdvanced MaintenanceModeConfigurationModelMode = "Advanced" + MaintenanceModeConfigurationModelModeCanNotDelete MaintenanceModeConfigurationModelMode = "CanNotDelete" + MaintenanceModeConfigurationModelModeGeneral MaintenanceModeConfigurationModelMode = "General" + MaintenanceModeConfigurationModelModeOff MaintenanceModeConfigurationModelMode = "Off" + MaintenanceModeConfigurationModelModeOn MaintenanceModeConfigurationModelMode = "On" +) + +// PossibleMaintenanceModeConfigurationModelModeValues returns the possible values for the MaintenanceModeConfigurationModelMode const type. +func PossibleMaintenanceModeConfigurationModelModeValues() []MaintenanceModeConfigurationModelMode { + return []MaintenanceModeConfigurationModelMode{ + MaintenanceModeConfigurationModelModeAdvanced, + MaintenanceModeConfigurationModelModeCanNotDelete, + MaintenanceModeConfigurationModelModeGeneral, + MaintenanceModeConfigurationModelModeOff, + MaintenanceModeConfigurationModelModeOn, + } +} + +// ManagedServiceIdentityType - Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). +type ManagedServiceIdentityType string + +const ( + // ManagedServiceIdentityTypeNone - No managed identity. + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + // ManagedServiceIdentityTypeSystemAssigned - System assigned managed identity. + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + // ManagedServiceIdentityTypeSystemAssignedUserAssigned - System and user assigned managed identity. + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned" + // ManagedServiceIdentityTypeUserAssigned - User assigned managed identity. + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{ + ManagedServiceIdentityTypeNone, + ManagedServiceIdentityTypeSystemAssigned, + ManagedServiceIdentityTypeSystemAssignedUserAssigned, + ManagedServiceIdentityTypeUserAssigned, + } +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + // OriginSystem - Indicates the operation is initiated by a system. + OriginSystem Origin = "system" + // OriginUser - Indicates the operation is initiated by a user. + OriginUser Origin = "user" + // OriginUserSystem - Indicates the operation is initiated by a user or system. + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +type PrincipalType string + +const ( + PrincipalTypeGroup PrincipalType = "Group" + PrincipalTypeServicePrincipal PrincipalType = "ServicePrincipal" + PrincipalTypeUser PrincipalType = "User" +) + +// PossiblePrincipalTypeValues returns the possible values for the PrincipalType const type. +func PossiblePrincipalTypeValues() []PrincipalType { + return []PrincipalType{ + PrincipalTypeGroup, + PrincipalTypeServicePrincipal, + PrincipalTypeUser, + } +} + +// ProvisioningState - The provisioning status of the resource. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted - Provisioning State Type Accepted + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreating - Provisioning State Type Creating + ProvisioningStateCreating ProvisioningState = "Creating" + // ProvisioningStateDeleting - Provisioning State Type Deleting + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateNotSpecified - Provisioning State Type NotSpecified + ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + // ProvisioningStateRunning - Provisioning State Type Running + ProvisioningStateRunning ProvisioningState = "Running" + // ProvisioningStateSucceeded - Resource has been created. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - Provisioning State Type Updating + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateCreating, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateNotSpecified, + ProvisioningStateRunning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ServiceIdentifier - Identifier for governed services. +type ServiceIdentifier string + +const ( + // ServiceIdentifierAKS - Service identifier for AKS + ServiceIdentifierAKS ServiceIdentifier = "AKS" + // ServiceIdentifierAppService - Service identifier for App Service + ServiceIdentifierAppService ServiceIdentifier = "AppService" + // ServiceIdentifierAzureFirewalls - Service identifier for Azure Firewalls + ServiceIdentifierAzureFirewalls ServiceIdentifier = "AzureFirewalls" + // ServiceIdentifierContainerRegistry - Service identifier for Container Registry + ServiceIdentifierContainerRegistry ServiceIdentifier = "ContainerRegistry" + // ServiceIdentifierCosmosDB - Service identifier for CosmosDB + ServiceIdentifierCosmosDB ServiceIdentifier = "CosmosDB" + // ServiceIdentifierDataConnectors - Service identifier for Data Connectors + ServiceIdentifierDataConnectors ServiceIdentifier = "DataConnectors" + // ServiceIdentifierInsights - Service identifier for Insights + ServiceIdentifierInsights ServiceIdentifier = "Insights" + // ServiceIdentifierKeyVault - Service identifier for Key Vault + ServiceIdentifierKeyVault ServiceIdentifier = "KeyVault" + // ServiceIdentifierLogic - Service identifier for Logic + ServiceIdentifierLogic ServiceIdentifier = "Logic" + // ServiceIdentifierMicrosoftSQL - Service identifier for Microsoft SQL + ServiceIdentifierMicrosoftSQL ServiceIdentifier = "MicrosoftSQL" + // ServiceIdentifierMonitoring - Service identifier for Monitoring + ServiceIdentifierMonitoring ServiceIdentifier = "Monitoring" + // ServiceIdentifierPostgreSQL - Service identifier for PostgreSQL + ServiceIdentifierPostgreSQL ServiceIdentifier = "PostgreSQL" + // ServiceIdentifierPrivateDNSZones - Service identifier for Private DNS Zones + ServiceIdentifierPrivateDNSZones ServiceIdentifier = "PrivateDNSZones" + // ServiceIdentifierServiceBus - Service identifier for Service Bus + ServiceIdentifierServiceBus ServiceIdentifier = "ServiceBus" + // ServiceIdentifierStorage - Service identifier for Storage + ServiceIdentifierStorage ServiceIdentifier = "Storage" +) + +// PossibleServiceIdentifierValues returns the possible values for the ServiceIdentifier const type. +func PossibleServiceIdentifierValues() []ServiceIdentifier { + return []ServiceIdentifier{ + ServiceIdentifierAKS, + ServiceIdentifierAppService, + ServiceIdentifierAzureFirewalls, + ServiceIdentifierContainerRegistry, + ServiceIdentifierCosmosDB, + ServiceIdentifierDataConnectors, + ServiceIdentifierInsights, + ServiceIdentifierKeyVault, + ServiceIdentifierLogic, + ServiceIdentifierMicrosoftSQL, + ServiceIdentifierMonitoring, + ServiceIdentifierPostgreSQL, + ServiceIdentifierPrivateDNSZones, + ServiceIdentifierServiceBus, + ServiceIdentifierStorage, + } +} + +// TransitHubState - Specifies the state of the transitHub. +type TransitHubState string + +const ( + // TransitHubStateActive - TransitHubState Type Active + TransitHubStateActive TransitHubState = "Active" + // TransitHubStateApproved - TransitHubState Type Approved + TransitHubStateApproved TransitHubState = "Approved" + // TransitHubStateFailed - TransitHubState Type Failed + TransitHubStateFailed TransitHubState = "Failed" + // TransitHubStatePendingApproval - TransitHubState Type PendingApproval + TransitHubStatePendingApproval TransitHubState = "PendingApproval" + // TransitHubStatePendingUpdate - TransitHubState Type PendingUpdate + TransitHubStatePendingUpdate TransitHubState = "PendingUpdate" +) + +// PossibleTransitHubStateValues returns the possible values for the TransitHubState const type. +func PossibleTransitHubStateValues() []TransitHubState { + return []TransitHubState{ + TransitHubStateActive, + TransitHubStateApproved, + TransitHubStateFailed, + TransitHubStatePendingApproval, + TransitHubStatePendingUpdate, + } +} + +// TransitOptionType - Specifies the type of the transitOption. +type TransitOptionType string + +const ( + // TransitOptionTypeExpressRoute - TransitOptionType ExpressRoute + TransitOptionTypeExpressRoute TransitOptionType = "ExpressRoute" + // TransitOptionTypeGateway - TransitOptionType Gateway + TransitOptionTypeGateway TransitOptionType = "Gateway" + // TransitOptionTypePeering - TransitOptionType Peering + TransitOptionTypePeering TransitOptionType = "Peering" +) + +// PossibleTransitOptionTypeValues returns the possible values for the TransitOptionType const type. +func PossibleTransitOptionTypeValues() []TransitOptionType { + return []TransitOptionType{ + TransitOptionTypeExpressRoute, + TransitOptionTypeGateway, + TransitOptionTypePeering, + } +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/enclaveconnection_client.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/enclaveconnection_client.go new file mode 100644 index 000000000000..53d1d2696041 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/enclaveconnection_client.go @@ -0,0 +1,619 @@ +// 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 armvirtualenclaves + +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" +) + +// EnclaveConnectionClient - Enclave Connection Interface +// Don't use this type directly, use NewEnclaveConnectionClient() instead. +type EnclaveConnectionClient struct { + internal *arm.Client + subscriptionID string +} + +// NewEnclaveConnectionClient creates a new instance of EnclaveConnectionClient 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 NewEnclaveConnectionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EnclaveConnectionClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &EnclaveConnectionClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a EnclaveConnectionResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - enclaveConnectionName - The name of the Enclave Connection Resource +// - resource - Resource create parameters. +// - options - EnclaveConnectionClientBeginCreateOrUpdateOptions contains the optional parameters for the EnclaveConnectionClient.BeginCreateOrUpdate +// method. +func (client *EnclaveConnectionClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, enclaveConnectionName string, resource EnclaveConnectionResource, options *EnclaveConnectionClientBeginCreateOrUpdateOptions) (*runtime.Poller[EnclaveConnectionClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, enclaveConnectionName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EnclaveConnectionClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EnclaveConnectionClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a EnclaveConnectionResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *EnclaveConnectionClient) createOrUpdate(ctx context.Context, resourceGroupName string, enclaveConnectionName string, resource EnclaveConnectionResource, options *EnclaveConnectionClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "EnclaveConnectionClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, enclaveConnectionName, 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 +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *EnclaveConnectionClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, enclaveConnectionName string, resource EnclaveConnectionResource, _ *EnclaveConnectionClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName}" + 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 enclaveConnectionName == "" { + return nil, errors.New("parameter enclaveConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enclaveConnectionName}", url.PathEscape(enclaveConnectionName)) + 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-05-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 EnclaveConnectionResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - enclaveConnectionName - The name of the Enclave Connection Resource +// - options - EnclaveConnectionClientBeginDeleteOptions contains the optional parameters for the EnclaveConnectionClient.BeginDelete +// method. +func (client *EnclaveConnectionClient) BeginDelete(ctx context.Context, resourceGroupName string, enclaveConnectionName string, options *EnclaveConnectionClientBeginDeleteOptions) (*runtime.Poller[EnclaveConnectionClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, enclaveConnectionName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EnclaveConnectionClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EnclaveConnectionClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a EnclaveConnectionResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *EnclaveConnectionClient) deleteOperation(ctx context.Context, resourceGroupName string, enclaveConnectionName string, options *EnclaveConnectionClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "EnclaveConnectionClient.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, enclaveConnectionName, 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 *EnclaveConnectionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, enclaveConnectionName string, _ *EnclaveConnectionClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName}" + 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 enclaveConnectionName == "" { + return nil, errors.New("parameter enclaveConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enclaveConnectionName}", url.PathEscape(enclaveConnectionName)) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Get a EnclaveConnectionResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - enclaveConnectionName - The name of the Enclave Connection Resource +// - options - EnclaveConnectionClientGetOptions contains the optional parameters for the EnclaveConnectionClient.Get method. +func (client *EnclaveConnectionClient) Get(ctx context.Context, resourceGroupName string, enclaveConnectionName string, options *EnclaveConnectionClientGetOptions) (EnclaveConnectionClientGetResponse, error) { + var err error + const operationName = "EnclaveConnectionClient.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, enclaveConnectionName, options) + if err != nil { + return EnclaveConnectionClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EnclaveConnectionClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EnclaveConnectionClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *EnclaveConnectionClient) getCreateRequest(ctx context.Context, resourceGroupName string, enclaveConnectionName string, _ *EnclaveConnectionClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName}" + 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 enclaveConnectionName == "" { + return nil, errors.New("parameter enclaveConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enclaveConnectionName}", url.PathEscape(enclaveConnectionName)) + 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-05-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 *EnclaveConnectionClient) getHandleResponse(resp *http.Response) (EnclaveConnectionClientGetResponse, error) { + result := EnclaveConnectionClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnclaveConnectionResource); err != nil { + return EnclaveConnectionClientGetResponse{}, err + } + return result, nil +} + +// BeginHandleApprovalCreation - Callback that triggers on approval state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - enclaveConnectionName - The name of the Enclave Connection Resource +// - body - The content of the action request +// - options - EnclaveConnectionClientBeginHandleApprovalCreationOptions contains the optional parameters for the EnclaveConnectionClient.BeginHandleApprovalCreation +// method. +func (client *EnclaveConnectionClient) BeginHandleApprovalCreation(ctx context.Context, resourceGroupName string, enclaveConnectionName string, body ApprovalCallbackRequest, options *EnclaveConnectionClientBeginHandleApprovalCreationOptions) (*runtime.Poller[EnclaveConnectionClientHandleApprovalCreationResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.handleApprovalCreation(ctx, resourceGroupName, enclaveConnectionName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EnclaveConnectionClientHandleApprovalCreationResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EnclaveConnectionClientHandleApprovalCreationResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// HandleApprovalCreation - Callback that triggers on approval state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *EnclaveConnectionClient) handleApprovalCreation(ctx context.Context, resourceGroupName string, enclaveConnectionName string, body ApprovalCallbackRequest, options *EnclaveConnectionClientBeginHandleApprovalCreationOptions) (*http.Response, error) { + var err error + const operationName = "EnclaveConnectionClient.BeginHandleApprovalCreation" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.handleApprovalCreationCreateRequest(ctx, resourceGroupName, enclaveConnectionName, 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 +} + +// handleApprovalCreationCreateRequest creates the HandleApprovalCreation request. +func (client *EnclaveConnectionClient) handleApprovalCreationCreateRequest(ctx context.Context, resourceGroupName string, enclaveConnectionName string, body ApprovalCallbackRequest, _ *EnclaveConnectionClientBeginHandleApprovalCreationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName}/handleApprovalCreation" + 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 enclaveConnectionName == "" { + return nil, errors.New("parameter enclaveConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enclaveConnectionName}", url.PathEscape(enclaveConnectionName)) + 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-05-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 +} + +// BeginHandleApprovalDeletion - Callback that triggers on approval deletion state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - enclaveConnectionName - The name of the Enclave Connection Resource +// - body - The content of the action request +// - options - EnclaveConnectionClientBeginHandleApprovalDeletionOptions contains the optional parameters for the EnclaveConnectionClient.BeginHandleApprovalDeletion +// method. +func (client *EnclaveConnectionClient) BeginHandleApprovalDeletion(ctx context.Context, resourceGroupName string, enclaveConnectionName string, body ApprovalDeletionCallbackRequest, options *EnclaveConnectionClientBeginHandleApprovalDeletionOptions) (*runtime.Poller[EnclaveConnectionClientHandleApprovalDeletionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.handleApprovalDeletion(ctx, resourceGroupName, enclaveConnectionName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EnclaveConnectionClientHandleApprovalDeletionResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EnclaveConnectionClientHandleApprovalDeletionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// HandleApprovalDeletion - Callback that triggers on approval deletion state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *EnclaveConnectionClient) handleApprovalDeletion(ctx context.Context, resourceGroupName string, enclaveConnectionName string, body ApprovalDeletionCallbackRequest, options *EnclaveConnectionClientBeginHandleApprovalDeletionOptions) (*http.Response, error) { + var err error + const operationName = "EnclaveConnectionClient.BeginHandleApprovalDeletion" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.handleApprovalDeletionCreateRequest(ctx, resourceGroupName, enclaveConnectionName, 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 +} + +// handleApprovalDeletionCreateRequest creates the HandleApprovalDeletion request. +func (client *EnclaveConnectionClient) handleApprovalDeletionCreateRequest(ctx context.Context, resourceGroupName string, enclaveConnectionName string, body ApprovalDeletionCallbackRequest, _ *EnclaveConnectionClientBeginHandleApprovalDeletionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName}/handleApprovalDeletion" + 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 enclaveConnectionName == "" { + return nil, errors.New("parameter enclaveConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enclaveConnectionName}", url.PathEscape(enclaveConnectionName)) + 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-05-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 +} + +// NewListByResourceGroupPager - List EnclaveConnectionResource resources by resource group +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - EnclaveConnectionClientListByResourceGroupOptions contains the optional parameters for the EnclaveConnectionClient.NewListByResourceGroupPager +// method. +func (client *EnclaveConnectionClient) NewListByResourceGroupPager(resourceGroupName string, options *EnclaveConnectionClientListByResourceGroupOptions) *runtime.Pager[EnclaveConnectionClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[EnclaveConnectionClientListByResourceGroupResponse]{ + More: func(page EnclaveConnectionClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EnclaveConnectionClientListByResourceGroupResponse) (EnclaveConnectionClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EnclaveConnectionClient.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 EnclaveConnectionClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *EnclaveConnectionClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *EnclaveConnectionClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections" + 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-05-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 *EnclaveConnectionClient) listByResourceGroupHandleResponse(resp *http.Response) (EnclaveConnectionClientListByResourceGroupResponse, error) { + result := EnclaveConnectionClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnclaveConnectionResourceListResult); err != nil { + return EnclaveConnectionClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List EnclaveConnectionResource resources by subscription ID +// +// Generated from API version 2025-05-01-preview +// - options - EnclaveConnectionClientListBySubscriptionOptions contains the optional parameters for the EnclaveConnectionClient.NewListBySubscriptionPager +// method. +func (client *EnclaveConnectionClient) NewListBySubscriptionPager(options *EnclaveConnectionClientListBySubscriptionOptions) *runtime.Pager[EnclaveConnectionClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[EnclaveConnectionClientListBySubscriptionResponse]{ + More: func(page EnclaveConnectionClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EnclaveConnectionClientListBySubscriptionResponse) (EnclaveConnectionClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EnclaveConnectionClient.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 EnclaveConnectionClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *EnclaveConnectionClient) listBySubscriptionCreateRequest(ctx context.Context, _ *EnclaveConnectionClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Mission/enclaveConnections" + 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-05-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 *EnclaveConnectionClient) listBySubscriptionHandleResponse(resp *http.Response) (EnclaveConnectionClientListBySubscriptionResponse, error) { + result := EnclaveConnectionClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnclaveConnectionResourceListResult); err != nil { + return EnclaveConnectionClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a EnclaveConnectionResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - enclaveConnectionName - The name of the Enclave Connection Resource +// - properties - The resource properties to be updated. +// - options - EnclaveConnectionClientBeginUpdateOptions contains the optional parameters for the EnclaveConnectionClient.BeginUpdate +// method. +func (client *EnclaveConnectionClient) BeginUpdate(ctx context.Context, resourceGroupName string, enclaveConnectionName string, properties EnclaveConnectionPatchModel, options *EnclaveConnectionClientBeginUpdateOptions) (*runtime.Poller[EnclaveConnectionClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, enclaveConnectionName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EnclaveConnectionClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EnclaveConnectionClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a EnclaveConnectionResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *EnclaveConnectionClient) update(ctx context.Context, resourceGroupName string, enclaveConnectionName string, properties EnclaveConnectionPatchModel, options *EnclaveConnectionClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "EnclaveConnectionClient.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, enclaveConnectionName, 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 *EnclaveConnectionClient) updateCreateRequest(ctx context.Context, resourceGroupName string, enclaveConnectionName string, properties EnclaveConnectionPatchModel, _ *EnclaveConnectionClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/enclaveConnections/{enclaveConnectionName}" + 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 enclaveConnectionName == "" { + return nil, errors.New("parameter enclaveConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enclaveConnectionName}", url.PathEscape(enclaveConnectionName)) + 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-05-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/virtualenclaves/armvirtualenclaves/enclaveconnection_client_example_test.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/enclaveconnection_client_example_test.go new file mode 100644 index 000000000000..815a6d17b1f4 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/enclaveconnection_client_example_test.go @@ -0,0 +1,374 @@ +// 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 armvirtualenclaves_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/virtualenclaves/armvirtualenclaves" + "log" +) + +// Generated from example definition: 2025-05-01-preview/EnclaveConnection_CreateOrUpdate.json +func ExampleEnclaveConnectionClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnclaveConnectionClient().BeginCreateOrUpdate(ctx, "rgopenapi", "TestMyEnclaveConnection", armvirtualenclaves.EnclaveConnectionResource{ + Properties: &armvirtualenclaves.EnclaveConnectionProperties{ + CommunityResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + SourceResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + SourceCidr: to.Ptr("10.0.0.0/24"), + DestinationEndpointID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/virtualenclaves/TestMyEnclave/enclaveendpoints/TestMyEnclaveEndpoint"), + }, + Tags: map[string]*string{ + "sampletag": to.Ptr("samplevalue"), + }, + Location: to.Ptr("West US"), + }, 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 = armvirtualenclaves.EnclaveConnectionClientCreateOrUpdateResponse{ + // EnclaveConnectionResource: &armvirtualenclaves.EnclaveConnectionResource{ + // Properties: &armvirtualenclaves.EnclaveConnectionProperties{ + // CommunityResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // SourceResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // SourceCidr: to.Ptr("10.0.0.0/24"), + // DestinationEndpointID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/virtualenclaves/TestMyEnclave/enclaveendpoints/TestMyEnclaveEndpoint"), + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"), + // Name: to.Ptr("TestMyEnclaveConnection"), + // Type: to.Ptr("Microsoft.Mission/enclaveconnections"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/EnclaveConnection_Delete.json +func ExampleEnclaveConnectionClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnclaveConnectionClient().BeginDelete(ctx, "rgopenapi", "TestMyEnclaveConnection", 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-05-01-preview/EnclaveConnection_Get.json +func ExampleEnclaveConnectionClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEnclaveConnectionClient().Get(ctx, "rgopenapi", "TestMyEnclaveConnection", 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 = armvirtualenclaves.EnclaveConnectionClientGetResponse{ + // EnclaveConnectionResource: &armvirtualenclaves.EnclaveConnectionResource{ + // Properties: &armvirtualenclaves.EnclaveConnectionProperties{ + // CommunityResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // SourceResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // SourceCidr: to.Ptr("10.0.0.0/24"), + // DestinationEndpointID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/virtualenclaves/TestMyEnclave/enclaveendpoints/TestMyEnclaveEndpoint"), + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"), + // Name: to.Ptr("TestMyEnclaveConnection"), + // Type: to.Ptr("Microsoft.Mission/enclaveconnections"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/EnclaveConnection_HandleApprovalCreation.json +func ExampleEnclaveConnectionClient_BeginHandleApprovalCreation() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnclaveConnectionClient().BeginHandleApprovalCreation(ctx, "rgopenapi", "TestMyEnclaveConnection", armvirtualenclaves.ApprovalCallbackRequest{ + ResourceRequestAction: to.Ptr(armvirtualenclaves.ApprovalCallbackRequestResourceRequestActionCreate), + ApprovalStatus: to.Ptr(armvirtualenclaves.ApprovalCallbackRequestApprovalStatusApproved), + ApprovalCallbackPayload: to.Ptr("{\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n}"), + }, 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 = armvirtualenclaves.EnclaveConnectionClientHandleApprovalCreationResponse{ + // ApprovalActionResponse: &armvirtualenclaves.ApprovalActionResponse{ + // Message: to.Ptr("Approval state change handled successfully."), + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/EnclaveConnection_HandleApprovalDeletion.json +func ExampleEnclaveConnectionClient_BeginHandleApprovalDeletion() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnclaveConnectionClient().BeginHandleApprovalDeletion(ctx, "rgopenapi", "TestMyEnclaveConnection", armvirtualenclaves.ApprovalDeletionCallbackRequest{ + ResourceRequestAction: to.Ptr(armvirtualenclaves.ApprovalDeletionCallbackRequestResourceRequestActionCreate), + }, 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 = armvirtualenclaves.EnclaveConnectionClientHandleApprovalDeletionResponse{ + // ApprovalActionResponse: &armvirtualenclaves.ApprovalActionResponse{ + // Message: to.Ptr("Approval state change handled successfully."), + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/EnclaveConnection_ListByResourceGroup.json +func ExampleEnclaveConnectionClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEnclaveConnectionClient().NewListByResourceGroupPager("rgopenapi", 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 = armvirtualenclaves.EnclaveConnectionClientListByResourceGroupResponse{ + // EnclaveConnectionResourceListResult: armvirtualenclaves.EnclaveConnectionResourceListResult{ + // Value: []*armvirtualenclaves.EnclaveConnectionResource{ + // { + // Properties: &armvirtualenclaves.EnclaveConnectionProperties{ + // CommunityResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // SourceResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // SourceCidr: to.Ptr("10.0.0.0/24"), + // DestinationEndpointID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/virtualenclaves/TestMyEnclave/enclaveendpoints/TestMyEnclaveEndpoint"), + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"), + // Name: to.Ptr("TestMyEnclaveConnection"), + // Type: to.Ptr("Microsoft.Mission/enclaveconnections"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/EnclaveConnection_ListBySubscription.json +func ExampleEnclaveConnectionClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEnclaveConnectionClient().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 = armvirtualenclaves.EnclaveConnectionClientListBySubscriptionResponse{ + // EnclaveConnectionResourceListResult: armvirtualenclaves.EnclaveConnectionResourceListResult{ + // Value: []*armvirtualenclaves.EnclaveConnectionResource{ + // { + // Properties: &armvirtualenclaves.EnclaveConnectionProperties{ + // CommunityResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // SourceResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // SourceCidr: to.Ptr("10.0.0.0/24"), + // DestinationEndpointID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/virtualenclaves/TestMyEnclave/enclaveendpoints/TestMyEnclaveEndpoint"), + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"), + // Name: to.Ptr("TestMyEnclaveConnection"), + // Type: to.Ptr("Microsoft.Mission/enclaveconnections"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/EnclaveConnection_Update.json +func ExampleEnclaveConnectionClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnclaveConnectionClient().BeginUpdate(ctx, "rgopenapi", "TestMyEnclaveConnection", armvirtualenclaves.EnclaveConnectionPatchModel{ + Tags: map[string]*string{ + "sampletag": to.Ptr("samplevalue"), + }, + Properties: &armvirtualenclaves.EnclaveConnectionPatchProperties{ + SourceCidr: to.Ptr("10.0.0.0/24"), + }, + }, 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 = armvirtualenclaves.EnclaveConnectionClientUpdateResponse{ + // EnclaveConnectionResource: &armvirtualenclaves.EnclaveConnectionResource{ + // Properties: &armvirtualenclaves.EnclaveConnectionProperties{ + // CommunityResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity"), + // SourceResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // SourceCidr: to.Ptr("10.0.0.0/24"), + // DestinationEndpointID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/virtualenclaves/TestMyEnclave/enclaveendpoints/TestMyEnclaveEndpoint"), + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/enclaveconnections/TestMyEnclaveConnection"), + // Name: to.Ptr("TestMyEnclaveConnection"), + // Type: to.Ptr("Microsoft.Mission/enclaveconnections"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/enclaveendpoints_client.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/enclaveendpoints_client.go new file mode 100644 index 000000000000..fcfc7aee8d85 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/enclaveendpoints_client.go @@ -0,0 +1,659 @@ +// 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 armvirtualenclaves + +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" +) + +// EnclaveEndpointsClient - Enclave Endpoint Interface +// Don't use this type directly, use NewEnclaveEndpointsClient() instead. +type EnclaveEndpointsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewEnclaveEndpointsClient creates a new instance of EnclaveEndpointsClient 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 NewEnclaveEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EnclaveEndpointsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &EnclaveEndpointsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a EnclaveEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - enclaveEndpointName - The name of the Enclave Endpoint Resource +// - resource - Resource create parameters. +// - options - EnclaveEndpointsClientBeginCreateOrUpdateOptions contains the optional parameters for the EnclaveEndpointsClient.BeginCreateOrUpdate +// method. +func (client *EnclaveEndpointsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, resource EnclaveEndpointResource, options *EnclaveEndpointsClientBeginCreateOrUpdateOptions) (*runtime.Poller[EnclaveEndpointsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, virtualEnclaveName, enclaveEndpointName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EnclaveEndpointsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EnclaveEndpointsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a EnclaveEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *EnclaveEndpointsClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, resource EnclaveEndpointResource, options *EnclaveEndpointsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "EnclaveEndpointsClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, virtualEnclaveName, enclaveEndpointName, 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 +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *EnclaveEndpointsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, resource EnclaveEndpointResource, _ *EnclaveEndpointsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName}" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + if enclaveEndpointName == "" { + return nil, errors.New("parameter enclaveEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enclaveEndpointName}", url.PathEscape(enclaveEndpointName)) + 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-05-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 EnclaveEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - enclaveEndpointName - The name of the Enclave Endpoint Resource +// - options - EnclaveEndpointsClientBeginDeleteOptions contains the optional parameters for the EnclaveEndpointsClient.BeginDelete +// method. +func (client *EnclaveEndpointsClient) BeginDelete(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, options *EnclaveEndpointsClientBeginDeleteOptions) (*runtime.Poller[EnclaveEndpointsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, virtualEnclaveName, enclaveEndpointName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EnclaveEndpointsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EnclaveEndpointsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a EnclaveEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *EnclaveEndpointsClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, options *EnclaveEndpointsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "EnclaveEndpointsClient.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, virtualEnclaveName, enclaveEndpointName, 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 *EnclaveEndpointsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, _ *EnclaveEndpointsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName}" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + if enclaveEndpointName == "" { + return nil, errors.New("parameter enclaveEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enclaveEndpointName}", url.PathEscape(enclaveEndpointName)) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Get a EnclaveEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - enclaveEndpointName - The name of the Enclave Endpoint Resource +// - options - EnclaveEndpointsClientGetOptions contains the optional parameters for the EnclaveEndpointsClient.Get method. +func (client *EnclaveEndpointsClient) Get(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, options *EnclaveEndpointsClientGetOptions) (EnclaveEndpointsClientGetResponse, error) { + var err error + const operationName = "EnclaveEndpointsClient.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, virtualEnclaveName, enclaveEndpointName, options) + if err != nil { + return EnclaveEndpointsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EnclaveEndpointsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EnclaveEndpointsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *EnclaveEndpointsClient) getCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, _ *EnclaveEndpointsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName}" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + if enclaveEndpointName == "" { + return nil, errors.New("parameter enclaveEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enclaveEndpointName}", url.PathEscape(enclaveEndpointName)) + 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-05-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 *EnclaveEndpointsClient) getHandleResponse(resp *http.Response) (EnclaveEndpointsClientGetResponse, error) { + result := EnclaveEndpointsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnclaveEndpointResource); err != nil { + return EnclaveEndpointsClientGetResponse{}, err + } + return result, nil +} + +// BeginHandleApprovalCreation - Callback that triggers on approval state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - enclaveEndpointName - The name of the Enclave Endpoint Resource +// - body - The content of the action request +// - options - EnclaveEndpointsClientBeginHandleApprovalCreationOptions contains the optional parameters for the EnclaveEndpointsClient.BeginHandleApprovalCreation +// method. +func (client *EnclaveEndpointsClient) BeginHandleApprovalCreation(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, body ApprovalCallbackRequest, options *EnclaveEndpointsClientBeginHandleApprovalCreationOptions) (*runtime.Poller[EnclaveEndpointsClientHandleApprovalCreationResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.handleApprovalCreation(ctx, resourceGroupName, virtualEnclaveName, enclaveEndpointName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EnclaveEndpointsClientHandleApprovalCreationResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EnclaveEndpointsClientHandleApprovalCreationResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// HandleApprovalCreation - Callback that triggers on approval state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *EnclaveEndpointsClient) handleApprovalCreation(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, body ApprovalCallbackRequest, options *EnclaveEndpointsClientBeginHandleApprovalCreationOptions) (*http.Response, error) { + var err error + const operationName = "EnclaveEndpointsClient.BeginHandleApprovalCreation" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.handleApprovalCreationCreateRequest(ctx, resourceGroupName, virtualEnclaveName, enclaveEndpointName, 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 +} + +// handleApprovalCreationCreateRequest creates the HandleApprovalCreation request. +func (client *EnclaveEndpointsClient) handleApprovalCreationCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, body ApprovalCallbackRequest, _ *EnclaveEndpointsClientBeginHandleApprovalCreationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName}/handleApprovalCreation" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + if enclaveEndpointName == "" { + return nil, errors.New("parameter enclaveEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enclaveEndpointName}", url.PathEscape(enclaveEndpointName)) + 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-05-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 +} + +// BeginHandleApprovalDeletion - Callback that triggers on approval deletion state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - enclaveEndpointName - The name of the Enclave Endpoint Resource +// - body - The content of the action request +// - options - EnclaveEndpointsClientBeginHandleApprovalDeletionOptions contains the optional parameters for the EnclaveEndpointsClient.BeginHandleApprovalDeletion +// method. +func (client *EnclaveEndpointsClient) BeginHandleApprovalDeletion(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, body ApprovalDeletionCallbackRequest, options *EnclaveEndpointsClientBeginHandleApprovalDeletionOptions) (*runtime.Poller[EnclaveEndpointsClientHandleApprovalDeletionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.handleApprovalDeletion(ctx, resourceGroupName, virtualEnclaveName, enclaveEndpointName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EnclaveEndpointsClientHandleApprovalDeletionResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EnclaveEndpointsClientHandleApprovalDeletionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// HandleApprovalDeletion - Callback that triggers on approval deletion state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *EnclaveEndpointsClient) handleApprovalDeletion(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, body ApprovalDeletionCallbackRequest, options *EnclaveEndpointsClientBeginHandleApprovalDeletionOptions) (*http.Response, error) { + var err error + const operationName = "EnclaveEndpointsClient.BeginHandleApprovalDeletion" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.handleApprovalDeletionCreateRequest(ctx, resourceGroupName, virtualEnclaveName, enclaveEndpointName, 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 +} + +// handleApprovalDeletionCreateRequest creates the HandleApprovalDeletion request. +func (client *EnclaveEndpointsClient) handleApprovalDeletionCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, body ApprovalDeletionCallbackRequest, _ *EnclaveEndpointsClientBeginHandleApprovalDeletionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName}/handleApprovalDeletion" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + if enclaveEndpointName == "" { + return nil, errors.New("parameter enclaveEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enclaveEndpointName}", url.PathEscape(enclaveEndpointName)) + 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-05-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 +} + +// NewListByEnclaveResourcePager - List EnclaveEndpointResource resources by EnclaveResource +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - options - EnclaveEndpointsClientListByEnclaveResourceOptions contains the optional parameters for the EnclaveEndpointsClient.NewListByEnclaveResourcePager +// method. +func (client *EnclaveEndpointsClient) NewListByEnclaveResourcePager(resourceGroupName string, virtualEnclaveName string, options *EnclaveEndpointsClientListByEnclaveResourceOptions) *runtime.Pager[EnclaveEndpointsClientListByEnclaveResourceResponse] { + return runtime.NewPager(runtime.PagingHandler[EnclaveEndpointsClientListByEnclaveResourceResponse]{ + More: func(page EnclaveEndpointsClientListByEnclaveResourceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EnclaveEndpointsClientListByEnclaveResourceResponse) (EnclaveEndpointsClientListByEnclaveResourceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EnclaveEndpointsClient.NewListByEnclaveResourcePager") + 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.listByEnclaveResourceCreateRequest(ctx, resourceGroupName, virtualEnclaveName, options) + }, nil) + if err != nil { + return EnclaveEndpointsClientListByEnclaveResourceResponse{}, err + } + return client.listByEnclaveResourceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByEnclaveResourceCreateRequest creates the ListByEnclaveResource request. +func (client *EnclaveEndpointsClient) listByEnclaveResourceCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, _ *EnclaveEndpointsClientListByEnclaveResourceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByEnclaveResourceHandleResponse handles the ListByEnclaveResource response. +func (client *EnclaveEndpointsClient) listByEnclaveResourceHandleResponse(resp *http.Response) (EnclaveEndpointsClientListByEnclaveResourceResponse, error) { + result := EnclaveEndpointsClientListByEnclaveResourceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnclaveEndpointResourceListResult); err != nil { + return EnclaveEndpointsClientListByEnclaveResourceResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List EnclaveEndpointResource resources by subscription ID +// +// Generated from API version 2025-05-01-preview +// - virtualEnclaveName - The name of the enclaveResource Resource +// - options - EnclaveEndpointsClientListBySubscriptionOptions contains the optional parameters for the EnclaveEndpointsClient.NewListBySubscriptionPager +// method. +func (client *EnclaveEndpointsClient) NewListBySubscriptionPager(virtualEnclaveName string, options *EnclaveEndpointsClientListBySubscriptionOptions) *runtime.Pager[EnclaveEndpointsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[EnclaveEndpointsClientListBySubscriptionResponse]{ + More: func(page EnclaveEndpointsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EnclaveEndpointsClientListBySubscriptionResponse) (EnclaveEndpointsClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EnclaveEndpointsClient.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, virtualEnclaveName, options) + }, nil) + if err != nil { + return EnclaveEndpointsClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *EnclaveEndpointsClient) listBySubscriptionCreateRequest(ctx context.Context, virtualEnclaveName string, _ *EnclaveEndpointsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + 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-05-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 *EnclaveEndpointsClient) listBySubscriptionHandleResponse(resp *http.Response) (EnclaveEndpointsClientListBySubscriptionResponse, error) { + result := EnclaveEndpointsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnclaveEndpointResourceListResult); err != nil { + return EnclaveEndpointsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a EnclaveEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - enclaveEndpointName - The name of the Enclave Endpoint Resource +// - properties - The resource properties to be updated. +// - options - EnclaveEndpointsClientBeginUpdateOptions contains the optional parameters for the EnclaveEndpointsClient.BeginUpdate +// method. +func (client *EnclaveEndpointsClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, properties EnclaveEndpointPatchModel, options *EnclaveEndpointsClientBeginUpdateOptions) (*runtime.Poller[EnclaveEndpointsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, virtualEnclaveName, enclaveEndpointName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EnclaveEndpointsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[EnclaveEndpointsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a EnclaveEndpointResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *EnclaveEndpointsClient) update(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, properties EnclaveEndpointPatchModel, options *EnclaveEndpointsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "EnclaveEndpointsClient.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, virtualEnclaveName, enclaveEndpointName, 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 *EnclaveEndpointsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, properties EnclaveEndpointPatchModel, _ *EnclaveEndpointsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/enclaveEndpoints/{enclaveEndpointName}" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + if enclaveEndpointName == "" { + return nil, errors.New("parameter enclaveEndpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{enclaveEndpointName}", url.PathEscape(enclaveEndpointName)) + 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-05-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/virtualenclaves/armvirtualenclaves/enclaveendpoints_client_example_test.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/enclaveendpoints_client_example_test.go new file mode 100644 index 000000000000..d2a800d76ef5 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/enclaveendpoints_client_example_test.go @@ -0,0 +1,418 @@ +// 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 armvirtualenclaves_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/virtualenclaves/armvirtualenclaves" + "log" +) + +// Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_CreateOrUpdate.json +func ExampleEnclaveEndpointsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnclaveEndpointsClient().BeginCreateOrUpdate(ctx, "rgopenapi", "TestMyEnclave", "TestMyEnclaveEndpoint", armvirtualenclaves.EnclaveEndpointResource{ + Properties: &armvirtualenclaves.EnclaveEndpointProperties{ + RuleCollection: []*armvirtualenclaves.EnclaveEndpointDestinationRule{ + { + EndpointRuleName: to.Ptr("54CEECEF-2C30-488E-946F-D20F414D99BA"), + Destination: to.Ptr("10.0.0.0/24"), + Ports: to.Ptr("443"), + Protocols: []*armvirtualenclaves.EnclaveEndpointProtocol{ + to.Ptr(armvirtualenclaves.EnclaveEndpointProtocolTCP), + }, + }, + }, + }, + Tags: map[string]*string{ + "sampletag": to.Ptr("samplevalue"), + }, + Location: to.Ptr("West US"), + }, 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 = armvirtualenclaves.EnclaveEndpointsClientCreateOrUpdateResponse{ + // EnclaveEndpointResource: &armvirtualenclaves.EnclaveEndpointResource{ + // Properties: &armvirtualenclaves.EnclaveEndpointProperties{ + // RuleCollection: []*armvirtualenclaves.EnclaveEndpointDestinationRule{ + // { + // EndpointRuleName: to.Ptr("54CEECEF-2C30-488E-946F-D20F414D99BA"), + // Destination: to.Ptr("10.0.0.0/24"), + // Ports: to.Ptr("443"), + // Protocols: []*armvirtualenclaves.EnclaveEndpointProtocol{ + // to.Ptr(armvirtualenclaves.EnclaveEndpointProtocolTCP), + // }, + // }, + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/virtualenclaves/TestMyEnclave/enclaveendpoints/TestMyEnclaveEndpoint"), + // Name: to.Ptr("TestMyEnclaveEndpoint"), + // Type: to.Ptr("Microsoft.Mission/virtualenclaves/enclaveendpoints"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_Delete.json +func ExampleEnclaveEndpointsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnclaveEndpointsClient().BeginDelete(ctx, "rgopenapi", "TestMyEnclave", "TestMyEnclaveEndpoint", 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-05-01-preview/EnclaveEndpoints_Get.json +func ExampleEnclaveEndpointsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEnclaveEndpointsClient().Get(ctx, "rgopenapi", "TestMyEnclave", "TestMyEnclaveEndpoint", 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 = armvirtualenclaves.EnclaveEndpointsClientGetResponse{ + // EnclaveEndpointResource: &armvirtualenclaves.EnclaveEndpointResource{ + // Properties: &armvirtualenclaves.EnclaveEndpointProperties{ + // RuleCollection: []*armvirtualenclaves.EnclaveEndpointDestinationRule{ + // { + // EndpointRuleName: to.Ptr("54CEECEF-2C30-488E-946F-D20F414D99BA"), + // Destination: to.Ptr("10.0.0.0/24"), + // Ports: to.Ptr("443"), + // Protocols: []*armvirtualenclaves.EnclaveEndpointProtocol{ + // to.Ptr(armvirtualenclaves.EnclaveEndpointProtocolTCP), + // }, + // }, + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/virtualenclaves/TestMyEnclave/enclaveendpoints/TestMyEnclaveEndpoint"), + // Name: to.Ptr("TestMyEnclaveEndpoint"), + // Type: to.Ptr("Microsoft.Mission/virtualenclaves/enclaveendpoints"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_HandleApprovalCreation.json +func ExampleEnclaveEndpointsClient_BeginHandleApprovalCreation() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnclaveEndpointsClient().BeginHandleApprovalCreation(ctx, "rgopenapi", "TestMyEnclave", "TestMyEnclaveEndpoint", armvirtualenclaves.ApprovalCallbackRequest{ + ResourceRequestAction: to.Ptr(armvirtualenclaves.ApprovalCallbackRequestResourceRequestActionCreate), + ApprovalStatus: to.Ptr(armvirtualenclaves.ApprovalCallbackRequestApprovalStatusApproved), + }, 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 = armvirtualenclaves.EnclaveEndpointsClientHandleApprovalCreationResponse{ + // ApprovalActionResponse: &armvirtualenclaves.ApprovalActionResponse{ + // Message: to.Ptr("Approval state change handled successfully."), + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_HandleApprovalDeletion.json +func ExampleEnclaveEndpointsClient_BeginHandleApprovalDeletion() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnclaveEndpointsClient().BeginHandleApprovalDeletion(ctx, "rgopenapi", "TestMyEnclave", "TestMyEnclaveEndpoint", armvirtualenclaves.ApprovalDeletionCallbackRequest{ + ResourceRequestAction: to.Ptr(armvirtualenclaves.ApprovalDeletionCallbackRequestResourceRequestActionCreate), + }, 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 = armvirtualenclaves.EnclaveEndpointsClientHandleApprovalDeletionResponse{ + // ApprovalActionResponse: &armvirtualenclaves.ApprovalActionResponse{ + // Message: to.Ptr("Approval state change handled successfully."), + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_ListByEnclaveResource.json +func ExampleEnclaveEndpointsClient_NewListByEnclaveResourcePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEnclaveEndpointsClient().NewListByEnclaveResourcePager("rgopenapi", "TestMyEnclave", 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 = armvirtualenclaves.EnclaveEndpointsClientListByEnclaveResourceResponse{ + // EnclaveEndpointResourceListResult: armvirtualenclaves.EnclaveEndpointResourceListResult{ + // Value: []*armvirtualenclaves.EnclaveEndpointResource{ + // { + // Properties: &armvirtualenclaves.EnclaveEndpointProperties{ + // RuleCollection: []*armvirtualenclaves.EnclaveEndpointDestinationRule{ + // { + // EndpointRuleName: to.Ptr("54CEECEF-2C30-488E-946F-D20F414D99BA"), + // Destination: to.Ptr("10.0.0.0/24"), + // Ports: to.Ptr("443"), + // Protocols: []*armvirtualenclaves.EnclaveEndpointProtocol{ + // to.Ptr(armvirtualenclaves.EnclaveEndpointProtocolTCP), + // }, + // }, + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/virtualenclaves/TestMyEnclave/enclaveendpoints/TestMyEnclaveEndpoint"), + // Name: to.Ptr("TestMyEnclaveEndpoint"), + // Type: to.Ptr("Microsoft.Mission/virtualenclaves/enclaveendpoints"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_ListBySubscription.json +func ExampleEnclaveEndpointsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEnclaveEndpointsClient().NewListBySubscriptionPager("TestMyEnclave", 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 = armvirtualenclaves.EnclaveEndpointsClientListBySubscriptionResponse{ + // EnclaveEndpointResourceListResult: armvirtualenclaves.EnclaveEndpointResourceListResult{ + // Value: []*armvirtualenclaves.EnclaveEndpointResource{ + // { + // Properties: &armvirtualenclaves.EnclaveEndpointProperties{ + // RuleCollection: []*armvirtualenclaves.EnclaveEndpointDestinationRule{ + // { + // EndpointRuleName: to.Ptr("54CEECEF-2C30-488E-946F-D20F414D99BA"), + // Destination: to.Ptr("10.0.0.0/24"), + // Ports: to.Ptr("443"), + // Protocols: []*armvirtualenclaves.EnclaveEndpointProtocol{ + // to.Ptr(armvirtualenclaves.EnclaveEndpointProtocolTCP), + // }, + // }, + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/virtualenclaves/TestMyEnclave/enclaveendpoints/TestMyEnclaveEndpoint"), + // Name: to.Ptr("TestMyEnclaveEndpoint"), + // Type: to.Ptr("Microsoft.Mission/virtualenclaves/enclaveendpoints"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/EnclaveEndpoints_Update.json +func ExampleEnclaveEndpointsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("73CEECEF-2C30-488E-946F-D20F414D99BA", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnclaveEndpointsClient().BeginUpdate(ctx, "rgopenapi", "TestMyEnclave", "TestMyEnclaveEndpoint", armvirtualenclaves.EnclaveEndpointPatchModel{ + Tags: map[string]*string{ + "sampletag": to.Ptr("samplevalue"), + }, + Properties: &armvirtualenclaves.EnclaveEndpointPatchProperties{ + RuleCollection: []*armvirtualenclaves.EnclaveEndpointDestinationRule{ + { + EndpointRuleName: to.Ptr("54CEECEF-2C30-488E-946F-D20F414D99BA"), + Destination: to.Ptr("10.0.0.0/24"), + Ports: to.Ptr("443"), + Protocols: []*armvirtualenclaves.EnclaveEndpointProtocol{ + to.Ptr(armvirtualenclaves.EnclaveEndpointProtocolTCP), + }, + }, + }, + }, + }, 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 = armvirtualenclaves.EnclaveEndpointsClientUpdateResponse{ + // EnclaveEndpointResource: &armvirtualenclaves.EnclaveEndpointResource{ + // Properties: &armvirtualenclaves.EnclaveEndpointProperties{ + // RuleCollection: []*armvirtualenclaves.EnclaveEndpointDestinationRule{ + // { + // EndpointRuleName: to.Ptr("54CEECEF-2C30-488E-946F-D20F414D99BA"), + // Destination: to.Ptr("10.0.0.0/24"), + // Ports: to.Ptr("443"), + // Protocols: []*armvirtualenclaves.EnclaveEndpointProtocol{ + // to.Ptr(armvirtualenclaves.EnclaveEndpointProtocolTCP), + // }, + // }, + // }, + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "sampletag": to.Ptr("samplevalue"), + // }, + // Location: to.Ptr("West US"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Mission/virtualenclaves/TestMyEnclave/enclaveendpoints/TestMyEnclaveEndpoint"), + // Name: to.Ptr("TestMyEnclaveEndpoint"), + // Type: to.Ptr("Microsoft.Mission/virtualenclaves/enclaveendpoints"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/approval_server.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/approval_server.go new file mode 100644 index 000000000000..1369027dd1f8 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/approval_server.go @@ -0,0 +1,389 @@ +// 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/virtualenclaves/armvirtualenclaves" + "net/http" + "net/url" + "regexp" +) + +// ApprovalServer is a fake server for instances of the armvirtualenclaves.ApprovalClient type. +type ApprovalServer struct { + // BeginCreateOrUpdate is the fake for method ApprovalClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceURI string, approvalName string, resource armvirtualenclaves.ApprovalResource, options *armvirtualenclaves.ApprovalClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.ApprovalClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ApprovalClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceURI string, approvalName string, options *armvirtualenclaves.ApprovalClientBeginDeleteOptions) (resp azfake.PollerResponder[armvirtualenclaves.ApprovalClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ApprovalClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceURI string, approvalName string, options *armvirtualenclaves.ApprovalClientGetOptions) (resp azfake.Responder[armvirtualenclaves.ApprovalClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByParentPager is the fake for method ApprovalClient.NewListByParentPager + // HTTP status codes to indicate success: http.StatusOK + NewListByParentPager func(resourceURI string, options *armvirtualenclaves.ApprovalClientListByParentOptions) (resp azfake.PagerResponder[armvirtualenclaves.ApprovalClientListByParentResponse]) + + // BeginNotifyInitiator is the fake for method ApprovalClient.BeginNotifyInitiator + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginNotifyInitiator func(ctx context.Context, resourceURI string, approvalName string, body armvirtualenclaves.ApprovalActionRequest, options *armvirtualenclaves.ApprovalClientBeginNotifyInitiatorOptions) (resp azfake.PollerResponder[armvirtualenclaves.ApprovalClientNotifyInitiatorResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method ApprovalClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceURI string, approvalName string, properties armvirtualenclaves.ApprovalPatchModel, options *armvirtualenclaves.ApprovalClientBeginUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.ApprovalClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewApprovalServerTransport creates a new instance of ApprovalServerTransport with the provided implementation. +// The returned ApprovalServerTransport instance is connected to an instance of armvirtualenclaves.ApprovalClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewApprovalServerTransport(srv *ApprovalServer) *ApprovalServerTransport { + return &ApprovalServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.ApprovalClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armvirtualenclaves.ApprovalClientDeleteResponse]](), + newListByParentPager: newTracker[azfake.PagerResponder[armvirtualenclaves.ApprovalClientListByParentResponse]](), + beginNotifyInitiator: newTracker[azfake.PollerResponder[armvirtualenclaves.ApprovalClientNotifyInitiatorResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.ApprovalClientUpdateResponse]](), + } +} + +// ApprovalServerTransport connects instances of armvirtualenclaves.ApprovalClient to instances of ApprovalServer. +// Don't use this type directly, use NewApprovalServerTransport instead. +type ApprovalServerTransport struct { + srv *ApprovalServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.ApprovalClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armvirtualenclaves.ApprovalClientDeleteResponse]] + newListByParentPager *tracker[azfake.PagerResponder[armvirtualenclaves.ApprovalClientListByParentResponse]] + beginNotifyInitiator *tracker[azfake.PollerResponder[armvirtualenclaves.ApprovalClientNotifyInitiatorResponse]] + beginUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.ApprovalClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for ApprovalServerTransport. +func (a *ApprovalServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return a.dispatchToMethodFake(req, method) +} + +func (a *ApprovalServerTransport) 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 approvalServerTransportInterceptor != nil { + res.resp, res.err, intercepted = approvalServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ApprovalClient.BeginCreateOrUpdate": + res.resp, res.err = a.dispatchBeginCreateOrUpdate(req) + case "ApprovalClient.BeginDelete": + res.resp, res.err = a.dispatchBeginDelete(req) + case "ApprovalClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "ApprovalClient.NewListByParentPager": + res.resp, res.err = a.dispatchNewListByParentPager(req) + case "ApprovalClient.BeginNotifyInitiator": + res.resp, res.err = a.dispatchBeginNotifyInitiator(req) + case "ApprovalClient.BeginUpdate": + res.resp, res.err = a.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (a *ApprovalServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if a.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := a.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/approvals/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armvirtualenclaves.ApprovalResource](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + approvalNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("approvalName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginCreateOrUpdate(req.Context(), resourceURIParam, approvalNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + a.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + a.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + a.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (a *ApprovalServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if a.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := a.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/approvals/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + approvalNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("approvalName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginDelete(req.Context(), resourceURIParam, approvalNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + a.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + a.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + a.beginDelete.remove(req) + } + + return resp, nil +} + +func (a *ApprovalServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/approvals/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + approvalNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("approvalName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceURIParam, approvalNameParam, 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).ApprovalResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *ApprovalServerTransport) dispatchNewListByParentPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByParentPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByParentPager not implemented")} + } + newListByParentPager := a.newListByParentPager.get(req) + if newListByParentPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/approvals` + 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) + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListByParentPager(resourceURIParam, nil) + newListByParentPager = &resp + a.newListByParentPager.add(req, newListByParentPager) + server.PagerResponderInjectNextLinks(newListByParentPager, req, func(page *armvirtualenclaves.ApprovalClientListByParentResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByParentPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByParentPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByParentPager) { + a.newListByParentPager.remove(req) + } + return resp, nil +} + +func (a *ApprovalServerTransport) dispatchBeginNotifyInitiator(req *http.Request) (*http.Response, error) { + if a.srv.BeginNotifyInitiator == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginNotifyInitiator not implemented")} + } + beginNotifyInitiator := a.beginNotifyInitiator.get(req) + if beginNotifyInitiator == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/approvals/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/notifyInitiator` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armvirtualenclaves.ApprovalActionRequest](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + approvalNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("approvalName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginNotifyInitiator(req.Context(), resourceURIParam, approvalNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginNotifyInitiator = &respr + a.beginNotifyInitiator.add(req, beginNotifyInitiator) + } + + resp, err := server.PollerResponderNext(beginNotifyInitiator, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + a.beginNotifyInitiator.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginNotifyInitiator) { + a.beginNotifyInitiator.remove(req) + } + + return resp, nil +} + +func (a *ApprovalServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if a.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := a.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/approvals/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armvirtualenclaves.ApprovalPatchModel](req) + if err != nil { + return nil, err + } + resourceURIParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceUri")]) + if err != nil { + return nil, err + } + approvalNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("approvalName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginUpdate(req.Context(), resourceURIParam, approvalNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + a.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + a.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) { + a.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to ApprovalServerTransport +var approvalServerTransportInterceptor 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/virtualenclaves/armvirtualenclaves/fake/community_server.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/community_server.go new file mode 100644 index 000000000000..5415a0ea587c --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/community_server.go @@ -0,0 +1,417 @@ +// 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/virtualenclaves/armvirtualenclaves" + "net/http" + "net/url" + "regexp" +) + +// CommunityServer is a fake server for instances of the armvirtualenclaves.CommunityClient type. +type CommunityServer struct { + // CheckAddressSpaceAvailability is the fake for method CommunityClient.CheckAddressSpaceAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckAddressSpaceAvailability func(ctx context.Context, resourceGroupName string, communityName string, checkAddressSpaceAvailabilityRequest armvirtualenclaves.CheckAddressSpaceAvailabilityRequest, options *armvirtualenclaves.CommunityClientCheckAddressSpaceAvailabilityOptions) (resp azfake.Responder[armvirtualenclaves.CommunityClientCheckAddressSpaceAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method CommunityClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, communityName string, resource armvirtualenclaves.CommunityResource, options *armvirtualenclaves.CommunityClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.CommunityClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method CommunityClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, communityName string, options *armvirtualenclaves.CommunityClientBeginDeleteOptions) (resp azfake.PollerResponder[armvirtualenclaves.CommunityClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method CommunityClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, communityName string, options *armvirtualenclaves.CommunityClientGetOptions) (resp azfake.Responder[armvirtualenclaves.CommunityClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method CommunityClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armvirtualenclaves.CommunityClientListByResourceGroupOptions) (resp azfake.PagerResponder[armvirtualenclaves.CommunityClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method CommunityClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armvirtualenclaves.CommunityClientListBySubscriptionOptions) (resp azfake.PagerResponder[armvirtualenclaves.CommunityClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method CommunityClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, communityName string, properties armvirtualenclaves.CommunityPatchModel, options *armvirtualenclaves.CommunityClientBeginUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.CommunityClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewCommunityServerTransport creates a new instance of CommunityServerTransport with the provided implementation. +// The returned CommunityServerTransport instance is connected to an instance of armvirtualenclaves.CommunityClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewCommunityServerTransport(srv *CommunityServer) *CommunityServerTransport { + return &CommunityServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.CommunityClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armvirtualenclaves.CommunityClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armvirtualenclaves.CommunityClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armvirtualenclaves.CommunityClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.CommunityClientUpdateResponse]](), + } +} + +// CommunityServerTransport connects instances of armvirtualenclaves.CommunityClient to instances of CommunityServer. +// Don't use this type directly, use NewCommunityServerTransport instead. +type CommunityServerTransport struct { + srv *CommunityServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.CommunityClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armvirtualenclaves.CommunityClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armvirtualenclaves.CommunityClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armvirtualenclaves.CommunityClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.CommunityClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for CommunityServerTransport. +func (c *CommunityServerTransport) 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 c.dispatchToMethodFake(req, method) +} + +func (c *CommunityServerTransport) 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 communityServerTransportInterceptor != nil { + res.resp, res.err, intercepted = communityServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "CommunityClient.CheckAddressSpaceAvailability": + res.resp, res.err = c.dispatchCheckAddressSpaceAvailability(req) + case "CommunityClient.BeginCreateOrUpdate": + res.resp, res.err = c.dispatchBeginCreateOrUpdate(req) + case "CommunityClient.BeginDelete": + res.resp, res.err = c.dispatchBeginDelete(req) + case "CommunityClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "CommunityClient.NewListByResourceGroupPager": + res.resp, res.err = c.dispatchNewListByResourceGroupPager(req) + case "CommunityClient.NewListBySubscriptionPager": + res.resp, res.err = c.dispatchNewListBySubscriptionPager(req) + case "CommunityClient.BeginUpdate": + res.resp, res.err = c.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 (c *CommunityServerTransport) dispatchCheckAddressSpaceAvailability(req *http.Request) (*http.Response, error) { + if c.srv.CheckAddressSpaceAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckAddressSpaceAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkAddressSpaceAvailability` + 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[armvirtualenclaves.CheckAddressSpaceAvailabilityRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.CheckAddressSpaceAvailability(req.Context(), resourceGroupNameParam, communityNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckAddressSpaceAvailabilityResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CommunityServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := c.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?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[armvirtualenclaves.CommunityResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, communityNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + c.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + c.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + c.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (c *CommunityServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if c.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := c.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?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 + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginDelete(req.Context(), resourceGroupNameParam, communityNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + c.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) { + c.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) { + c.beginDelete.remove(req) + } + + return resp, nil +} + +func (c *CommunityServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.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\.Mission/communities/(?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 + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, communityNameParam, 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).CommunityResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CommunityServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := c.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities` + 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 := c.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + c.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armvirtualenclaves.CommunityClientListByResourceGroupResponse, 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) { + c.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + c.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (c *CommunityServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := c.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities` + 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 := c.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + c.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armvirtualenclaves.CommunityClientListBySubscriptionResponse, 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) { + c.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + c.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (c *CommunityServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := c.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?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[armvirtualenclaves.CommunityPatchModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginUpdate(req.Context(), resourceGroupNameParam, communityNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + c.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) { + c.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) { + c.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to CommunityServerTransport +var communityServerTransportInterceptor 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/virtualenclaves/armvirtualenclaves/fake/communityendpoints_server.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/communityendpoints_server.go new file mode 100644 index 000000000000..01c427b4cbf9 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/communityendpoints_server.go @@ -0,0 +1,518 @@ +// 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/virtualenclaves/armvirtualenclaves" + "net/http" + "net/url" + "regexp" +) + +// CommunityEndpointsServer is a fake server for instances of the armvirtualenclaves.CommunityEndpointsClient type. +type CommunityEndpointsServer struct { + // BeginCreateOrUpdate is the fake for method CommunityEndpointsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, resource armvirtualenclaves.CommunityEndpointResource, options *armvirtualenclaves.CommunityEndpointsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method CommunityEndpointsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, options *armvirtualenclaves.CommunityEndpointsClientBeginDeleteOptions) (resp azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method CommunityEndpointsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, options *armvirtualenclaves.CommunityEndpointsClientGetOptions) (resp azfake.Responder[armvirtualenclaves.CommunityEndpointsClientGetResponse], errResp azfake.ErrorResponder) + + // BeginHandleApprovalCreation is the fake for method CommunityEndpointsClient.BeginHandleApprovalCreation + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginHandleApprovalCreation func(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, body armvirtualenclaves.ApprovalCallbackRequest, options *armvirtualenclaves.CommunityEndpointsClientBeginHandleApprovalCreationOptions) (resp azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientHandleApprovalCreationResponse], errResp azfake.ErrorResponder) + + // BeginHandleApprovalDeletion is the fake for method CommunityEndpointsClient.BeginHandleApprovalDeletion + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginHandleApprovalDeletion func(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, body armvirtualenclaves.ApprovalDeletionCallbackRequest, options *armvirtualenclaves.CommunityEndpointsClientBeginHandleApprovalDeletionOptions) (resp azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientHandleApprovalDeletionResponse], errResp azfake.ErrorResponder) + + // NewListByCommunityResourcePager is the fake for method CommunityEndpointsClient.NewListByCommunityResourcePager + // HTTP status codes to indicate success: http.StatusOK + NewListByCommunityResourcePager func(resourceGroupName string, communityName string, options *armvirtualenclaves.CommunityEndpointsClientListByCommunityResourceOptions) (resp azfake.PagerResponder[armvirtualenclaves.CommunityEndpointsClientListByCommunityResourceResponse]) + + // NewListBySubscriptionPager is the fake for method CommunityEndpointsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(communityName string, options *armvirtualenclaves.CommunityEndpointsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armvirtualenclaves.CommunityEndpointsClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method CommunityEndpointsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, communityName string, communityEndpointName string, properties armvirtualenclaves.CommunityEndpointPatchModel, options *armvirtualenclaves.CommunityEndpointsClientBeginUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewCommunityEndpointsServerTransport creates a new instance of CommunityEndpointsServerTransport with the provided implementation. +// The returned CommunityEndpointsServerTransport instance is connected to an instance of armvirtualenclaves.CommunityEndpointsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewCommunityEndpointsServerTransport(srv *CommunityEndpointsServer) *CommunityEndpointsServerTransport { + return &CommunityEndpointsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientDeleteResponse]](), + beginHandleApprovalCreation: newTracker[azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientHandleApprovalCreationResponse]](), + beginHandleApprovalDeletion: newTracker[azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientHandleApprovalDeletionResponse]](), + newListByCommunityResourcePager: newTracker[azfake.PagerResponder[armvirtualenclaves.CommunityEndpointsClientListByCommunityResourceResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armvirtualenclaves.CommunityEndpointsClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientUpdateResponse]](), + } +} + +// CommunityEndpointsServerTransport connects instances of armvirtualenclaves.CommunityEndpointsClient to instances of CommunityEndpointsServer. +// Don't use this type directly, use NewCommunityEndpointsServerTransport instead. +type CommunityEndpointsServerTransport struct { + srv *CommunityEndpointsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientDeleteResponse]] + beginHandleApprovalCreation *tracker[azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientHandleApprovalCreationResponse]] + beginHandleApprovalDeletion *tracker[azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientHandleApprovalDeletionResponse]] + newListByCommunityResourcePager *tracker[azfake.PagerResponder[armvirtualenclaves.CommunityEndpointsClientListByCommunityResourceResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armvirtualenclaves.CommunityEndpointsClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.CommunityEndpointsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for CommunityEndpointsServerTransport. +func (c *CommunityEndpointsServerTransport) 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 c.dispatchToMethodFake(req, method) +} + +func (c *CommunityEndpointsServerTransport) 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 communityEndpointsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = communityEndpointsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "CommunityEndpointsClient.BeginCreateOrUpdate": + res.resp, res.err = c.dispatchBeginCreateOrUpdate(req) + case "CommunityEndpointsClient.BeginDelete": + res.resp, res.err = c.dispatchBeginDelete(req) + case "CommunityEndpointsClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "CommunityEndpointsClient.BeginHandleApprovalCreation": + res.resp, res.err = c.dispatchBeginHandleApprovalCreation(req) + case "CommunityEndpointsClient.BeginHandleApprovalDeletion": + res.resp, res.err = c.dispatchBeginHandleApprovalDeletion(req) + case "CommunityEndpointsClient.NewListByCommunityResourcePager": + res.resp, res.err = c.dispatchNewListByCommunityResourcePager(req) + case "CommunityEndpointsClient.NewListBySubscriptionPager": + res.resp, res.err = c.dispatchNewListBySubscriptionPager(req) + case "CommunityEndpointsClient.BeginUpdate": + res.resp, res.err = c.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 (c *CommunityEndpointsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := c.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/communityEndpoints/(?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[armvirtualenclaves.CommunityEndpointResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + communityEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, communityNameParam, communityEndpointNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + c.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + c.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + c.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (c *CommunityEndpointsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if c.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := c.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/communityEndpoints/(?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 + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + communityEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginDelete(req.Context(), resourceGroupNameParam, communityNameParam, communityEndpointNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + c.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) { + c.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) { + c.beginDelete.remove(req) + } + + return resp, nil +} + +func (c *CommunityEndpointsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.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\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/communityEndpoints/(?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 + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + communityEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, communityNameParam, communityEndpointNameParam, 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).CommunityEndpointResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CommunityEndpointsServerTransport) dispatchBeginHandleApprovalCreation(req *http.Request) (*http.Response, error) { + if c.srv.BeginHandleApprovalCreation == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginHandleApprovalCreation not implemented")} + } + beginHandleApprovalCreation := c.beginHandleApprovalCreation.get(req) + if beginHandleApprovalCreation == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/communityEndpoints/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/handleApprovalCreation` + 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[armvirtualenclaves.ApprovalCallbackRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + communityEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginHandleApprovalCreation(req.Context(), resourceGroupNameParam, communityNameParam, communityEndpointNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginHandleApprovalCreation = &respr + c.beginHandleApprovalCreation.add(req, beginHandleApprovalCreation) + } + + resp, err := server.PollerResponderNext(beginHandleApprovalCreation, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginHandleApprovalCreation.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginHandleApprovalCreation) { + c.beginHandleApprovalCreation.remove(req) + } + + return resp, nil +} + +func (c *CommunityEndpointsServerTransport) dispatchBeginHandleApprovalDeletion(req *http.Request) (*http.Response, error) { + if c.srv.BeginHandleApprovalDeletion == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginHandleApprovalDeletion not implemented")} + } + beginHandleApprovalDeletion := c.beginHandleApprovalDeletion.get(req) + if beginHandleApprovalDeletion == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/communityEndpoints/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/handleApprovalDeletion` + 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[armvirtualenclaves.ApprovalDeletionCallbackRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + communityEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginHandleApprovalDeletion(req.Context(), resourceGroupNameParam, communityNameParam, communityEndpointNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginHandleApprovalDeletion = &respr + c.beginHandleApprovalDeletion.add(req, beginHandleApprovalDeletion) + } + + resp, err := server.PollerResponderNext(beginHandleApprovalDeletion, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginHandleApprovalDeletion.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginHandleApprovalDeletion) { + c.beginHandleApprovalDeletion.remove(req) + } + + return resp, nil +} + +func (c *CommunityEndpointsServerTransport) dispatchNewListByCommunityResourcePager(req *http.Request) (*http.Response, error) { + if c.srv.NewListByCommunityResourcePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByCommunityResourcePager not implemented")} + } + newListByCommunityResourcePager := c.newListByCommunityResourcePager.get(req) + if newListByCommunityResourcePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/communityEndpoints` + 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 + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListByCommunityResourcePager(resourceGroupNameParam, communityNameParam, nil) + newListByCommunityResourcePager = &resp + c.newListByCommunityResourcePager.add(req, newListByCommunityResourcePager) + server.PagerResponderInjectNextLinks(newListByCommunityResourcePager, req, func(page *armvirtualenclaves.CommunityEndpointsClientListByCommunityResourceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByCommunityResourcePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListByCommunityResourcePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByCommunityResourcePager) { + c.newListByCommunityResourcePager.remove(req) + } + return resp, nil +} + +func (c *CommunityEndpointsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := c.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/communityEndpoints` + 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) + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListBySubscriptionPager(communityNameParam, nil) + newListBySubscriptionPager = &resp + c.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armvirtualenclaves.CommunityEndpointsClientListBySubscriptionResponse, 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) { + c.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + c.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (c *CommunityEndpointsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := c.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/communityEndpoints/(?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[armvirtualenclaves.CommunityEndpointPatchModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + communityEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginUpdate(req.Context(), resourceGroupNameParam, communityNameParam, communityEndpointNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + c.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) { + c.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) { + c.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to CommunityEndpointsServerTransport +var communityEndpointsServerTransportInterceptor 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/virtualenclaves/armvirtualenclaves/fake/enclaveconnection_server.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/enclaveconnection_server.go new file mode 100644 index 000000000000..4e2e4ea16a7e --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/enclaveconnection_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/virtualenclaves/armvirtualenclaves" + "net/http" + "net/url" + "regexp" +) + +// EnclaveConnectionServer is a fake server for instances of the armvirtualenclaves.EnclaveConnectionClient type. +type EnclaveConnectionServer struct { + // BeginCreateOrUpdate is the fake for method EnclaveConnectionClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, enclaveConnectionName string, resource armvirtualenclaves.EnclaveConnectionResource, options *armvirtualenclaves.EnclaveConnectionClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method EnclaveConnectionClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, enclaveConnectionName string, options *armvirtualenclaves.EnclaveConnectionClientBeginDeleteOptions) (resp azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method EnclaveConnectionClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, enclaveConnectionName string, options *armvirtualenclaves.EnclaveConnectionClientGetOptions) (resp azfake.Responder[armvirtualenclaves.EnclaveConnectionClientGetResponse], errResp azfake.ErrorResponder) + + // BeginHandleApprovalCreation is the fake for method EnclaveConnectionClient.BeginHandleApprovalCreation + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginHandleApprovalCreation func(ctx context.Context, resourceGroupName string, enclaveConnectionName string, body armvirtualenclaves.ApprovalCallbackRequest, options *armvirtualenclaves.EnclaveConnectionClientBeginHandleApprovalCreationOptions) (resp azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientHandleApprovalCreationResponse], errResp azfake.ErrorResponder) + + // BeginHandleApprovalDeletion is the fake for method EnclaveConnectionClient.BeginHandleApprovalDeletion + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginHandleApprovalDeletion func(ctx context.Context, resourceGroupName string, enclaveConnectionName string, body armvirtualenclaves.ApprovalDeletionCallbackRequest, options *armvirtualenclaves.EnclaveConnectionClientBeginHandleApprovalDeletionOptions) (resp azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientHandleApprovalDeletionResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method EnclaveConnectionClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armvirtualenclaves.EnclaveConnectionClientListByResourceGroupOptions) (resp azfake.PagerResponder[armvirtualenclaves.EnclaveConnectionClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method EnclaveConnectionClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armvirtualenclaves.EnclaveConnectionClientListBySubscriptionOptions) (resp azfake.PagerResponder[armvirtualenclaves.EnclaveConnectionClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method EnclaveConnectionClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, enclaveConnectionName string, properties armvirtualenclaves.EnclaveConnectionPatchModel, options *armvirtualenclaves.EnclaveConnectionClientBeginUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewEnclaveConnectionServerTransport creates a new instance of EnclaveConnectionServerTransport with the provided implementation. +// The returned EnclaveConnectionServerTransport instance is connected to an instance of armvirtualenclaves.EnclaveConnectionClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewEnclaveConnectionServerTransport(srv *EnclaveConnectionServer) *EnclaveConnectionServerTransport { + return &EnclaveConnectionServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientDeleteResponse]](), + beginHandleApprovalCreation: newTracker[azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientHandleApprovalCreationResponse]](), + beginHandleApprovalDeletion: newTracker[azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientHandleApprovalDeletionResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armvirtualenclaves.EnclaveConnectionClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armvirtualenclaves.EnclaveConnectionClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientUpdateResponse]](), + } +} + +// EnclaveConnectionServerTransport connects instances of armvirtualenclaves.EnclaveConnectionClient to instances of EnclaveConnectionServer. +// Don't use this type directly, use NewEnclaveConnectionServerTransport instead. +type EnclaveConnectionServerTransport struct { + srv *EnclaveConnectionServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientDeleteResponse]] + beginHandleApprovalCreation *tracker[azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientHandleApprovalCreationResponse]] + beginHandleApprovalDeletion *tracker[azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientHandleApprovalDeletionResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armvirtualenclaves.EnclaveConnectionClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armvirtualenclaves.EnclaveConnectionClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.EnclaveConnectionClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for EnclaveConnectionServerTransport. +func (e *EnclaveConnectionServerTransport) 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 *EnclaveConnectionServerTransport) 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 enclaveConnectionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = enclaveConnectionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "EnclaveConnectionClient.BeginCreateOrUpdate": + res.resp, res.err = e.dispatchBeginCreateOrUpdate(req) + case "EnclaveConnectionClient.BeginDelete": + res.resp, res.err = e.dispatchBeginDelete(req) + case "EnclaveConnectionClient.Get": + res.resp, res.err = e.dispatchGet(req) + case "EnclaveConnectionClient.BeginHandleApprovalCreation": + res.resp, res.err = e.dispatchBeginHandleApprovalCreation(req) + case "EnclaveConnectionClient.BeginHandleApprovalDeletion": + res.resp, res.err = e.dispatchBeginHandleApprovalDeletion(req) + case "EnclaveConnectionClient.NewListByResourceGroupPager": + res.resp, res.err = e.dispatchNewListByResourceGroupPager(req) + case "EnclaveConnectionClient.NewListBySubscriptionPager": + res.resp, res.err = e.dispatchNewListBySubscriptionPager(req) + case "EnclaveConnectionClient.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 *EnclaveConnectionServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if e.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := e.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/enclaveConnections/(?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[armvirtualenclaves.EnclaveConnectionResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + enclaveConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enclaveConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, enclaveConnectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + e.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + e.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + e.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (e *EnclaveConnectionServerTransport) 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\.Mission/enclaveConnections/(?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 + } + enclaveConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enclaveConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginDelete(req.Context(), resourceGroupNameParam, enclaveConnectionNameParam, 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 *EnclaveConnectionServerTransport) 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\.Mission/enclaveConnections/(?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 + } + enclaveConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enclaveConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameParam, enclaveConnectionNameParam, 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).EnclaveConnectionResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EnclaveConnectionServerTransport) dispatchBeginHandleApprovalCreation(req *http.Request) (*http.Response, error) { + if e.srv.BeginHandleApprovalCreation == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginHandleApprovalCreation not implemented")} + } + beginHandleApprovalCreation := e.beginHandleApprovalCreation.get(req) + if beginHandleApprovalCreation == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/enclaveConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/handleApprovalCreation` + 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[armvirtualenclaves.ApprovalCallbackRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + enclaveConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enclaveConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginHandleApprovalCreation(req.Context(), resourceGroupNameParam, enclaveConnectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginHandleApprovalCreation = &respr + e.beginHandleApprovalCreation.add(req, beginHandleApprovalCreation) + } + + resp, err := server.PollerResponderNext(beginHandleApprovalCreation, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + e.beginHandleApprovalCreation.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginHandleApprovalCreation) { + e.beginHandleApprovalCreation.remove(req) + } + + return resp, nil +} + +func (e *EnclaveConnectionServerTransport) dispatchBeginHandleApprovalDeletion(req *http.Request) (*http.Response, error) { + if e.srv.BeginHandleApprovalDeletion == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginHandleApprovalDeletion not implemented")} + } + beginHandleApprovalDeletion := e.beginHandleApprovalDeletion.get(req) + if beginHandleApprovalDeletion == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/enclaveConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/handleApprovalDeletion` + 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[armvirtualenclaves.ApprovalDeletionCallbackRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + enclaveConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enclaveConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginHandleApprovalDeletion(req.Context(), resourceGroupNameParam, enclaveConnectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginHandleApprovalDeletion = &respr + e.beginHandleApprovalDeletion.add(req, beginHandleApprovalDeletion) + } + + resp, err := server.PollerResponderNext(beginHandleApprovalDeletion, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + e.beginHandleApprovalDeletion.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginHandleApprovalDeletion) { + e.beginHandleApprovalDeletion.remove(req) + } + + return resp, nil +} + +func (e *EnclaveConnectionServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := e.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/enclaveConnections` + 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 := e.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + e.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armvirtualenclaves.EnclaveConnectionClientListByResourceGroupResponse, 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) { + e.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + e.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (e *EnclaveConnectionServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := e.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/enclaveConnections` + 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 := e.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + e.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armvirtualenclaves.EnclaveConnectionClientListBySubscriptionResponse, 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) { + e.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + e.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (e *EnclaveConnectionServerTransport) 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\.Mission/enclaveConnections/(?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[armvirtualenclaves.EnclaveConnectionPatchModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + enclaveConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enclaveConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginUpdate(req.Context(), resourceGroupNameParam, enclaveConnectionNameParam, 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 EnclaveConnectionServerTransport +var enclaveConnectionServerTransportInterceptor 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/virtualenclaves/armvirtualenclaves/fake/enclaveendpoints_server.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/enclaveendpoints_server.go new file mode 100644 index 000000000000..cba935ff038a --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/enclaveendpoints_server.go @@ -0,0 +1,518 @@ +// 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/virtualenclaves/armvirtualenclaves" + "net/http" + "net/url" + "regexp" +) + +// EnclaveEndpointsServer is a fake server for instances of the armvirtualenclaves.EnclaveEndpointsClient type. +type EnclaveEndpointsServer struct { + // BeginCreateOrUpdate is the fake for method EnclaveEndpointsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, resource armvirtualenclaves.EnclaveEndpointResource, options *armvirtualenclaves.EnclaveEndpointsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method EnclaveEndpointsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, options *armvirtualenclaves.EnclaveEndpointsClientBeginDeleteOptions) (resp azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method EnclaveEndpointsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, options *armvirtualenclaves.EnclaveEndpointsClientGetOptions) (resp azfake.Responder[armvirtualenclaves.EnclaveEndpointsClientGetResponse], errResp azfake.ErrorResponder) + + // BeginHandleApprovalCreation is the fake for method EnclaveEndpointsClient.BeginHandleApprovalCreation + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginHandleApprovalCreation func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, body armvirtualenclaves.ApprovalCallbackRequest, options *armvirtualenclaves.EnclaveEndpointsClientBeginHandleApprovalCreationOptions) (resp azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientHandleApprovalCreationResponse], errResp azfake.ErrorResponder) + + // BeginHandleApprovalDeletion is the fake for method EnclaveEndpointsClient.BeginHandleApprovalDeletion + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginHandleApprovalDeletion func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, body armvirtualenclaves.ApprovalDeletionCallbackRequest, options *armvirtualenclaves.EnclaveEndpointsClientBeginHandleApprovalDeletionOptions) (resp azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientHandleApprovalDeletionResponse], errResp azfake.ErrorResponder) + + // NewListByEnclaveResourcePager is the fake for method EnclaveEndpointsClient.NewListByEnclaveResourcePager + // HTTP status codes to indicate success: http.StatusOK + NewListByEnclaveResourcePager func(resourceGroupName string, virtualEnclaveName string, options *armvirtualenclaves.EnclaveEndpointsClientListByEnclaveResourceOptions) (resp azfake.PagerResponder[armvirtualenclaves.EnclaveEndpointsClientListByEnclaveResourceResponse]) + + // NewListBySubscriptionPager is the fake for method EnclaveEndpointsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(virtualEnclaveName string, options *armvirtualenclaves.EnclaveEndpointsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armvirtualenclaves.EnclaveEndpointsClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method EnclaveEndpointsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, enclaveEndpointName string, properties armvirtualenclaves.EnclaveEndpointPatchModel, options *armvirtualenclaves.EnclaveEndpointsClientBeginUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewEnclaveEndpointsServerTransport creates a new instance of EnclaveEndpointsServerTransport with the provided implementation. +// The returned EnclaveEndpointsServerTransport instance is connected to an instance of armvirtualenclaves.EnclaveEndpointsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewEnclaveEndpointsServerTransport(srv *EnclaveEndpointsServer) *EnclaveEndpointsServerTransport { + return &EnclaveEndpointsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientDeleteResponse]](), + beginHandleApprovalCreation: newTracker[azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientHandleApprovalCreationResponse]](), + beginHandleApprovalDeletion: newTracker[azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientHandleApprovalDeletionResponse]](), + newListByEnclaveResourcePager: newTracker[azfake.PagerResponder[armvirtualenclaves.EnclaveEndpointsClientListByEnclaveResourceResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armvirtualenclaves.EnclaveEndpointsClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientUpdateResponse]](), + } +} + +// EnclaveEndpointsServerTransport connects instances of armvirtualenclaves.EnclaveEndpointsClient to instances of EnclaveEndpointsServer. +// Don't use this type directly, use NewEnclaveEndpointsServerTransport instead. +type EnclaveEndpointsServerTransport struct { + srv *EnclaveEndpointsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientDeleteResponse]] + beginHandleApprovalCreation *tracker[azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientHandleApprovalCreationResponse]] + beginHandleApprovalDeletion *tracker[azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientHandleApprovalDeletionResponse]] + newListByEnclaveResourcePager *tracker[azfake.PagerResponder[armvirtualenclaves.EnclaveEndpointsClientListByEnclaveResourceResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armvirtualenclaves.EnclaveEndpointsClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.EnclaveEndpointsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for EnclaveEndpointsServerTransport. +func (e *EnclaveEndpointsServerTransport) 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 *EnclaveEndpointsServerTransport) 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 enclaveEndpointsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = enclaveEndpointsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "EnclaveEndpointsClient.BeginCreateOrUpdate": + res.resp, res.err = e.dispatchBeginCreateOrUpdate(req) + case "EnclaveEndpointsClient.BeginDelete": + res.resp, res.err = e.dispatchBeginDelete(req) + case "EnclaveEndpointsClient.Get": + res.resp, res.err = e.dispatchGet(req) + case "EnclaveEndpointsClient.BeginHandleApprovalCreation": + res.resp, res.err = e.dispatchBeginHandleApprovalCreation(req) + case "EnclaveEndpointsClient.BeginHandleApprovalDeletion": + res.resp, res.err = e.dispatchBeginHandleApprovalDeletion(req) + case "EnclaveEndpointsClient.NewListByEnclaveResourcePager": + res.resp, res.err = e.dispatchNewListByEnclaveResourcePager(req) + case "EnclaveEndpointsClient.NewListBySubscriptionPager": + res.resp, res.err = e.dispatchNewListBySubscriptionPager(req) + case "EnclaveEndpointsClient.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 *EnclaveEndpointsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if e.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := e.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enclaveEndpoints/(?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[armvirtualenclaves.EnclaveEndpointResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + enclaveEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enclaveEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, enclaveEndpointNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + e.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + e.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + e.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (e *EnclaveEndpointsServerTransport) 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\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enclaveEndpoints/(?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 + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + enclaveEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enclaveEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginDelete(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, enclaveEndpointNameParam, 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 *EnclaveEndpointsServerTransport) 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\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enclaveEndpoints/(?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 + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + enclaveEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enclaveEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, enclaveEndpointNameParam, 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).EnclaveEndpointResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EnclaveEndpointsServerTransport) dispatchBeginHandleApprovalCreation(req *http.Request) (*http.Response, error) { + if e.srv.BeginHandleApprovalCreation == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginHandleApprovalCreation not implemented")} + } + beginHandleApprovalCreation := e.beginHandleApprovalCreation.get(req) + if beginHandleApprovalCreation == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enclaveEndpoints/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/handleApprovalCreation` + 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[armvirtualenclaves.ApprovalCallbackRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + enclaveEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enclaveEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginHandleApprovalCreation(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, enclaveEndpointNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginHandleApprovalCreation = &respr + e.beginHandleApprovalCreation.add(req, beginHandleApprovalCreation) + } + + resp, err := server.PollerResponderNext(beginHandleApprovalCreation, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + e.beginHandleApprovalCreation.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginHandleApprovalCreation) { + e.beginHandleApprovalCreation.remove(req) + } + + return resp, nil +} + +func (e *EnclaveEndpointsServerTransport) dispatchBeginHandleApprovalDeletion(req *http.Request) (*http.Response, error) { + if e.srv.BeginHandleApprovalDeletion == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginHandleApprovalDeletion not implemented")} + } + beginHandleApprovalDeletion := e.beginHandleApprovalDeletion.get(req) + if beginHandleApprovalDeletion == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enclaveEndpoints/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/handleApprovalDeletion` + 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[armvirtualenclaves.ApprovalDeletionCallbackRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + enclaveEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enclaveEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginHandleApprovalDeletion(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, enclaveEndpointNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginHandleApprovalDeletion = &respr + e.beginHandleApprovalDeletion.add(req, beginHandleApprovalDeletion) + } + + resp, err := server.PollerResponderNext(beginHandleApprovalDeletion, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + e.beginHandleApprovalDeletion.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginHandleApprovalDeletion) { + e.beginHandleApprovalDeletion.remove(req) + } + + return resp, nil +} + +func (e *EnclaveEndpointsServerTransport) dispatchNewListByEnclaveResourcePager(req *http.Request) (*http.Response, error) { + if e.srv.NewListByEnclaveResourcePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByEnclaveResourcePager not implemented")} + } + newListByEnclaveResourcePager := e.newListByEnclaveResourcePager.get(req) + if newListByEnclaveResourcePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enclaveEndpoints` + 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 + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + resp := e.srv.NewListByEnclaveResourcePager(resourceGroupNameParam, virtualEnclaveNameParam, nil) + newListByEnclaveResourcePager = &resp + e.newListByEnclaveResourcePager.add(req, newListByEnclaveResourcePager) + server.PagerResponderInjectNextLinks(newListByEnclaveResourcePager, req, func(page *armvirtualenclaves.EnclaveEndpointsClientListByEnclaveResourceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByEnclaveResourcePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + e.newListByEnclaveResourcePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByEnclaveResourcePager) { + e.newListByEnclaveResourcePager.remove(req) + } + return resp, nil +} + +func (e *EnclaveEndpointsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := e.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enclaveEndpoints` + 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) + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + resp := e.srv.NewListBySubscriptionPager(virtualEnclaveNameParam, nil) + newListBySubscriptionPager = &resp + e.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armvirtualenclaves.EnclaveEndpointsClientListBySubscriptionResponse, 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) { + e.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + e.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (e *EnclaveEndpointsServerTransport) 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\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enclaveEndpoints/(?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[armvirtualenclaves.EnclaveEndpointPatchModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + enclaveEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("enclaveEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginUpdate(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, enclaveEndpointNameParam, 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 EnclaveEndpointsServerTransport +var enclaveEndpointsServerTransportInterceptor 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/virtualenclaves/armvirtualenclaves/fake/internal.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/internal.go new file mode 100644 index 000000000000..7425b6a669e2 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/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/virtualenclaves/armvirtualenclaves/fake/operations_server.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/operations_server.go new file mode 100644 index 000000000000..f60ed1c7fc07 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/operations_server.go @@ -0,0 +1,117 @@ +// 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" + 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/virtualenclaves/armvirtualenclaves" + "net/http" +) + +// OperationsServer is a fake server for instances of the armvirtualenclaves.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armvirtualenclaves.OperationsClientListOptions) (resp azfake.PagerResponder[armvirtualenclaves.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armvirtualenclaves.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armvirtualenclaves.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armvirtualenclaves.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armvirtualenclaves.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) 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 o.dispatchToMethodFake(req, method) +} + +func (o *OperationsServerTransport) 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 operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(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 (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armvirtualenclaves.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor 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/virtualenclaves/armvirtualenclaves/fake/server_factory.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/server_factory.go new file mode 100644 index 000000000000..8f003c286080 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/server_factory.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 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 armvirtualenclaves.ClientFactory type. +type ServerFactory struct { + // ApprovalServer contains the fakes for client ApprovalClient + ApprovalServer ApprovalServer + + // CommunityServer contains the fakes for client CommunityClient + CommunityServer CommunityServer + + // CommunityEndpointsServer contains the fakes for client CommunityEndpointsClient + CommunityEndpointsServer CommunityEndpointsServer + + // EnclaveConnectionServer contains the fakes for client EnclaveConnectionClient + EnclaveConnectionServer EnclaveConnectionServer + + // EnclaveEndpointsServer contains the fakes for client EnclaveEndpointsClient + EnclaveEndpointsServer EnclaveEndpointsServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // TransitHubServer contains the fakes for client TransitHubClient + TransitHubServer TransitHubServer + + // VirtualEnclaveServer contains the fakes for client VirtualEnclaveClient + VirtualEnclaveServer VirtualEnclaveServer + + // WorkloadServer contains the fakes for client WorkloadClient + WorkloadServer WorkloadServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armvirtualenclaves.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 armvirtualenclaves.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trApprovalServer *ApprovalServerTransport + trCommunityServer *CommunityServerTransport + trCommunityEndpointsServer *CommunityEndpointsServerTransport + trEnclaveConnectionServer *EnclaveConnectionServerTransport + trEnclaveEndpointsServer *EnclaveEndpointsServerTransport + trOperationsServer *OperationsServerTransport + trTransitHubServer *TransitHubServerTransport + trVirtualEnclaveServer *VirtualEnclaveServerTransport + trWorkloadServer *WorkloadServerTransport +} + +// 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 "ApprovalClient": + initServer(s, &s.trApprovalServer, func() *ApprovalServerTransport { return NewApprovalServerTransport(&s.srv.ApprovalServer) }) + resp, err = s.trApprovalServer.Do(req) + case "CommunityClient": + initServer(s, &s.trCommunityServer, func() *CommunityServerTransport { return NewCommunityServerTransport(&s.srv.CommunityServer) }) + resp, err = s.trCommunityServer.Do(req) + case "CommunityEndpointsClient": + initServer(s, &s.trCommunityEndpointsServer, func() *CommunityEndpointsServerTransport { + return NewCommunityEndpointsServerTransport(&s.srv.CommunityEndpointsServer) + }) + resp, err = s.trCommunityEndpointsServer.Do(req) + case "EnclaveConnectionClient": + initServer(s, &s.trEnclaveConnectionServer, func() *EnclaveConnectionServerTransport { + return NewEnclaveConnectionServerTransport(&s.srv.EnclaveConnectionServer) + }) + resp, err = s.trEnclaveConnectionServer.Do(req) + case "EnclaveEndpointsClient": + initServer(s, &s.trEnclaveEndpointsServer, func() *EnclaveEndpointsServerTransport { + return NewEnclaveEndpointsServerTransport(&s.srv.EnclaveEndpointsServer) + }) + resp, err = s.trEnclaveEndpointsServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "TransitHubClient": + initServer(s, &s.trTransitHubServer, func() *TransitHubServerTransport { return NewTransitHubServerTransport(&s.srv.TransitHubServer) }) + resp, err = s.trTransitHubServer.Do(req) + case "VirtualEnclaveClient": + initServer(s, &s.trVirtualEnclaveServer, func() *VirtualEnclaveServerTransport { + return NewVirtualEnclaveServerTransport(&s.srv.VirtualEnclaveServer) + }) + resp, err = s.trVirtualEnclaveServer.Do(req) + case "WorkloadClient": + initServer(s, &s.trWorkloadServer, func() *WorkloadServerTransport { return NewWorkloadServerTransport(&s.srv.WorkloadServer) }) + resp, err = s.trWorkloadServer.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/virtualenclaves/armvirtualenclaves/fake/transithub_server.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/transithub_server.go new file mode 100644 index 000000000000..b4e7a8f2490f --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/transithub_server.go @@ -0,0 +1,398 @@ +// 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/virtualenclaves/armvirtualenclaves" + "net/http" + "net/url" + "regexp" +) + +// TransitHubServer is a fake server for instances of the armvirtualenclaves.TransitHubClient type. +type TransitHubServer struct { + // BeginCreateOrUpdate is the fake for method TransitHubClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, resource armvirtualenclaves.TransitHubResource, options *armvirtualenclaves.TransitHubClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.TransitHubClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method TransitHubClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, options *armvirtualenclaves.TransitHubClientBeginDeleteOptions) (resp azfake.PollerResponder[armvirtualenclaves.TransitHubClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TransitHubClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, options *armvirtualenclaves.TransitHubClientGetOptions) (resp azfake.Responder[armvirtualenclaves.TransitHubClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByCommunityResourcePager is the fake for method TransitHubClient.NewListByCommunityResourcePager + // HTTP status codes to indicate success: http.StatusOK + NewListByCommunityResourcePager func(resourceGroupName string, communityName string, options *armvirtualenclaves.TransitHubClientListByCommunityResourceOptions) (resp azfake.PagerResponder[armvirtualenclaves.TransitHubClientListByCommunityResourceResponse]) + + // NewListBySubscriptionPager is the fake for method TransitHubClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(communityName string, options *armvirtualenclaves.TransitHubClientListBySubscriptionOptions) (resp azfake.PagerResponder[armvirtualenclaves.TransitHubClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method TransitHubClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, properties armvirtualenclaves.TransitHubPatchModel, options *armvirtualenclaves.TransitHubClientBeginUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.TransitHubClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewTransitHubServerTransport creates a new instance of TransitHubServerTransport with the provided implementation. +// The returned TransitHubServerTransport instance is connected to an instance of armvirtualenclaves.TransitHubClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTransitHubServerTransport(srv *TransitHubServer) *TransitHubServerTransport { + return &TransitHubServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.TransitHubClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armvirtualenclaves.TransitHubClientDeleteResponse]](), + newListByCommunityResourcePager: newTracker[azfake.PagerResponder[armvirtualenclaves.TransitHubClientListByCommunityResourceResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armvirtualenclaves.TransitHubClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.TransitHubClientUpdateResponse]](), + } +} + +// TransitHubServerTransport connects instances of armvirtualenclaves.TransitHubClient to instances of TransitHubServer. +// Don't use this type directly, use NewTransitHubServerTransport instead. +type TransitHubServerTransport struct { + srv *TransitHubServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.TransitHubClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armvirtualenclaves.TransitHubClientDeleteResponse]] + newListByCommunityResourcePager *tracker[azfake.PagerResponder[armvirtualenclaves.TransitHubClientListByCommunityResourceResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armvirtualenclaves.TransitHubClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.TransitHubClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for TransitHubServerTransport. +func (t *TransitHubServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return t.dispatchToMethodFake(req, method) +} + +func (t *TransitHubServerTransport) 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 transitHubServerTransportInterceptor != nil { + res.resp, res.err, intercepted = transitHubServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TransitHubClient.BeginCreateOrUpdate": + res.resp, res.err = t.dispatchBeginCreateOrUpdate(req) + case "TransitHubClient.BeginDelete": + res.resp, res.err = t.dispatchBeginDelete(req) + case "TransitHubClient.Get": + res.resp, res.err = t.dispatchGet(req) + case "TransitHubClient.NewListByCommunityResourcePager": + res.resp, res.err = t.dispatchNewListByCommunityResourcePager(req) + case "TransitHubClient.NewListBySubscriptionPager": + res.resp, res.err = t.dispatchNewListBySubscriptionPager(req) + case "TransitHubClient.BeginUpdate": + res.resp, res.err = t.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (t *TransitHubServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if t.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := t.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transitHubs/(?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[armvirtualenclaves.TransitHubResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + transitHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transitHubName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, communityNameParam, transitHubNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + t.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + t.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + t.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (t *TransitHubServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if t.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := t.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transitHubs/(?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 + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + transitHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transitHubName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginDelete(req.Context(), resourceGroupNameParam, communityNameParam, transitHubNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + t.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) { + t.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) { + t.beginDelete.remove(req) + } + + return resp, nil +} + +func (t *TransitHubServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transitHubs/(?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 + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + transitHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transitHubName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameParam, communityNameParam, transitHubNameParam, 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).TransitHubResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TransitHubServerTransport) dispatchNewListByCommunityResourcePager(req *http.Request) (*http.Response, error) { + if t.srv.NewListByCommunityResourcePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByCommunityResourcePager not implemented")} + } + newListByCommunityResourcePager := t.newListByCommunityResourcePager.get(req) + if newListByCommunityResourcePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transitHubs` + 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 + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + resp := t.srv.NewListByCommunityResourcePager(resourceGroupNameParam, communityNameParam, nil) + newListByCommunityResourcePager = &resp + t.newListByCommunityResourcePager.add(req, newListByCommunityResourcePager) + server.PagerResponderInjectNextLinks(newListByCommunityResourcePager, req, func(page *armvirtualenclaves.TransitHubClientListByCommunityResourceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByCommunityResourcePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + t.newListByCommunityResourcePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByCommunityResourcePager) { + t.newListByCommunityResourcePager.remove(req) + } + return resp, nil +} + +func (t *TransitHubServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := t.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transitHubs` + 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) + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + resp := t.srv.NewListBySubscriptionPager(communityNameParam, nil) + newListBySubscriptionPager = &resp + t.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armvirtualenclaves.TransitHubClientListBySubscriptionResponse, 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) { + t.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + t.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (t *TransitHubServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if t.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := t.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/communities/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/transitHubs/(?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[armvirtualenclaves.TransitHubPatchModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + communityNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("communityName")]) + if err != nil { + return nil, err + } + transitHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("transitHubName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.BeginUpdate(req.Context(), resourceGroupNameParam, communityNameParam, transitHubNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + t.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + t.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) { + t.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to TransitHubServerTransport +var transitHubServerTransportInterceptor 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/virtualenclaves/armvirtualenclaves/fake/virtualenclave_server.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/virtualenclave_server.go new file mode 100644 index 000000000000..a964f4b11e56 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/virtualenclave_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/virtualenclaves/armvirtualenclaves" + "net/http" + "net/url" + "regexp" +) + +// VirtualEnclaveServer is a fake server for instances of the armvirtualenclaves.VirtualEnclaveClient type. +type VirtualEnclaveServer struct { + // BeginCreateOrUpdate is the fake for method VirtualEnclaveClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, resource armvirtualenclaves.EnclaveResource, options *armvirtualenclaves.VirtualEnclaveClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method VirtualEnclaveClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, options *armvirtualenclaves.VirtualEnclaveClientBeginDeleteOptions) (resp azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method VirtualEnclaveClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, options *armvirtualenclaves.VirtualEnclaveClientGetOptions) (resp azfake.Responder[armvirtualenclaves.VirtualEnclaveClientGetResponse], errResp azfake.ErrorResponder) + + // BeginHandleApprovalCreation is the fake for method VirtualEnclaveClient.BeginHandleApprovalCreation + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginHandleApprovalCreation func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, body armvirtualenclaves.ApprovalCallbackRequest, options *armvirtualenclaves.VirtualEnclaveClientBeginHandleApprovalCreationOptions) (resp azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientHandleApprovalCreationResponse], errResp azfake.ErrorResponder) + + // BeginHandleApprovalDeletion is the fake for method VirtualEnclaveClient.BeginHandleApprovalDeletion + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginHandleApprovalDeletion func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, body armvirtualenclaves.ApprovalDeletionCallbackRequest, options *armvirtualenclaves.VirtualEnclaveClientBeginHandleApprovalDeletionOptions) (resp azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientHandleApprovalDeletionResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method VirtualEnclaveClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armvirtualenclaves.VirtualEnclaveClientListByResourceGroupOptions) (resp azfake.PagerResponder[armvirtualenclaves.VirtualEnclaveClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method VirtualEnclaveClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armvirtualenclaves.VirtualEnclaveClientListBySubscriptionOptions) (resp azfake.PagerResponder[armvirtualenclaves.VirtualEnclaveClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method VirtualEnclaveClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, properties armvirtualenclaves.VirtualEnclavePatchModel, options *armvirtualenclaves.VirtualEnclaveClientBeginUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewVirtualEnclaveServerTransport creates a new instance of VirtualEnclaveServerTransport with the provided implementation. +// The returned VirtualEnclaveServerTransport instance is connected to an instance of armvirtualenclaves.VirtualEnclaveClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewVirtualEnclaveServerTransport(srv *VirtualEnclaveServer) *VirtualEnclaveServerTransport { + return &VirtualEnclaveServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientDeleteResponse]](), + beginHandleApprovalCreation: newTracker[azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientHandleApprovalCreationResponse]](), + beginHandleApprovalDeletion: newTracker[azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientHandleApprovalDeletionResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armvirtualenclaves.VirtualEnclaveClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armvirtualenclaves.VirtualEnclaveClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientUpdateResponse]](), + } +} + +// VirtualEnclaveServerTransport connects instances of armvirtualenclaves.VirtualEnclaveClient to instances of VirtualEnclaveServer. +// Don't use this type directly, use NewVirtualEnclaveServerTransport instead. +type VirtualEnclaveServerTransport struct { + srv *VirtualEnclaveServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientDeleteResponse]] + beginHandleApprovalCreation *tracker[azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientHandleApprovalCreationResponse]] + beginHandleApprovalDeletion *tracker[azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientHandleApprovalDeletionResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armvirtualenclaves.VirtualEnclaveClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armvirtualenclaves.VirtualEnclaveClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.VirtualEnclaveClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for VirtualEnclaveServerTransport. +func (v *VirtualEnclaveServerTransport) 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 v.dispatchToMethodFake(req, method) +} + +func (v *VirtualEnclaveServerTransport) 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 virtualEnclaveServerTransportInterceptor != nil { + res.resp, res.err, intercepted = virtualEnclaveServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "VirtualEnclaveClient.BeginCreateOrUpdate": + res.resp, res.err = v.dispatchBeginCreateOrUpdate(req) + case "VirtualEnclaveClient.BeginDelete": + res.resp, res.err = v.dispatchBeginDelete(req) + case "VirtualEnclaveClient.Get": + res.resp, res.err = v.dispatchGet(req) + case "VirtualEnclaveClient.BeginHandleApprovalCreation": + res.resp, res.err = v.dispatchBeginHandleApprovalCreation(req) + case "VirtualEnclaveClient.BeginHandleApprovalDeletion": + res.resp, res.err = v.dispatchBeginHandleApprovalDeletion(req) + case "VirtualEnclaveClient.NewListByResourceGroupPager": + res.resp, res.err = v.dispatchNewListByResourceGroupPager(req) + case "VirtualEnclaveClient.NewListBySubscriptionPager": + res.resp, res.err = v.dispatchNewListBySubscriptionPager(req) + case "VirtualEnclaveClient.BeginUpdate": + res.resp, res.err = v.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 (v *VirtualEnclaveServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if v.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := v.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?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[armvirtualenclaves.EnclaveResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + v.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + v.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + v.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (v *VirtualEnclaveServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if v.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := v.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?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 + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginDelete(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + v.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) { + v.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) { + v.beginDelete.remove(req) + } + + return resp, nil +} + +func (v *VirtualEnclaveServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if v.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\.Mission/virtualEnclaves/(?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 + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.Get(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, 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).EnclaveResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (v *VirtualEnclaveServerTransport) dispatchBeginHandleApprovalCreation(req *http.Request) (*http.Response, error) { + if v.srv.BeginHandleApprovalCreation == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginHandleApprovalCreation not implemented")} + } + beginHandleApprovalCreation := v.beginHandleApprovalCreation.get(req) + if beginHandleApprovalCreation == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/handleApprovalCreation` + 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[armvirtualenclaves.ApprovalCallbackRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginHandleApprovalCreation(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginHandleApprovalCreation = &respr + v.beginHandleApprovalCreation.add(req, beginHandleApprovalCreation) + } + + resp, err := server.PollerResponderNext(beginHandleApprovalCreation, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + v.beginHandleApprovalCreation.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginHandleApprovalCreation) { + v.beginHandleApprovalCreation.remove(req) + } + + return resp, nil +} + +func (v *VirtualEnclaveServerTransport) dispatchBeginHandleApprovalDeletion(req *http.Request) (*http.Response, error) { + if v.srv.BeginHandleApprovalDeletion == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginHandleApprovalDeletion not implemented")} + } + beginHandleApprovalDeletion := v.beginHandleApprovalDeletion.get(req) + if beginHandleApprovalDeletion == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/handleApprovalDeletion` + 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[armvirtualenclaves.ApprovalDeletionCallbackRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginHandleApprovalDeletion(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginHandleApprovalDeletion = &respr + v.beginHandleApprovalDeletion.add(req, beginHandleApprovalDeletion) + } + + resp, err := server.PollerResponderNext(beginHandleApprovalDeletion, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + v.beginHandleApprovalDeletion.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginHandleApprovalDeletion) { + v.beginHandleApprovalDeletion.remove(req) + } + + return resp, nil +} + +func (v *VirtualEnclaveServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if v.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := v.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves` + 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 := v.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + v.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armvirtualenclaves.VirtualEnclaveClientListByResourceGroupResponse, 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) { + v.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + v.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (v *VirtualEnclaveServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if v.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := v.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves` + 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 := v.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + v.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armvirtualenclaves.VirtualEnclaveClientListBySubscriptionResponse, 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) { + v.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + v.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (v *VirtualEnclaveServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if v.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := v.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?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[armvirtualenclaves.VirtualEnclavePatchModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginUpdate(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + v.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) { + v.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) { + v.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to VirtualEnclaveServerTransport +var virtualEnclaveServerTransportInterceptor 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/virtualenclaves/armvirtualenclaves/fake/workload_server.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/workload_server.go new file mode 100644 index 000000000000..4dab5c9fc602 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/fake/workload_server.go @@ -0,0 +1,398 @@ +// 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/virtualenclaves/armvirtualenclaves" + "net/http" + "net/url" + "regexp" +) + +// WorkloadServer is a fake server for instances of the armvirtualenclaves.WorkloadClient type. +type WorkloadServer struct { + // BeginCreateOrUpdate is the fake for method WorkloadClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, resource armvirtualenclaves.WorkloadResource, options *armvirtualenclaves.WorkloadClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.WorkloadClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method WorkloadClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, options *armvirtualenclaves.WorkloadClientBeginDeleteOptions) (resp azfake.PollerResponder[armvirtualenclaves.WorkloadClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkloadClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, options *armvirtualenclaves.WorkloadClientGetOptions) (resp azfake.Responder[armvirtualenclaves.WorkloadClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByEnclaveResourcePager is the fake for method WorkloadClient.NewListByEnclaveResourcePager + // HTTP status codes to indicate success: http.StatusOK + NewListByEnclaveResourcePager func(resourceGroupName string, virtualEnclaveName string, options *armvirtualenclaves.WorkloadClientListByEnclaveResourceOptions) (resp azfake.PagerResponder[armvirtualenclaves.WorkloadClientListByEnclaveResourceResponse]) + + // NewListBySubscriptionPager is the fake for method WorkloadClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(virtualEnclaveName string, options *armvirtualenclaves.WorkloadClientListBySubscriptionOptions) (resp azfake.PagerResponder[armvirtualenclaves.WorkloadClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method WorkloadClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, properties armvirtualenclaves.WorkloadPatchModel, options *armvirtualenclaves.WorkloadClientBeginUpdateOptions) (resp azfake.PollerResponder[armvirtualenclaves.WorkloadClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkloadServerTransport creates a new instance of WorkloadServerTransport with the provided implementation. +// The returned WorkloadServerTransport instance is connected to an instance of armvirtualenclaves.WorkloadClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkloadServerTransport(srv *WorkloadServer) *WorkloadServerTransport { + return &WorkloadServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.WorkloadClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armvirtualenclaves.WorkloadClientDeleteResponse]](), + newListByEnclaveResourcePager: newTracker[azfake.PagerResponder[armvirtualenclaves.WorkloadClientListByEnclaveResourceResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armvirtualenclaves.WorkloadClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armvirtualenclaves.WorkloadClientUpdateResponse]](), + } +} + +// WorkloadServerTransport connects instances of armvirtualenclaves.WorkloadClient to instances of WorkloadServer. +// Don't use this type directly, use NewWorkloadServerTransport instead. +type WorkloadServerTransport struct { + srv *WorkloadServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.WorkloadClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armvirtualenclaves.WorkloadClientDeleteResponse]] + newListByEnclaveResourcePager *tracker[azfake.PagerResponder[armvirtualenclaves.WorkloadClientListByEnclaveResourceResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armvirtualenclaves.WorkloadClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armvirtualenclaves.WorkloadClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for WorkloadServerTransport. +func (w *WorkloadServerTransport) 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 w.dispatchToMethodFake(req, method) +} + +func (w *WorkloadServerTransport) 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 workloadServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workloadServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkloadClient.BeginCreateOrUpdate": + res.resp, res.err = w.dispatchBeginCreateOrUpdate(req) + case "WorkloadClient.BeginDelete": + res.resp, res.err = w.dispatchBeginDelete(req) + case "WorkloadClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkloadClient.NewListByEnclaveResourcePager": + res.resp, res.err = w.dispatchNewListByEnclaveResourcePager(req) + case "WorkloadClient.NewListBySubscriptionPager": + res.resp, res.err = w.dispatchNewListBySubscriptionPager(req) + case "WorkloadClient.BeginUpdate": + res.resp, res.err = w.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 (w *WorkloadServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := w.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workloads/(?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[armvirtualenclaves.WorkloadResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + workloadNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workloadName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, workloadNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + w.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + w.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + w.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (w *WorkloadServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if w.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := w.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workloads/(?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 + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + workloadNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workloadName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginDelete(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, workloadNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + w.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) { + w.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) { + w.beginDelete.remove(req) + } + + return resp, nil +} + +func (w *WorkloadServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.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\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workloads/(?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 + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + workloadNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workloadName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, workloadNameParam, 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).WorkloadResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkloadServerTransport) dispatchNewListByEnclaveResourcePager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByEnclaveResourcePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByEnclaveResourcePager not implemented")} + } + newListByEnclaveResourcePager := w.newListByEnclaveResourcePager.get(req) + if newListByEnclaveResourcePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workloads` + 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 + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListByEnclaveResourcePager(resourceGroupNameParam, virtualEnclaveNameParam, nil) + newListByEnclaveResourcePager = &resp + w.newListByEnclaveResourcePager.add(req, newListByEnclaveResourcePager) + server.PagerResponderInjectNextLinks(newListByEnclaveResourcePager, req, func(page *armvirtualenclaves.WorkloadClientListByEnclaveResourceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByEnclaveResourcePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByEnclaveResourcePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByEnclaveResourcePager) { + w.newListByEnclaveResourcePager.remove(req) + } + return resp, nil +} + +func (w *WorkloadServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := w.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workloads` + 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) + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListBySubscriptionPager(virtualEnclaveNameParam, nil) + newListBySubscriptionPager = &resp + w.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armvirtualenclaves.WorkloadClientListBySubscriptionResponse, 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) { + w.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + w.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (w *WorkloadServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if w.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := w.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Mission/virtualEnclaves/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workloads/(?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[armvirtualenclaves.WorkloadPatchModel](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + virtualEnclaveNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualEnclaveName")]) + if err != nil { + return nil, err + } + workloadNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workloadName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginUpdate(req.Context(), resourceGroupNameParam, virtualEnclaveNameParam, workloadNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + w.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) { + w.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) { + w.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkloadServerTransport +var workloadServerTransportInterceptor 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/virtualenclaves/armvirtualenclaves/go.mod b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/go.mod new file mode 100644 index 000000000000..30938e28bf0f --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/virtualenclaves/armvirtualenclaves + +go 1.23.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.1 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.0 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.5.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.41.0 // indirect + golang.org/x/net v0.43.0 // indirect + golang.org/x/sys v0.35.0 // indirect + golang.org/x/text v0.28.0 // indirect +) diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/go.sum b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/go.sum new file mode 100644 index 000000000000..9bdbb08beab0 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/go.sum @@ -0,0 +1,39 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.1 h1:5YTBM8QDVIBN3sxBil89WfdAAqDZbyJTgh688DSxX5w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.1/go.mod h1:YD5h/ldMsG0XiIw7PdyNhLxaM317eFh5yNLccNfGdyw= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.0 h1:KpMC6LFL7mqpExyMC9jVOYRiVhLmamjeZfRsUpB7l4s= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.0/go.mod h1:J7MUC/wtRpfGVbQ5sIItY5/FuVWmvzlY21WAOfQnq/I= +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.5.0 h1:XkkQbfMyuH2jTSjQjSoihryI8GINRcs4xp8lNawg0FI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.5.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.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= +golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= +golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= +golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= +golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= +golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= +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/virtualenclaves/armvirtualenclaves/models.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/models.go new file mode 100644 index 000000000000..f0d580721573 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/models.go @@ -0,0 +1,1081 @@ +// 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 armvirtualenclaves + +import "time" + +// ApprovalActionRequest - Request body for calling post-action +type ApprovalActionRequest struct { + // REQUIRED; Approval status indicating 'Approved' or 'Rejected' + ApprovalStatus *ApprovalActionRequestApprovalStatus +} + +// ApprovalActionResponse - Response body after handling of approvalCallbackRequest +type ApprovalActionResponse struct { + // REQUIRED; Confirmation message indicating the result of the operation. + Message *string +} + +// ApprovalCallbackRequest - Request body for calling post-action +type ApprovalCallbackRequest struct { + // REQUIRED; Approval status indicating 'Approved' or 'Rejected' + ApprovalStatus *ApprovalCallbackRequestApprovalStatus + + // REQUIRED; Resource request action indicating action which needed to be performed upon calling approval-callback post action + ResourceRequestAction *ApprovalCallbackRequestResourceRequestAction + + // Payload requested by client upon approval action + ApprovalCallbackPayload *string +} + +// ApprovalDeletionCallbackRequest - Request body for calling post-action +type ApprovalDeletionCallbackRequest struct { + // REQUIRED; Resource request action indicating action which needed to be performed upon calling approval-deletion-callback + // post action + ResourceRequestAction *ApprovalDeletionCallbackRequestResourceRequestAction +} + +// ApprovalPatchModel - Approvals patch model. +type ApprovalPatchModel struct { + // Approval Patch properties + Properties *ApprovalPatchProperties +} + +// ApprovalPatchProperties - Approvals patch properties. +type ApprovalPatchProperties struct { + // REQUIRED; Request metadata for the approval request. + RequestMetadata *RequestMetadataUpdatableProperties + + // List of approvers for the approval request + Approvers []*Approver + + // Approval request creation time + CreatedAt *time.Time + + // Parameter for optimizing query results + GrandparentResourceID *string + + // Parameter for optimizing query results + ParentResourceID *string + + // Approval request state change time, time at which approval request state changed from pending to approved or rejected. + StateChangedAt *time.Time + + // Ticket ID for the approval request + TicketID *string +} + +// ApprovalProperties - Approval Base model. +type ApprovalProperties struct { + // REQUIRED; Request metadata for the approval request. + RequestMetadata *RequestMetadata + + // List of approvers for the approval request + Approvers []*Approver + + // Approval request creation time + CreatedAt *time.Time + + // Parameter for optimizing query results + GrandparentResourceID *string + + // Parameter for optimizing query results + ParentResourceID *string + + // Approval request state change time, time at which approval request state changed from pending to approved or rejected. + StateChangedAt *time.Time + + // Ticket ID for the approval request + TicketID *string + + // READ-ONLY; Provisioning State. + ProvisioningState *ProvisioningState +} + +// ApprovalResource - Approval Model Resource +type ApprovalResource struct { + // The resource-specific properties for this resource. + Properties *ApprovalProperties + + // 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 +} + +// ApprovalResourceListResult - The response of a ApprovalResource list operation. +type ApprovalResourceListResult struct { + // REQUIRED; The ApprovalResource items on this page + Value []*ApprovalResource + + // The link to the next page of items + NextLink *string +} + +// ApprovalSettings Properties +type ApprovalSettings struct { + // Approval required for enclave connection creation (Required or NotRequired). + ConnectionCreation *ApprovalPolicy + + // Approval required for enclave connection deletion (Required or NotRequired). + ConnectionDeletion *ApprovalPolicy + + // Approval required for enclave connection update (Required or NotRequired). + ConnectionUpdate *ApprovalPolicy + + // Approval required for virtual enclave creation (Required or NotRequired). + EnclaveCreation *ApprovalPolicy + + // Approval required for virtual enclave deletion (Required or NotRequired). + EnclaveDeletion *ApprovalPolicy + + // Approval required for endpoint creation (Required or NotRequired). + EndpointCreation *ApprovalPolicy + + // Approval required for endpoint deletion (Required or NotRequired). + EndpointDeletion *ApprovalPolicy + + // Approval required for endpoint update (Required or NotRequired). + EndpointUpdate *ApprovalPolicy + + // Approval required for toggling maintenance mode (Required or NotRequired). + MaintenanceMode *ApprovalPolicy + + // List of mandatory approvers for the approval request + MandatoryApprovers []*MandatoryApprover + + // Minimum number of approvers required for the approval request + MinimumApproversRequired *int64 + + // Notification will be sent on any action taken (Approve/Reject) on an Approval Request + NotificationOnApprovalAction *ApprovalPolicy + + // Notification will be sent on creation of an Approval Request + NotificationOnApprovalCreation *ApprovalPolicy + + // Notification will be sent on deletion of an Approval Request + NotificationOnApprovalDeletion *ApprovalPolicy + + // Approval required for deploying service catalog templates (Required or NotRequired). + ServiceCatalogDeployment *ApprovalPolicy +} + +// ApprovalSettingsPatchProperties - ApprovalSettings Properties +type ApprovalSettingsPatchProperties struct { + // List of mandatory approvers for the approval request + MandatoryApprovers []*MandatoryApprover +} + +// Approver Metadata for approvals request. +type Approver struct { + // REQUIRED; Entra ObjectID of the approver + ApproverEntraID *string + + // REQUIRED; approval request last updated at + LastUpdatedAt *time.Time + + // Action Performed by approver + ActionPerformed *ActionPerformed +} + +// CheckAddressSpaceAvailabilityRequest - Request to the action call to check address space availability. +type CheckAddressSpaceAvailabilityRequest struct { + // REQUIRED; Resource Id of the Community + CommunityResourceID *string + + // REQUIRED; Information about the enclave virtual network + EnclaveVirtualNetwork *EnclaveVirtualNetworkModel +} + +// CheckAddressSpaceAvailabilityResponse - Response of availability of the requested address space. +type CheckAddressSpaceAvailabilityResponse struct { + // REQUIRED; Boolean representing whether the address space is available. + Value *bool +} + +// CommunityEndpointDestinationRule - Base type for destination rules. +type CommunityEndpointDestinationRule struct { + // Destination address. Can include multiple CIDR/IP Addresses or fqdn tags or fqdns (for community endpoint) separated by + // commas. + Destination *string + + // Destination Type. + DestinationType *DestinationType + + // Endpoint Rule Name. + EndpointRuleName *string + + // Port. Can include multiple ports separated by commas or a range indicated by a hyphen. + Ports *string + + // Protocols. Options specified by Endpoint Protocol Enum. + Protocols []*CommunityEndpointProtocol + + // Transit Hub Resource Id. + TransitHubResourceID *string +} + +// CommunityEndpointPatchModel - Community Endpoint Patch Resource +type CommunityEndpointPatchModel struct { + // Community Endpoint Patch properties + Properties *CommunityEndpointPatchProperties + + // Resource tags. + Tags map[string]*string +} + +// CommunityEndpointPatchProperties - Community Endpoint patchable Properties +type CommunityEndpointPatchProperties struct { + // REQUIRED; Community Endpoint Rule Collection. + RuleCollection []*CommunityEndpointDestinationRule +} + +// CommunityEndpointProperties - Community Endpoint Resource properties +type CommunityEndpointProperties struct { + // REQUIRED; Community Endpoint Rule Collection. + RuleCollection []*CommunityEndpointDestinationRule + + // READ-ONLY; Provisioning State. + ProvisioningState *ProvisioningState + + // READ-ONLY; List of resource ids created by community endpoint. + ResourceCollection []*string +} + +// CommunityEndpointResource - CommunityEndpoint Model Resource +type CommunityEndpointResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *CommunityEndpointProperties + + // 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 +} + +// CommunityEndpointResourceListResult - The response of a CommunityEndpointResource list operation. +type CommunityEndpointResourceListResult struct { + // REQUIRED; The CommunityEndpointResource items on this page + Value []*CommunityEndpointResource + + // The link to the next page of items + NextLink *string +} + +// CommunityPatchModel - Community Patch Resource +type CommunityPatchModel struct { + // The managed service identities assigned to this resource. + Identity *ManagedServiceIdentity + + // Community Patch properties + Properties *CommunityPatchProperties + + // Resource tags. + Tags map[string]*string +} + +// CommunityPatchProperties - Community Resource Properties without default values +type CommunityPatchProperties struct { + // Approval requirements for various actions on the community's resources. + ApprovalSettings *ApprovalSettingsPatchProperties + + // Community role assignments + CommunityRoleAssignments []*RoleAssignmentItem + + // DNS Servers. + DNSServers []*string + + // SKU of the community's Azure Firewall (Basic, Standard, Premium). Standard is the default + FirewallSKU *FirewallSKU + + // List of services governed by a community. + GovernedServiceList []*GovernedServiceItem + + // Maintenance Mode configuration. + MaintenanceModeConfiguration *MaintenanceModeConfigurationPatchModel + + // Policy override setting for the community. Specifies whether to apply enclave-specific policies or disable policy enforcement. + PolicyOverride *CommunityPropertiesPolicyOverride +} + +// CommunityProperties - Community Resource Properties +type CommunityProperties struct { + // Address Space. + AddressSpace *string + + // Approval requirements for various actions on the community's resources. + ApprovalSettings *ApprovalSettings + + // Community role assignments + CommunityRoleAssignments []*RoleAssignmentItem + + // DNS Servers. + DNSServers []*string + + // SKU of the community's Azure Firewall (Basic, Standard, Premium). Standard is the default + FirewallSKU *FirewallSKU + + // List of services governed by a community. + GovernedServiceList []*GovernedServiceItem + + // Maintenance Mode configuration. + MaintenanceModeConfiguration *MaintenanceModeConfigurationModel + + // Policy override setting for the community. Specifies whether to apply enclave-specific policies or disable policy enforcement. + PolicyOverride *CommunityPropertiesPolicyOverride + + // READ-ONLY; Managed On Behalf Of Configuration. + ManagedOnBehalfOfConfiguration *ManagedOnBehalfOfConfiguration + + // READ-ONLY; Managed resource group name. + ManagedResourceGroupName *string + + // READ-ONLY; Provisioning State. + ProvisioningState *ProvisioningState + + // READ-ONLY; List of resource ids created by communities. + ResourceCollection []*string +} + +// CommunityResource - Community Model Resource +type CommunityResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The managed service identities assigned to this resource. + Identity *ManagedServiceIdentity + + // The resource-specific properties for this resource. + Properties *CommunityProperties + + // 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 +} + +// CommunityResourceListResult - The response of a CommunityResource list operation. +type CommunityResourceListResult struct { + // REQUIRED; The CommunityResource items on this page + Value []*CommunityResource + + // The link to the next page of items + NextLink *string +} + +// EnclaveAddressSpacesModel - Enclave Address Spaces +type EnclaveAddressSpacesModel struct { + // Enclave Address Space + EnclaveAddressSpace *string + + // Managed Address Space + ManagedAddressSpace *string +} + +// EnclaveConnectionPatchModel - Enclave Connection Patch Resource +type EnclaveConnectionPatchModel struct { + // Enclave Connection Patch properties + Properties *EnclaveConnectionPatchProperties + + // Resource tags. + Tags map[string]*string +} + +// EnclaveConnectionPatchProperties - Enclave Connection patchable Properties +type EnclaveConnectionPatchProperties struct { + // Source CIDR. + SourceCidr *string +} + +// EnclaveConnectionProperties - Enclave Connection Resource properties +type EnclaveConnectionProperties struct { + // REQUIRED; Community Resource Id. + CommunityResourceID *string + + // REQUIRED; Destination Endpoint Resource Id. + DestinationEndpointID *string + + // REQUIRED; Source Resource Id. + SourceResourceID *string + + // Source CIDR. + SourceCidr *string + + // READ-ONLY; Provisioning State. + ProvisioningState *ProvisioningState + + // READ-ONLY; List of resource ids modified by enclave Connections. + ResourceCollection []*string + + // READ-ONLY; The state of the enclaveConnection. + State *EnclaveConnectionState +} + +// EnclaveConnectionResource - EnclaveConnection Model Resource +type EnclaveConnectionResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *EnclaveConnectionProperties + + // 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 +} + +// EnclaveConnectionResourceListResult - The response of a EnclaveConnectionResource list operation. +type EnclaveConnectionResourceListResult struct { + // REQUIRED; The EnclaveConnectionResource items on this page + Value []*EnclaveConnectionResource + + // The link to the next page of items + NextLink *string +} + +// EnclaveDefaultSettingsModel - Virtual Enclave Default Settings +type EnclaveDefaultSettingsModel struct { + // Diagnostic Destination. + DiagnosticDestination *DiagnosticDestination + + // READ-ONLY; Key Vault Resource Id. + KeyVaultResourceID *string + + // READ-ONLY; Log Analytics Resource Ids. + LogAnalyticsResourceIDCollection []*string + + // READ-ONLY; Storage Account Resource Id. + StorageAccountResourceID *string +} + +// EnclaveDefaultSettingsPatchModel - Virtual Enclave Default Settings +type EnclaveDefaultSettingsPatchModel struct { + // Diagnostic Destination. + DiagnosticDestination *DiagnosticDestination +} + +// EnclaveEndpointDestinationRule - Enclave Endpoint Rule Properties +type EnclaveEndpointDestinationRule struct { + // Destination address. Can include multiple CIDR/IP Addresses or fqdn tags or fqdns (for community endpoint) separated by + // commas. + Destination *string + + // Endpoint Rule Name. + EndpointRuleName *string + + // Port. Can include multiple ports separated by commas or a range indicated by a hyphen. + Ports *string + + // Protocols. Options specified by Endpoint Protocol Enum. + Protocols []*EnclaveEndpointProtocol +} + +// EnclaveEndpointPatchModel - Enclave Endpoint Patch Resource +type EnclaveEndpointPatchModel struct { + // Enclave Endpoint Patch properties + Properties *EnclaveEndpointPatchProperties + + // Resource tags. + Tags map[string]*string +} + +// EnclaveEndpointPatchProperties - Enclave Endpoint patchable Properties +type EnclaveEndpointPatchProperties struct { + // REQUIRED; Enclave Endpoint Rule Collection. + RuleCollection []*EnclaveEndpointDestinationRule +} + +// EnclaveEndpointProperties - Enclave Endpoint Resource properties +type EnclaveEndpointProperties struct { + // REQUIRED; Enclave Endpoint Rule Collection. + RuleCollection []*EnclaveEndpointDestinationRule + + // READ-ONLY; Provisioning State. + ProvisioningState *ProvisioningState + + // READ-ONLY; List of resource ids created by community endpoint. + ResourceCollection []*string +} + +// EnclaveEndpointResource - EnclaveEndpoint Model Resource +type EnclaveEndpointResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *EnclaveEndpointProperties + + // 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 +} + +// EnclaveEndpointResourceListResult - The response of a EnclaveEndpointResource list operation. +type EnclaveEndpointResourceListResult struct { + // REQUIRED; The EnclaveEndpointResource items on this page + Value []*EnclaveEndpointResource + + // The link to the next page of items + NextLink *string +} + +// EnclaveResource - Virtual Enclave Model Resource +type EnclaveResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The managed service identities assigned to this resource. + Identity *ManagedServiceIdentity + + // The resource-specific properties for this resource. + Properties *VirtualEnclaveProperties + + // 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 +} + +// EnclaveResourceListResult - The response of a EnclaveResource list operation. +type EnclaveResourceListResult struct { + // REQUIRED; The EnclaveResource items on this page + Value []*EnclaveResource + + // The link to the next page of items + NextLink *string +} + +// EnclaveVirtualNetworkModel - Enclave Virtual Network Properties +type EnclaveVirtualNetworkModel struct { + // Allow Subnet Communication. + AllowSubnetCommunication *bool + + // Custom CIDR Range. + CustomCidrRange *string + + // Network Name. + NetworkName *string + + // Network Size. + NetworkSize *string + + // Subnet Configurations. + SubnetConfigurations []*SubnetConfiguration +} + +// GovernedServiceItem Properties +type GovernedServiceItem struct { + // REQUIRED; Service ID + ServiceID *ServiceIdentifier + + // Initiative enforcement (Enabled or Disabled). + Enforcement *GovernedServiceItemEnforcement + + // Governance option for this service (Allow, Deny, ExceptionOnly, or NotApplicable). + Option *GovernedServiceItemOption + + // Enforcement mode for policy. AuditOnly, Enforce, or None. + PolicyAction *GovernedServiceItemPolicyAction + + // READ-ONLY; Initiatives associated with this service. + Initiatives []*string + + // READ-ONLY; Service name. + ServiceName *string +} + +// MaintenanceModeConfigurationModel - Maintenance Mode +type MaintenanceModeConfigurationModel struct { + // REQUIRED; Current mode of Maintenance Mode Configuration + Mode *MaintenanceModeConfigurationModelMode + + // Justification for entering or exiting Maintenance Mode + Justification *MaintenanceModeConfigurationModelJustification + + // The user, group or service principal object affected by Maintenance Mode + Principals []*Principal +} + +// MaintenanceModeConfigurationPatchModel - Maintenance Mode Patch Model +type MaintenanceModeConfigurationPatchModel struct { + // REQUIRED; Current mode of Maintenance Mode Configuration + Mode *MaintenanceModeConfigurationModelMode + + // Justification for entering or exiting Maintenance Mode + Justification *MaintenanceModeConfigurationModelJustification + + // The user, group or service principal object affected by Maintenance Mode + Principals []*Principal +} + +// ManagedOnBehalfOfConfiguration - Managed-On-Behalf-Of configuration properties. This configuration exists for the resources +// where a resource provider manages those resources on behalf of the resource owner. +type ManagedOnBehalfOfConfiguration struct { + // READ-ONLY; Managed-On-Behalf-Of broker resources + MoboBrokerResources []*MoboBrokerResource +} + +// ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) +type ManagedServiceIdentity struct { + // REQUIRED; The type of managed identity assigned to this resource. + Type *ManagedServiceIdentityType + + // The identities assigned to this resource by the user. + UserAssignedIdentities map[string]*UserAssignedIdentity + + // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned + // identity. + PrincipalID *string + + // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string +} + +// MandatoryApprover - Approver Metadata for approvals request. +type MandatoryApprover struct { + // REQUIRED; EntraId of the approver + ApproverEntraID *string +} + +// MoboBrokerResource - Managed-On-Behalf-Of broker resource. This resource is created by the Resource Provider to manage +// some resources on behalf of the user. +type MoboBrokerResource struct { + // Resource identifier of a Managed-On-Behalf-Of broker resource + ID *string +} + +// Operation - REST API Operation +// +// Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure + // Resource Manager/control-plane operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin +} + +// OperationDisplay - Localized display information for and operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // REQUIRED; The Operation items on this page + Value []*Operation + + // The link to the next page of items + NextLink *string +} + +// Principal for maintenance mode or role assignments +type Principal struct { + // REQUIRED; The object id associated with the principal + ID *string + + // REQUIRED; The type of the object id. We currently allow users, groups, and service principals + Type *PrincipalType +} + +// RequestMetadata - Request Metadata for approvals request. +type RequestMetadata struct { + // REQUIRED; Resource Action of the item being approved or declined. + ResourceAction *string + + // Payload to be sent upon any action on approval request + ApprovalCallbackPayload *string + + // Route name for the approval callback + ApprovalCallbackRoute *string + + // Status of the approval. Uses ApprovalStatus enum. + ApprovalStatus *ApprovalStatus +} + +// RequestMetadataUpdatableProperties - Request Metadata patch properties. +type RequestMetadataUpdatableProperties struct { + // REQUIRED; Resource Action of the item being approved or declined. + ResourceAction *string + + // Payload to be sent upon any action on approval request + ApprovalCallbackPayload *string + + // Route name for the approval callback + ApprovalCallbackRoute *string + + // Status of the approval. Uses ApprovalStatus enum. + ApprovalStatus *ApprovalStatus +} + +// RoleAssignmentItem - Role assignment item that indicates which principals should be assigned this role definition +type RoleAssignmentItem struct { + // REQUIRED; Role definition identifier + RoleDefinitionID *string + + // List of principal IDs to which to assign this role definition + Principals []*Principal +} + +// SubnetConfiguration - Subnet Configuration +type SubnetConfiguration struct { + // REQUIRED; Network prefix size. + NetworkPrefixSize *int32 + + // REQUIRED; Subnet name. + SubnetName *string + + // Subnet delegation. + SubnetDelegation *string + + // READ-ONLY; Address prefix. + AddressPrefix *string + + // READ-ONLY; Network security group ID. + NetworkSecurityGroupResourceID *string + + // READ-ONLY; Subnet Resource ID. + SubnetResourceID *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 +} + +// TransitHubPatchModel - TH Patch Resource +type TransitHubPatchModel struct { + // The TransitHub resource. + Properties *TransitHubPatchProperties + + // Resource tags. + Tags map[string]*string +} + +// TransitHubPatchProperties - Transit Hub patchable Properties +type TransitHubPatchProperties struct { + // The state of the transitHub. + State *TransitHubState + + // The TransitOption of the transitHub. + TransitOption *TransitOption +} + +// TransitHubProperties - Describes the properties of an Transit Hub. +type TransitHubProperties struct { + // The state of the transitHub. + State *TransitHubState + + // The TransitOption of the transitHub. + TransitOption *TransitOption + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState + + // READ-ONLY; List of resource ids modified by transitHubs. + ResourceCollection []*string +} + +// TransitHubResource - TransitHub Model Resource +type TransitHubResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *TransitHubProperties + + // 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 +} + +// TransitHubResourceListResult - The response of a TransitHubResource list operation. +type TransitHubResourceListResult struct { + // REQUIRED; The TransitHubResource items on this page + Value []*TransitHubResource + + // The link to the next page of items + NextLink *string +} + +// TransitOption Properties +type TransitOption struct { + // Transit Option Params + Params *TransitOptionParams + + // Transit Option Type. + Type *TransitOptionType +} + +// TransitOptionParams Properties +type TransitOptionParams struct { + // Transit Option Params remoteVirtualNetworkId. + RemoteVirtualNetworkID *string + + // Transit Option Params scaleUnits. + ScaleUnits *int64 +} + +// UserAssignedIdentity - User assigned identity properties +type UserAssignedIdentity struct { + // READ-ONLY; The client ID of the assigned identity. + ClientID *string + + // READ-ONLY; The principal ID of the assigned identity. + PrincipalID *string +} + +// VirtualEnclavePatchModel - Virtual Enclave Patch Model +type VirtualEnclavePatchModel struct { + // The managed service identities assigned to this resource. + Identity *ManagedServiceIdentity + + // Virtual Enclave Patch properties + Properties *VirtualEnclavePatchProperties + + // Resource tags. + Tags map[string]*string +} + +// VirtualEnclavePatchProperties - Virtual Enclave Patchable Properties +type VirtualEnclavePatchProperties struct { + // REQUIRED; Virtual Network. + EnclaveVirtualNetwork *EnclaveVirtualNetworkModel + + // Deploy Bastion service (True or False). + BastionEnabled *bool + + // Enclave default settings. + EnclaveDefaultSettings *EnclaveDefaultSettingsPatchModel + + // Enclave role assignments + EnclaveRoleAssignments []*RoleAssignmentItem + + // Enclave specific policies + GovernedServiceList []*GovernedServiceItem + + // Maintenance Mode configuration. + MaintenanceModeConfiguration *MaintenanceModeConfigurationPatchModel + + // Workload role assignments + WorkloadRoleAssignments []*RoleAssignmentItem +} + +// VirtualEnclaveProperties - Virtual Enclave Resource properties +type VirtualEnclaveProperties struct { + // REQUIRED; Community Resource Id. + CommunityResourceID *string + + // REQUIRED; Virtual Network. + EnclaveVirtualNetwork *EnclaveVirtualNetworkModel + + // Deploy Bastion service (True or False). + BastionEnabled *bool + + // Enclave default settings. + EnclaveDefaultSettings *EnclaveDefaultSettingsModel + + // Enclave role assignments + EnclaveRoleAssignments []*RoleAssignmentItem + + // Enclave specific policies + GovernedServiceList []*GovernedServiceItem + + // Maintenance Mode configuration. + MaintenanceModeConfiguration *MaintenanceModeConfigurationModel + + // Workload role assignments + WorkloadRoleAssignments []*RoleAssignmentItem + + // READ-ONLY; Enclave Address Spaces + EnclaveAddressSpaces *EnclaveAddressSpacesModel + + // READ-ONLY; Managed On Behalf Of Configuration. + ManagedOnBehalfOfConfiguration *ManagedOnBehalfOfConfiguration + + // READ-ONLY; Managed resource group name. + ManagedResourceGroupName *string + + // READ-ONLY; Provisioning State. + ProvisioningState *ProvisioningState + + // READ-ONLY; List of resource ids created by Virtual Enclave. + ResourceCollection []*string +} + +// WorkloadPatchModel - Workload Patch Resource +type WorkloadPatchModel struct { + // Workload Patch properties + Properties *WorkloadPatchProperties + + // Resource tags. + Tags map[string]*string +} + +// WorkloadPatchProperties - Workload patchable Properties +type WorkloadPatchProperties struct { + // List of resource group ids. + ResourceGroupCollection []*string +} + +// WorkloadProperties - Workload Resource properties +type WorkloadProperties struct { + // List of resource group ids. + ResourceGroupCollection []*string + + // READ-ONLY; Managed On Behalf Of Configuration. + ManagedOnBehalfOfConfiguration *ManagedOnBehalfOfConfiguration + + // READ-ONLY; Provisioning State. + ProvisioningState *ProvisioningState +} + +// WorkloadResource - Workload Model Resource +type WorkloadResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *WorkloadProperties + + // 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 +} + +// WorkloadResourceListResult - The response of a WorkloadResource list operation. +type WorkloadResourceListResult struct { + // REQUIRED; The WorkloadResource items on this page + Value []*WorkloadResource + + // The link to the next page of items + NextLink *string +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/models_serde.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/models_serde.go new file mode 100644 index 000000000000..cae7453b555b --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/models_serde.go @@ -0,0 +1,2850 @@ +// 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 armvirtualenclaves + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ApprovalActionRequest. +func (a ApprovalActionRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "approvalStatus", a.ApprovalStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApprovalActionRequest. +func (a *ApprovalActionRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "approvalStatus": + err = unpopulate(val, "ApprovalStatus", &a.ApprovalStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApprovalActionResponse. +func (a ApprovalActionResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", a.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApprovalActionResponse. +func (a *ApprovalActionResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &a.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApprovalCallbackRequest. +func (a ApprovalCallbackRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "approvalCallbackPayload", a.ApprovalCallbackPayload) + populate(objectMap, "approvalStatus", a.ApprovalStatus) + populate(objectMap, "resourceRequestAction", a.ResourceRequestAction) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApprovalCallbackRequest. +func (a *ApprovalCallbackRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "approvalCallbackPayload": + err = unpopulate(val, "ApprovalCallbackPayload", &a.ApprovalCallbackPayload) + delete(rawMsg, key) + case "approvalStatus": + err = unpopulate(val, "ApprovalStatus", &a.ApprovalStatus) + delete(rawMsg, key) + case "resourceRequestAction": + err = unpopulate(val, "ResourceRequestAction", &a.ResourceRequestAction) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApprovalDeletionCallbackRequest. +func (a ApprovalDeletionCallbackRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceRequestAction", a.ResourceRequestAction) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApprovalDeletionCallbackRequest. +func (a *ApprovalDeletionCallbackRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceRequestAction": + err = unpopulate(val, "ResourceRequestAction", &a.ResourceRequestAction) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApprovalPatchModel. +func (a ApprovalPatchModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApprovalPatchModel. +func (a *ApprovalPatchModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApprovalPatchProperties. +func (a ApprovalPatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "approvers", a.Approvers) + populateDateTimeRFC3339(objectMap, "createdAt", a.CreatedAt) + populate(objectMap, "grandparentResourceId", a.GrandparentResourceID) + populate(objectMap, "parentResourceId", a.ParentResourceID) + populate(objectMap, "requestMetadata", a.RequestMetadata) + populateDateTimeRFC3339(objectMap, "stateChangedAt", a.StateChangedAt) + populate(objectMap, "ticketId", a.TicketID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApprovalPatchProperties. +func (a *ApprovalPatchProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "approvers": + err = unpopulate(val, "Approvers", &a.Approvers) + delete(rawMsg, key) + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &a.CreatedAt) + delete(rawMsg, key) + case "grandparentResourceId": + err = unpopulate(val, "GrandparentResourceID", &a.GrandparentResourceID) + delete(rawMsg, key) + case "parentResourceId": + err = unpopulate(val, "ParentResourceID", &a.ParentResourceID) + delete(rawMsg, key) + case "requestMetadata": + err = unpopulate(val, "RequestMetadata", &a.RequestMetadata) + delete(rawMsg, key) + case "stateChangedAt": + err = unpopulateDateTimeRFC3339(val, "StateChangedAt", &a.StateChangedAt) + delete(rawMsg, key) + case "ticketId": + err = unpopulate(val, "TicketID", &a.TicketID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApprovalProperties. +func (a ApprovalProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "approvers", a.Approvers) + populateDateTimeRFC3339(objectMap, "createdAt", a.CreatedAt) + populate(objectMap, "grandparentResourceId", a.GrandparentResourceID) + populate(objectMap, "parentResourceId", a.ParentResourceID) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "requestMetadata", a.RequestMetadata) + populateDateTimeRFC3339(objectMap, "stateChangedAt", a.StateChangedAt) + populate(objectMap, "ticketId", a.TicketID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApprovalProperties. +func (a *ApprovalProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "approvers": + err = unpopulate(val, "Approvers", &a.Approvers) + delete(rawMsg, key) + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &a.CreatedAt) + delete(rawMsg, key) + case "grandparentResourceId": + err = unpopulate(val, "GrandparentResourceID", &a.GrandparentResourceID) + delete(rawMsg, key) + case "parentResourceId": + err = unpopulate(val, "ParentResourceID", &a.ParentResourceID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "requestMetadata": + err = unpopulate(val, "RequestMetadata", &a.RequestMetadata) + delete(rawMsg, key) + case "stateChangedAt": + err = unpopulateDateTimeRFC3339(val, "StateChangedAt", &a.StateChangedAt) + delete(rawMsg, key) + case "ticketId": + err = unpopulate(val, "TicketID", &a.TicketID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApprovalResource. +func (a ApprovalResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApprovalResource. +func (a *ApprovalResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApprovalResourceListResult. +func (a ApprovalResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApprovalResourceListResult. +func (a *ApprovalResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApprovalSettings. +func (a ApprovalSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "connectionCreation", a.ConnectionCreation) + populate(objectMap, "connectionDeletion", a.ConnectionDeletion) + populate(objectMap, "connectionUpdate", a.ConnectionUpdate) + populate(objectMap, "enclaveCreation", a.EnclaveCreation) + populate(objectMap, "enclaveDeletion", a.EnclaveDeletion) + populate(objectMap, "endpointCreation", a.EndpointCreation) + populate(objectMap, "endpointDeletion", a.EndpointDeletion) + populate(objectMap, "endpointUpdate", a.EndpointUpdate) + populate(objectMap, "maintenanceMode", a.MaintenanceMode) + populate(objectMap, "mandatoryApprovers", a.MandatoryApprovers) + populate(objectMap, "minimumApproversRequired", a.MinimumApproversRequired) + populate(objectMap, "notificationOnApprovalAction", a.NotificationOnApprovalAction) + populate(objectMap, "notificationOnApprovalCreation", a.NotificationOnApprovalCreation) + populate(objectMap, "notificationOnApprovalDeletion", a.NotificationOnApprovalDeletion) + populate(objectMap, "serviceCatalogDeployment", a.ServiceCatalogDeployment) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApprovalSettings. +func (a *ApprovalSettings) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "connectionCreation": + err = unpopulate(val, "ConnectionCreation", &a.ConnectionCreation) + delete(rawMsg, key) + case "connectionDeletion": + err = unpopulate(val, "ConnectionDeletion", &a.ConnectionDeletion) + delete(rawMsg, key) + case "connectionUpdate": + err = unpopulate(val, "ConnectionUpdate", &a.ConnectionUpdate) + delete(rawMsg, key) + case "enclaveCreation": + err = unpopulate(val, "EnclaveCreation", &a.EnclaveCreation) + delete(rawMsg, key) + case "enclaveDeletion": + err = unpopulate(val, "EnclaveDeletion", &a.EnclaveDeletion) + delete(rawMsg, key) + case "endpointCreation": + err = unpopulate(val, "EndpointCreation", &a.EndpointCreation) + delete(rawMsg, key) + case "endpointDeletion": + err = unpopulate(val, "EndpointDeletion", &a.EndpointDeletion) + delete(rawMsg, key) + case "endpointUpdate": + err = unpopulate(val, "EndpointUpdate", &a.EndpointUpdate) + delete(rawMsg, key) + case "maintenanceMode": + err = unpopulate(val, "MaintenanceMode", &a.MaintenanceMode) + delete(rawMsg, key) + case "mandatoryApprovers": + err = unpopulate(val, "MandatoryApprovers", &a.MandatoryApprovers) + delete(rawMsg, key) + case "minimumApproversRequired": + err = unpopulate(val, "MinimumApproversRequired", &a.MinimumApproversRequired) + delete(rawMsg, key) + case "notificationOnApprovalAction": + err = unpopulate(val, "NotificationOnApprovalAction", &a.NotificationOnApprovalAction) + delete(rawMsg, key) + case "notificationOnApprovalCreation": + err = unpopulate(val, "NotificationOnApprovalCreation", &a.NotificationOnApprovalCreation) + delete(rawMsg, key) + case "notificationOnApprovalDeletion": + err = unpopulate(val, "NotificationOnApprovalDeletion", &a.NotificationOnApprovalDeletion) + delete(rawMsg, key) + case "serviceCatalogDeployment": + err = unpopulate(val, "ServiceCatalogDeployment", &a.ServiceCatalogDeployment) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ApprovalSettingsPatchProperties. +func (a ApprovalSettingsPatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "mandatoryApprovers", a.MandatoryApprovers) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApprovalSettingsPatchProperties. +func (a *ApprovalSettingsPatchProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "mandatoryApprovers": + err = unpopulate(val, "MandatoryApprovers", &a.MandatoryApprovers) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Approver. +func (a Approver) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionPerformed", a.ActionPerformed) + populate(objectMap, "approverEntraId", a.ApproverEntraID) + populateDateTimeRFC3339(objectMap, "lastUpdatedAt", a.LastUpdatedAt) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Approver. +func (a *Approver) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionPerformed": + err = unpopulate(val, "ActionPerformed", &a.ActionPerformed) + delete(rawMsg, key) + case "approverEntraId": + err = unpopulate(val, "ApproverEntraID", &a.ApproverEntraID) + delete(rawMsg, key) + case "lastUpdatedAt": + err = unpopulateDateTimeRFC3339(val, "LastUpdatedAt", &a.LastUpdatedAt) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckAddressSpaceAvailabilityRequest. +func (c CheckAddressSpaceAvailabilityRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "communityResourceId", c.CommunityResourceID) + populate(objectMap, "enclaveVirtualNetwork", c.EnclaveVirtualNetwork) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckAddressSpaceAvailabilityRequest. +func (c *CheckAddressSpaceAvailabilityRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "communityResourceId": + err = unpopulate(val, "CommunityResourceID", &c.CommunityResourceID) + delete(rawMsg, key) + case "enclaveVirtualNetwork": + err = unpopulate(val, "EnclaveVirtualNetwork", &c.EnclaveVirtualNetwork) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckAddressSpaceAvailabilityResponse. +func (c CheckAddressSpaceAvailabilityResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckAddressSpaceAvailabilityResponse. +func (c *CheckAddressSpaceAvailabilityResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunityEndpointDestinationRule. +func (c CommunityEndpointDestinationRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "destination", c.Destination) + populate(objectMap, "destinationType", c.DestinationType) + populate(objectMap, "endpointRuleName", c.EndpointRuleName) + populate(objectMap, "ports", c.Ports) + populate(objectMap, "protocols", c.Protocols) + populate(objectMap, "transitHubResourceId", c.TransitHubResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunityEndpointDestinationRule. +func (c *CommunityEndpointDestinationRule) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "destination": + err = unpopulate(val, "Destination", &c.Destination) + delete(rawMsg, key) + case "destinationType": + err = unpopulate(val, "DestinationType", &c.DestinationType) + delete(rawMsg, key) + case "endpointRuleName": + err = unpopulate(val, "EndpointRuleName", &c.EndpointRuleName) + delete(rawMsg, key) + case "ports": + err = unpopulate(val, "Ports", &c.Ports) + delete(rawMsg, key) + case "protocols": + err = unpopulate(val, "Protocols", &c.Protocols) + delete(rawMsg, key) + case "transitHubResourceId": + err = unpopulate(val, "TransitHubResourceID", &c.TransitHubResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunityEndpointPatchModel. +func (c CommunityEndpointPatchModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunityEndpointPatchModel. +func (c *CommunityEndpointPatchModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunityEndpointPatchProperties. +func (c CommunityEndpointPatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ruleCollection", c.RuleCollection) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunityEndpointPatchProperties. +func (c *CommunityEndpointPatchProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "ruleCollection": + err = unpopulate(val, "RuleCollection", &c.RuleCollection) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunityEndpointProperties. +func (c CommunityEndpointProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "resourceCollection", c.ResourceCollection) + populate(objectMap, "ruleCollection", c.RuleCollection) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunityEndpointProperties. +func (c *CommunityEndpointProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) + delete(rawMsg, key) + case "resourceCollection": + err = unpopulate(val, "ResourceCollection", &c.ResourceCollection) + delete(rawMsg, key) + case "ruleCollection": + err = unpopulate(val, "RuleCollection", &c.RuleCollection) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunityEndpointResource. +func (c CommunityEndpointResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunityEndpointResource. +func (c *CommunityEndpointResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunityEndpointResourceListResult. +func (c CommunityEndpointResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunityEndpointResourceListResult. +func (c *CommunityEndpointResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunityPatchModel. +func (c CommunityPatchModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", c.Identity) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunityPatchModel. +func (c *CommunityPatchModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &c.Identity) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunityPatchProperties. +func (c CommunityPatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "approvalSettings", c.ApprovalSettings) + populate(objectMap, "communityRoleAssignments", c.CommunityRoleAssignments) + populate(objectMap, "dnsServers", c.DNSServers) + populate(objectMap, "firewallSku", c.FirewallSKU) + populate(objectMap, "governedServiceList", c.GovernedServiceList) + populate(objectMap, "maintenanceModeConfiguration", c.MaintenanceModeConfiguration) + populate(objectMap, "policyOverride", c.PolicyOverride) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunityPatchProperties. +func (c *CommunityPatchProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "approvalSettings": + err = unpopulate(val, "ApprovalSettings", &c.ApprovalSettings) + delete(rawMsg, key) + case "communityRoleAssignments": + err = unpopulate(val, "CommunityRoleAssignments", &c.CommunityRoleAssignments) + delete(rawMsg, key) + case "dnsServers": + err = unpopulate(val, "DNSServers", &c.DNSServers) + delete(rawMsg, key) + case "firewallSku": + err = unpopulate(val, "FirewallSKU", &c.FirewallSKU) + delete(rawMsg, key) + case "governedServiceList": + err = unpopulate(val, "GovernedServiceList", &c.GovernedServiceList) + delete(rawMsg, key) + case "maintenanceModeConfiguration": + err = unpopulate(val, "MaintenanceModeConfiguration", &c.MaintenanceModeConfiguration) + delete(rawMsg, key) + case "policyOverride": + err = unpopulate(val, "PolicyOverride", &c.PolicyOverride) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunityProperties. +func (c CommunityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addressSpace", c.AddressSpace) + populate(objectMap, "approvalSettings", c.ApprovalSettings) + populate(objectMap, "communityRoleAssignments", c.CommunityRoleAssignments) + populate(objectMap, "dnsServers", c.DNSServers) + populate(objectMap, "firewallSku", c.FirewallSKU) + populate(objectMap, "governedServiceList", c.GovernedServiceList) + populate(objectMap, "maintenanceModeConfiguration", c.MaintenanceModeConfiguration) + populate(objectMap, "managedOnBehalfOfConfiguration", c.ManagedOnBehalfOfConfiguration) + populate(objectMap, "managedResourceGroupName", c.ManagedResourceGroupName) + populate(objectMap, "policyOverride", c.PolicyOverride) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "resourceCollection", c.ResourceCollection) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunityProperties. +func (c *CommunityProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addressSpace": + err = unpopulate(val, "AddressSpace", &c.AddressSpace) + delete(rawMsg, key) + case "approvalSettings": + err = unpopulate(val, "ApprovalSettings", &c.ApprovalSettings) + delete(rawMsg, key) + case "communityRoleAssignments": + err = unpopulate(val, "CommunityRoleAssignments", &c.CommunityRoleAssignments) + delete(rawMsg, key) + case "dnsServers": + err = unpopulate(val, "DNSServers", &c.DNSServers) + delete(rawMsg, key) + case "firewallSku": + err = unpopulate(val, "FirewallSKU", &c.FirewallSKU) + delete(rawMsg, key) + case "governedServiceList": + err = unpopulate(val, "GovernedServiceList", &c.GovernedServiceList) + delete(rawMsg, key) + case "maintenanceModeConfiguration": + err = unpopulate(val, "MaintenanceModeConfiguration", &c.MaintenanceModeConfiguration) + delete(rawMsg, key) + case "managedOnBehalfOfConfiguration": + err = unpopulate(val, "ManagedOnBehalfOfConfiguration", &c.ManagedOnBehalfOfConfiguration) + delete(rawMsg, key) + case "managedResourceGroupName": + err = unpopulate(val, "ManagedResourceGroupName", &c.ManagedResourceGroupName) + delete(rawMsg, key) + case "policyOverride": + err = unpopulate(val, "PolicyOverride", &c.PolicyOverride) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) + delete(rawMsg, key) + case "resourceCollection": + err = unpopulate(val, "ResourceCollection", &c.ResourceCollection) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunityResource. +func (c CommunityResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "identity", c.Identity) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunityResource. +func (c *CommunityResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &c.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommunityResourceListResult. +func (c CommunityResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommunityResourceListResult. +func (c *CommunityResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EnclaveAddressSpacesModel. +func (e EnclaveAddressSpacesModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enclaveAddressSpace", e.EnclaveAddressSpace) + populate(objectMap, "managedAddressSpace", e.ManagedAddressSpace) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnclaveAddressSpacesModel. +func (e *EnclaveAddressSpacesModel) 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 "enclaveAddressSpace": + err = unpopulate(val, "EnclaveAddressSpace", &e.EnclaveAddressSpace) + delete(rawMsg, key) + case "managedAddressSpace": + err = unpopulate(val, "ManagedAddressSpace", &e.ManagedAddressSpace) + 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 EnclaveConnectionPatchModel. +func (e EnclaveConnectionPatchModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnclaveConnectionPatchModel. +func (e *EnclaveConnectionPatchModel) 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 "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 EnclaveConnectionPatchProperties. +func (e EnclaveConnectionPatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sourceCidr", e.SourceCidr) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnclaveConnectionPatchProperties. +func (e *EnclaveConnectionPatchProperties) 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 "sourceCidr": + err = unpopulate(val, "SourceCidr", &e.SourceCidr) + 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 EnclaveConnectionProperties. +func (e EnclaveConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "communityResourceId", e.CommunityResourceID) + populate(objectMap, "destinationEndpointId", e.DestinationEndpointID) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "resourceCollection", e.ResourceCollection) + populate(objectMap, "sourceCidr", e.SourceCidr) + populate(objectMap, "sourceResourceId", e.SourceResourceID) + populate(objectMap, "state", e.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnclaveConnectionProperties. +func (e *EnclaveConnectionProperties) 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 "communityResourceId": + err = unpopulate(val, "CommunityResourceID", &e.CommunityResourceID) + delete(rawMsg, key) + case "destinationEndpointId": + err = unpopulate(val, "DestinationEndpointID", &e.DestinationEndpointID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "resourceCollection": + err = unpopulate(val, "ResourceCollection", &e.ResourceCollection) + delete(rawMsg, key) + case "sourceCidr": + err = unpopulate(val, "SourceCidr", &e.SourceCidr) + delete(rawMsg, key) + case "sourceResourceId": + err = unpopulate(val, "SourceResourceID", &e.SourceResourceID) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &e.State) + 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 EnclaveConnectionResource. +func (e EnclaveConnectionResource) 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 EnclaveConnectionResource. +func (e *EnclaveConnectionResource) 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 EnclaveConnectionResourceListResult. +func (e EnclaveConnectionResourceListResult) 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 EnclaveConnectionResourceListResult. +func (e *EnclaveConnectionResourceListResult) 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 EnclaveDefaultSettingsModel. +func (e EnclaveDefaultSettingsModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "diagnosticDestination", e.DiagnosticDestination) + populate(objectMap, "keyVaultResourceId", e.KeyVaultResourceID) + populate(objectMap, "logAnalyticsResourceIdCollection", e.LogAnalyticsResourceIDCollection) + populate(objectMap, "storageAccountResourceId", e.StorageAccountResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnclaveDefaultSettingsModel. +func (e *EnclaveDefaultSettingsModel) 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 "diagnosticDestination": + err = unpopulate(val, "DiagnosticDestination", &e.DiagnosticDestination) + delete(rawMsg, key) + case "keyVaultResourceId": + err = unpopulate(val, "KeyVaultResourceID", &e.KeyVaultResourceID) + delete(rawMsg, key) + case "logAnalyticsResourceIdCollection": + err = unpopulate(val, "LogAnalyticsResourceIDCollection", &e.LogAnalyticsResourceIDCollection) + delete(rawMsg, key) + case "storageAccountResourceId": + err = unpopulate(val, "StorageAccountResourceID", &e.StorageAccountResourceID) + 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 EnclaveDefaultSettingsPatchModel. +func (e EnclaveDefaultSettingsPatchModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "diagnosticDestination", e.DiagnosticDestination) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnclaveDefaultSettingsPatchModel. +func (e *EnclaveDefaultSettingsPatchModel) 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 "diagnosticDestination": + err = unpopulate(val, "DiagnosticDestination", &e.DiagnosticDestination) + 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 EnclaveEndpointDestinationRule. +func (e EnclaveEndpointDestinationRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "destination", e.Destination) + populate(objectMap, "endpointRuleName", e.EndpointRuleName) + populate(objectMap, "ports", e.Ports) + populate(objectMap, "protocols", e.Protocols) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnclaveEndpointDestinationRule. +func (e *EnclaveEndpointDestinationRule) 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 "destination": + err = unpopulate(val, "Destination", &e.Destination) + delete(rawMsg, key) + case "endpointRuleName": + err = unpopulate(val, "EndpointRuleName", &e.EndpointRuleName) + delete(rawMsg, key) + case "ports": + err = unpopulate(val, "Ports", &e.Ports) + delete(rawMsg, key) + case "protocols": + err = unpopulate(val, "Protocols", &e.Protocols) + 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 EnclaveEndpointPatchModel. +func (e EnclaveEndpointPatchModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnclaveEndpointPatchModel. +func (e *EnclaveEndpointPatchModel) 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 "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 EnclaveEndpointPatchProperties. +func (e EnclaveEndpointPatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ruleCollection", e.RuleCollection) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnclaveEndpointPatchProperties. +func (e *EnclaveEndpointPatchProperties) 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 "ruleCollection": + err = unpopulate(val, "RuleCollection", &e.RuleCollection) + 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 EnclaveEndpointProperties. +func (e EnclaveEndpointProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "resourceCollection", e.ResourceCollection) + populate(objectMap, "ruleCollection", e.RuleCollection) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnclaveEndpointProperties. +func (e *EnclaveEndpointProperties) 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 "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "resourceCollection": + err = unpopulate(val, "ResourceCollection", &e.ResourceCollection) + delete(rawMsg, key) + case "ruleCollection": + err = unpopulate(val, "RuleCollection", &e.RuleCollection) + 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 EnclaveEndpointResource. +func (e EnclaveEndpointResource) 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 EnclaveEndpointResource. +func (e *EnclaveEndpointResource) 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 EnclaveEndpointResourceListResult. +func (e EnclaveEndpointResourceListResult) 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 EnclaveEndpointResourceListResult. +func (e *EnclaveEndpointResourceListResult) 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 EnclaveResource. +func (e EnclaveResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "identity", e.Identity) + 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 EnclaveResource. +func (e *EnclaveResource) 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 "identity": + err = unpopulate(val, "Identity", &e.Identity) + 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 EnclaveResourceListResult. +func (e EnclaveResourceListResult) 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 EnclaveResourceListResult. +func (e *EnclaveResourceListResult) 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 EnclaveVirtualNetworkModel. +func (e EnclaveVirtualNetworkModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowSubnetCommunication", e.AllowSubnetCommunication) + populate(objectMap, "customCidrRange", e.CustomCidrRange) + populate(objectMap, "networkName", e.NetworkName) + populate(objectMap, "networkSize", e.NetworkSize) + populate(objectMap, "subnetConfigurations", e.SubnetConfigurations) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnclaveVirtualNetworkModel. +func (e *EnclaveVirtualNetworkModel) 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 "allowSubnetCommunication": + err = unpopulate(val, "AllowSubnetCommunication", &e.AllowSubnetCommunication) + delete(rawMsg, key) + case "customCidrRange": + err = unpopulate(val, "CustomCidrRange", &e.CustomCidrRange) + delete(rawMsg, key) + case "networkName": + err = unpopulate(val, "NetworkName", &e.NetworkName) + delete(rawMsg, key) + case "networkSize": + err = unpopulate(val, "NetworkSize", &e.NetworkSize) + delete(rawMsg, key) + case "subnetConfigurations": + err = unpopulate(val, "SubnetConfigurations", &e.SubnetConfigurations) + 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 GovernedServiceItem. +func (g GovernedServiceItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enforcement", g.Enforcement) + populate(objectMap, "initiatives", g.Initiatives) + populate(objectMap, "option", g.Option) + populate(objectMap, "policyAction", g.PolicyAction) + populate(objectMap, "serviceId", g.ServiceID) + populate(objectMap, "serviceName", g.ServiceName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GovernedServiceItem. +func (g *GovernedServiceItem) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enforcement": + err = unpopulate(val, "Enforcement", &g.Enforcement) + delete(rawMsg, key) + case "initiatives": + err = unpopulate(val, "Initiatives", &g.Initiatives) + delete(rawMsg, key) + case "option": + err = unpopulate(val, "Option", &g.Option) + delete(rawMsg, key) + case "policyAction": + err = unpopulate(val, "PolicyAction", &g.PolicyAction) + delete(rawMsg, key) + case "serviceId": + err = unpopulate(val, "ServiceID", &g.ServiceID) + delete(rawMsg, key) + case "serviceName": + err = unpopulate(val, "ServiceName", &g.ServiceName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MaintenanceModeConfigurationModel. +func (m MaintenanceModeConfigurationModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "justification", m.Justification) + populate(objectMap, "mode", m.Mode) + populate(objectMap, "principals", m.Principals) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MaintenanceModeConfigurationModel. +func (m *MaintenanceModeConfigurationModel) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "justification": + err = unpopulate(val, "Justification", &m.Justification) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &m.Mode) + delete(rawMsg, key) + case "principals": + err = unpopulate(val, "Principals", &m.Principals) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MaintenanceModeConfigurationPatchModel. +func (m MaintenanceModeConfigurationPatchModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "justification", m.Justification) + populate(objectMap, "mode", m.Mode) + populate(objectMap, "principals", m.Principals) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MaintenanceModeConfigurationPatchModel. +func (m *MaintenanceModeConfigurationPatchModel) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "justification": + err = unpopulate(val, "Justification", &m.Justification) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &m.Mode) + delete(rawMsg, key) + case "principals": + err = unpopulate(val, "Principals", &m.Principals) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedOnBehalfOfConfiguration. +func (m ManagedOnBehalfOfConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "moboBrokerResources", m.MoboBrokerResources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedOnBehalfOfConfiguration. +func (m *ManagedOnBehalfOfConfiguration) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "moboBrokerResources": + err = unpopulate(val, "MoboBrokerResources", &m.MoboBrokerResources) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentity. +func (m *ManagedServiceIdentity) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &m.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &m.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MandatoryApprover. +func (m MandatoryApprover) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "approverEntraId", m.ApproverEntraID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MandatoryApprover. +func (m *MandatoryApprover) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "approverEntraId": + err = unpopulate(val, "ApproverEntraID", &m.ApproverEntraID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MoboBrokerResource. +func (m MoboBrokerResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", m.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MoboBrokerResource. +func (m *MoboBrokerResource) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &m.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Principal. +func (p Principal) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Principal. +func (p *Principal) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RequestMetadata. +func (r RequestMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "approvalCallbackPayload", r.ApprovalCallbackPayload) + populate(objectMap, "approvalCallbackRoute", r.ApprovalCallbackRoute) + populate(objectMap, "approvalStatus", r.ApprovalStatus) + populate(objectMap, "resourceAction", r.ResourceAction) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RequestMetadata. +func (r *RequestMetadata) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "approvalCallbackPayload": + err = unpopulate(val, "ApprovalCallbackPayload", &r.ApprovalCallbackPayload) + delete(rawMsg, key) + case "approvalCallbackRoute": + err = unpopulate(val, "ApprovalCallbackRoute", &r.ApprovalCallbackRoute) + delete(rawMsg, key) + case "approvalStatus": + err = unpopulate(val, "ApprovalStatus", &r.ApprovalStatus) + delete(rawMsg, key) + case "resourceAction": + err = unpopulate(val, "ResourceAction", &r.ResourceAction) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RequestMetadataUpdatableProperties. +func (r RequestMetadataUpdatableProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "approvalCallbackPayload", r.ApprovalCallbackPayload) + populate(objectMap, "approvalCallbackRoute", r.ApprovalCallbackRoute) + populate(objectMap, "approvalStatus", r.ApprovalStatus) + populate(objectMap, "resourceAction", r.ResourceAction) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RequestMetadataUpdatableProperties. +func (r *RequestMetadataUpdatableProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "approvalCallbackPayload": + err = unpopulate(val, "ApprovalCallbackPayload", &r.ApprovalCallbackPayload) + delete(rawMsg, key) + case "approvalCallbackRoute": + err = unpopulate(val, "ApprovalCallbackRoute", &r.ApprovalCallbackRoute) + delete(rawMsg, key) + case "approvalStatus": + err = unpopulate(val, "ApprovalStatus", &r.ApprovalStatus) + delete(rawMsg, key) + case "resourceAction": + err = unpopulate(val, "ResourceAction", &r.ResourceAction) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoleAssignmentItem. +func (r RoleAssignmentItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principals", r.Principals) + populate(objectMap, "roleDefinitionId", r.RoleDefinitionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoleAssignmentItem. +func (r *RoleAssignmentItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principals": + err = unpopulate(val, "Principals", &r.Principals) + delete(rawMsg, key) + case "roleDefinitionId": + err = unpopulate(val, "RoleDefinitionID", &r.RoleDefinitionID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubnetConfiguration. +func (s SubnetConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "addressPrefix", s.AddressPrefix) + populate(objectMap, "networkPrefixSize", s.NetworkPrefixSize) + populate(objectMap, "networkSecurityGroupResourceId", s.NetworkSecurityGroupResourceID) + populate(objectMap, "subnetDelegation", s.SubnetDelegation) + populate(objectMap, "subnetName", s.SubnetName) + populate(objectMap, "subnetResourceId", s.SubnetResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubnetConfiguration. +func (s *SubnetConfiguration) 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 "addressPrefix": + err = unpopulate(val, "AddressPrefix", &s.AddressPrefix) + delete(rawMsg, key) + case "networkPrefixSize": + err = unpopulate(val, "NetworkPrefixSize", &s.NetworkPrefixSize) + delete(rawMsg, key) + case "networkSecurityGroupResourceId": + err = unpopulate(val, "NetworkSecurityGroupResourceID", &s.NetworkSecurityGroupResourceID) + delete(rawMsg, key) + case "subnetDelegation": + err = unpopulate(val, "SubnetDelegation", &s.SubnetDelegation) + delete(rawMsg, key) + case "subnetName": + err = unpopulate(val, "SubnetName", &s.SubnetName) + delete(rawMsg, key) + case "subnetResourceId": + err = unpopulate(val, "SubnetResourceID", &s.SubnetResourceID) + 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 TransitHubPatchModel. +func (t TransitHubPatchModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransitHubPatchModel. +func (t *TransitHubPatchModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransitHubPatchProperties. +func (t TransitHubPatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "state", t.State) + populate(objectMap, "transitOption", t.TransitOption) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransitHubPatchProperties. +func (t *TransitHubPatchProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "state": + err = unpopulate(val, "State", &t.State) + delete(rawMsg, key) + case "transitOption": + err = unpopulate(val, "TransitOption", &t.TransitOption) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransitHubProperties. +func (t TransitHubProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", t.ProvisioningState) + populate(objectMap, "resourceCollection", t.ResourceCollection) + populate(objectMap, "state", t.State) + populate(objectMap, "transitOption", t.TransitOption) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransitHubProperties. +func (t *TransitHubProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &t.ProvisioningState) + delete(rawMsg, key) + case "resourceCollection": + err = unpopulate(val, "ResourceCollection", &t.ResourceCollection) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &t.State) + delete(rawMsg, key) + case "transitOption": + err = unpopulate(val, "TransitOption", &t.TransitOption) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransitHubResource. +func (t TransitHubResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransitHubResource. +func (t *TransitHubResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransitHubResourceListResult. +func (t TransitHubResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransitHubResourceListResult. +func (t *TransitHubResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransitOption. +func (t TransitOption) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "params", t.Params) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransitOption. +func (t *TransitOption) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "params": + err = unpopulate(val, "Params", &t.Params) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TransitOptionParams. +func (t TransitOptionParams) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "remoteVirtualNetworkId", t.RemoteVirtualNetworkID) + populate(objectMap, "scaleUnits", t.ScaleUnits) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TransitOptionParams. +func (t *TransitOptionParams) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "remoteVirtualNetworkId": + err = unpopulate(val, "RemoteVirtualNetworkID", &t.RemoteVirtualNetworkID) + delete(rawMsg, key) + case "scaleUnits": + err = unpopulate(val, "ScaleUnits", &t.ScaleUnits) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentity. +func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentity. +func (u *UserAssignedIdentity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualEnclavePatchModel. +func (v VirtualEnclavePatchModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", v.Identity) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "tags", v.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualEnclavePatchModel. +func (v *VirtualEnclavePatchModel) 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 "identity": + err = unpopulate(val, "Identity", &v.Identity) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &v.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualEnclavePatchProperties. +func (v VirtualEnclavePatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "bastionEnabled", v.BastionEnabled) + populate(objectMap, "enclaveDefaultSettings", v.EnclaveDefaultSettings) + populate(objectMap, "enclaveRoleAssignments", v.EnclaveRoleAssignments) + populate(objectMap, "enclaveVirtualNetwork", v.EnclaveVirtualNetwork) + populate(objectMap, "governedServiceList", v.GovernedServiceList) + populate(objectMap, "maintenanceModeConfiguration", v.MaintenanceModeConfiguration) + populate(objectMap, "workloadRoleAssignments", v.WorkloadRoleAssignments) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualEnclavePatchProperties. +func (v *VirtualEnclavePatchProperties) 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 "bastionEnabled": + err = unpopulate(val, "BastionEnabled", &v.BastionEnabled) + delete(rawMsg, key) + case "enclaveDefaultSettings": + err = unpopulate(val, "EnclaveDefaultSettings", &v.EnclaveDefaultSettings) + delete(rawMsg, key) + case "enclaveRoleAssignments": + err = unpopulate(val, "EnclaveRoleAssignments", &v.EnclaveRoleAssignments) + delete(rawMsg, key) + case "enclaveVirtualNetwork": + err = unpopulate(val, "EnclaveVirtualNetwork", &v.EnclaveVirtualNetwork) + delete(rawMsg, key) + case "governedServiceList": + err = unpopulate(val, "GovernedServiceList", &v.GovernedServiceList) + delete(rawMsg, key) + case "maintenanceModeConfiguration": + err = unpopulate(val, "MaintenanceModeConfiguration", &v.MaintenanceModeConfiguration) + delete(rawMsg, key) + case "workloadRoleAssignments": + err = unpopulate(val, "WorkloadRoleAssignments", &v.WorkloadRoleAssignments) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualEnclaveProperties. +func (v VirtualEnclaveProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "bastionEnabled", v.BastionEnabled) + populate(objectMap, "communityResourceId", v.CommunityResourceID) + populate(objectMap, "enclaveAddressSpaces", v.EnclaveAddressSpaces) + populate(objectMap, "enclaveDefaultSettings", v.EnclaveDefaultSettings) + populate(objectMap, "enclaveRoleAssignments", v.EnclaveRoleAssignments) + populate(objectMap, "enclaveVirtualNetwork", v.EnclaveVirtualNetwork) + populate(objectMap, "governedServiceList", v.GovernedServiceList) + populate(objectMap, "maintenanceModeConfiguration", v.MaintenanceModeConfiguration) + populate(objectMap, "managedOnBehalfOfConfiguration", v.ManagedOnBehalfOfConfiguration) + populate(objectMap, "managedResourceGroupName", v.ManagedResourceGroupName) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "resourceCollection", v.ResourceCollection) + populate(objectMap, "workloadRoleAssignments", v.WorkloadRoleAssignments) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualEnclaveProperties. +func (v *VirtualEnclaveProperties) 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 "bastionEnabled": + err = unpopulate(val, "BastionEnabled", &v.BastionEnabled) + delete(rawMsg, key) + case "communityResourceId": + err = unpopulate(val, "CommunityResourceID", &v.CommunityResourceID) + delete(rawMsg, key) + case "enclaveAddressSpaces": + err = unpopulate(val, "EnclaveAddressSpaces", &v.EnclaveAddressSpaces) + delete(rawMsg, key) + case "enclaveDefaultSettings": + err = unpopulate(val, "EnclaveDefaultSettings", &v.EnclaveDefaultSettings) + delete(rawMsg, key) + case "enclaveRoleAssignments": + err = unpopulate(val, "EnclaveRoleAssignments", &v.EnclaveRoleAssignments) + delete(rawMsg, key) + case "enclaveVirtualNetwork": + err = unpopulate(val, "EnclaveVirtualNetwork", &v.EnclaveVirtualNetwork) + delete(rawMsg, key) + case "governedServiceList": + err = unpopulate(val, "GovernedServiceList", &v.GovernedServiceList) + delete(rawMsg, key) + case "maintenanceModeConfiguration": + err = unpopulate(val, "MaintenanceModeConfiguration", &v.MaintenanceModeConfiguration) + delete(rawMsg, key) + case "managedOnBehalfOfConfiguration": + err = unpopulate(val, "ManagedOnBehalfOfConfiguration", &v.ManagedOnBehalfOfConfiguration) + delete(rawMsg, key) + case "managedResourceGroupName": + err = unpopulate(val, "ManagedResourceGroupName", &v.ManagedResourceGroupName) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) + delete(rawMsg, key) + case "resourceCollection": + err = unpopulate(val, "ResourceCollection", &v.ResourceCollection) + delete(rawMsg, key) + case "workloadRoleAssignments": + err = unpopulate(val, "WorkloadRoleAssignments", &v.WorkloadRoleAssignments) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadPatchModel. +func (w WorkloadPatchModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "tags", w.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadPatchModel. +func (w *WorkloadPatchModel) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &w.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadPatchProperties. +func (w WorkloadPatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceGroupCollection", w.ResourceGroupCollection) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadPatchProperties. +func (w *WorkloadPatchProperties) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceGroupCollection": + err = unpopulate(val, "ResourceGroupCollection", &w.ResourceGroupCollection) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadProperties. +func (w WorkloadProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "managedOnBehalfOfConfiguration", w.ManagedOnBehalfOfConfiguration) + populate(objectMap, "provisioningState", w.ProvisioningState) + populate(objectMap, "resourceGroupCollection", w.ResourceGroupCollection) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadProperties. +func (w *WorkloadProperties) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "managedOnBehalfOfConfiguration": + err = unpopulate(val, "ManagedOnBehalfOfConfiguration", &w.ManagedOnBehalfOfConfiguration) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &w.ProvisioningState) + delete(rawMsg, key) + case "resourceGroupCollection": + err = unpopulate(val, "ResourceGroupCollection", &w.ResourceGroupCollection) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadResource. +func (w WorkloadResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", w.ID) + populate(objectMap, "location", w.Location) + populate(objectMap, "name", w.Name) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "systemData", w.SystemData) + populate(objectMap, "tags", w.Tags) + populate(objectMap, "type", w.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadResource. +func (w *WorkloadResource) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &w.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &w.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &w.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &w.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &w.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkloadResourceListResult. +func (w WorkloadResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkloadResourceListResult. +func (w *WorkloadResourceListResult) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &w.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &w.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, 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/virtualenclaves/armvirtualenclaves/operations_client.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/operations_client.go new file mode 100644 index 000000000000..083a84df5c26 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/operations_client.go @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armvirtualenclaves + +import ( + "context" + "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" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + internal *arm.Client +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - Contains optional client configuration. Pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - List the operations for the provider +// +// Generated from API version 2025-05-01-preview +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Mission/operations" + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/operations_client_example_test.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/operations_client_example_test.go new file mode 100644 index 000000000000..2a28ff816373 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/operations_client_example_test.go @@ -0,0 +1,56 @@ +// 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 armvirtualenclaves_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/virtualenclaves/armvirtualenclaves" + "log" +) + +// Generated from example definition: 2025-05-01-preview/Operations_List.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(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 = armvirtualenclaves.OperationsClientListResponse{ + // OperationListResult: armvirtualenclaves.OperationListResult{ + // Value: []*armvirtualenclaves.Operation{ + // { + // Name: to.Ptr("kribdpoznbvrjci"), + // IsDataAction: to.Ptr(true), + // Display: &armvirtualenclaves.OperationDisplay{ + // Provider: to.Ptr("usvnnruysydqdpwj"), + // Resource: to.Ptr("lrdjzltcbeoljosqrw"), + // Operation: to.Ptr("vdnitexr"), + // Description: to.Ptr("valid description goes here"), + // }, + // Origin: to.Ptr(armvirtualenclaves.OriginUser), + // ActionType: to.Ptr(armvirtualenclaves.ActionTypeInternal), + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/options.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/options.go new file mode 100644 index 000000000000..0e8bb53de200 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/options.go @@ -0,0 +1,362 @@ +// 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 armvirtualenclaves + +// ApprovalClientBeginCreateOrUpdateOptions contains the optional parameters for the ApprovalClient.BeginCreateOrUpdate method. +type ApprovalClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ApprovalClientBeginDeleteOptions contains the optional parameters for the ApprovalClient.BeginDelete method. +type ApprovalClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ApprovalClientBeginNotifyInitiatorOptions contains the optional parameters for the ApprovalClient.BeginNotifyInitiator +// method. +type ApprovalClientBeginNotifyInitiatorOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ApprovalClientBeginUpdateOptions contains the optional parameters for the ApprovalClient.BeginUpdate method. +type ApprovalClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ApprovalClientGetOptions contains the optional parameters for the ApprovalClient.Get method. +type ApprovalClientGetOptions struct { + // placeholder for future optional parameters +} + +// ApprovalClientListByParentOptions contains the optional parameters for the ApprovalClient.NewListByParentPager method. +type ApprovalClientListByParentOptions struct { + // placeholder for future optional parameters +} + +// CommunityClientBeginCreateOrUpdateOptions contains the optional parameters for the CommunityClient.BeginCreateOrUpdate +// method. +type CommunityClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// CommunityClientBeginDeleteOptions contains the optional parameters for the CommunityClient.BeginDelete method. +type CommunityClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// CommunityClientBeginUpdateOptions contains the optional parameters for the CommunityClient.BeginUpdate method. +type CommunityClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// CommunityClientCheckAddressSpaceAvailabilityOptions contains the optional parameters for the CommunityClient.CheckAddressSpaceAvailability +// method. +type CommunityClientCheckAddressSpaceAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// CommunityClientGetOptions contains the optional parameters for the CommunityClient.Get method. +type CommunityClientGetOptions struct { + // placeholder for future optional parameters +} + +// CommunityClientListByResourceGroupOptions contains the optional parameters for the CommunityClient.NewListByResourceGroupPager +// method. +type CommunityClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// CommunityClientListBySubscriptionOptions contains the optional parameters for the CommunityClient.NewListBySubscriptionPager +// method. +type CommunityClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// CommunityEndpointsClientBeginCreateOrUpdateOptions contains the optional parameters for the CommunityEndpointsClient.BeginCreateOrUpdate +// method. +type CommunityEndpointsClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// CommunityEndpointsClientBeginDeleteOptions contains the optional parameters for the CommunityEndpointsClient.BeginDelete +// method. +type CommunityEndpointsClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// CommunityEndpointsClientBeginHandleApprovalCreationOptions contains the optional parameters for the CommunityEndpointsClient.BeginHandleApprovalCreation +// method. +type CommunityEndpointsClientBeginHandleApprovalCreationOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// CommunityEndpointsClientBeginHandleApprovalDeletionOptions contains the optional parameters for the CommunityEndpointsClient.BeginHandleApprovalDeletion +// method. +type CommunityEndpointsClientBeginHandleApprovalDeletionOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// CommunityEndpointsClientBeginUpdateOptions contains the optional parameters for the CommunityEndpointsClient.BeginUpdate +// method. +type CommunityEndpointsClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// CommunityEndpointsClientGetOptions contains the optional parameters for the CommunityEndpointsClient.Get method. +type CommunityEndpointsClientGetOptions struct { + // placeholder for future optional parameters +} + +// CommunityEndpointsClientListByCommunityResourceOptions contains the optional parameters for the CommunityEndpointsClient.NewListByCommunityResourcePager +// method. +type CommunityEndpointsClientListByCommunityResourceOptions struct { + // placeholder for future optional parameters +} + +// CommunityEndpointsClientListBySubscriptionOptions contains the optional parameters for the CommunityEndpointsClient.NewListBySubscriptionPager +// method. +type CommunityEndpointsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// EnclaveConnectionClientBeginCreateOrUpdateOptions contains the optional parameters for the EnclaveConnectionClient.BeginCreateOrUpdate +// method. +type EnclaveConnectionClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EnclaveConnectionClientBeginDeleteOptions contains the optional parameters for the EnclaveConnectionClient.BeginDelete +// method. +type EnclaveConnectionClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EnclaveConnectionClientBeginHandleApprovalCreationOptions contains the optional parameters for the EnclaveConnectionClient.BeginHandleApprovalCreation +// method. +type EnclaveConnectionClientBeginHandleApprovalCreationOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EnclaveConnectionClientBeginHandleApprovalDeletionOptions contains the optional parameters for the EnclaveConnectionClient.BeginHandleApprovalDeletion +// method. +type EnclaveConnectionClientBeginHandleApprovalDeletionOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EnclaveConnectionClientBeginUpdateOptions contains the optional parameters for the EnclaveConnectionClient.BeginUpdate +// method. +type EnclaveConnectionClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EnclaveConnectionClientGetOptions contains the optional parameters for the EnclaveConnectionClient.Get method. +type EnclaveConnectionClientGetOptions struct { + // placeholder for future optional parameters +} + +// EnclaveConnectionClientListByResourceGroupOptions contains the optional parameters for the EnclaveConnectionClient.NewListByResourceGroupPager +// method. +type EnclaveConnectionClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// EnclaveConnectionClientListBySubscriptionOptions contains the optional parameters for the EnclaveConnectionClient.NewListBySubscriptionPager +// method. +type EnclaveConnectionClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// EnclaveEndpointsClientBeginCreateOrUpdateOptions contains the optional parameters for the EnclaveEndpointsClient.BeginCreateOrUpdate +// method. +type EnclaveEndpointsClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EnclaveEndpointsClientBeginDeleteOptions contains the optional parameters for the EnclaveEndpointsClient.BeginDelete method. +type EnclaveEndpointsClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EnclaveEndpointsClientBeginHandleApprovalCreationOptions contains the optional parameters for the EnclaveEndpointsClient.BeginHandleApprovalCreation +// method. +type EnclaveEndpointsClientBeginHandleApprovalCreationOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EnclaveEndpointsClientBeginHandleApprovalDeletionOptions contains the optional parameters for the EnclaveEndpointsClient.BeginHandleApprovalDeletion +// method. +type EnclaveEndpointsClientBeginHandleApprovalDeletionOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EnclaveEndpointsClientBeginUpdateOptions contains the optional parameters for the EnclaveEndpointsClient.BeginUpdate method. +type EnclaveEndpointsClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// EnclaveEndpointsClientGetOptions contains the optional parameters for the EnclaveEndpointsClient.Get method. +type EnclaveEndpointsClientGetOptions struct { + // placeholder for future optional parameters +} + +// EnclaveEndpointsClientListByEnclaveResourceOptions contains the optional parameters for the EnclaveEndpointsClient.NewListByEnclaveResourcePager +// method. +type EnclaveEndpointsClientListByEnclaveResourceOptions struct { + // placeholder for future optional parameters +} + +// EnclaveEndpointsClientListBySubscriptionOptions contains the optional parameters for the EnclaveEndpointsClient.NewListBySubscriptionPager +// method. +type EnclaveEndpointsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// TransitHubClientBeginCreateOrUpdateOptions contains the optional parameters for the TransitHubClient.BeginCreateOrUpdate +// method. +type TransitHubClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// TransitHubClientBeginDeleteOptions contains the optional parameters for the TransitHubClient.BeginDelete method. +type TransitHubClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// TransitHubClientBeginUpdateOptions contains the optional parameters for the TransitHubClient.BeginUpdate method. +type TransitHubClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// TransitHubClientGetOptions contains the optional parameters for the TransitHubClient.Get method. +type TransitHubClientGetOptions struct { + // placeholder for future optional parameters +} + +// TransitHubClientListByCommunityResourceOptions contains the optional parameters for the TransitHubClient.NewListByCommunityResourcePager +// method. +type TransitHubClientListByCommunityResourceOptions struct { + // placeholder for future optional parameters +} + +// TransitHubClientListBySubscriptionOptions contains the optional parameters for the TransitHubClient.NewListBySubscriptionPager +// method. +type TransitHubClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// VirtualEnclaveClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualEnclaveClient.BeginCreateOrUpdate +// method. +type VirtualEnclaveClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// VirtualEnclaveClientBeginDeleteOptions contains the optional parameters for the VirtualEnclaveClient.BeginDelete method. +type VirtualEnclaveClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// VirtualEnclaveClientBeginHandleApprovalCreationOptions contains the optional parameters for the VirtualEnclaveClient.BeginHandleApprovalCreation +// method. +type VirtualEnclaveClientBeginHandleApprovalCreationOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// VirtualEnclaveClientBeginHandleApprovalDeletionOptions contains the optional parameters for the VirtualEnclaveClient.BeginHandleApprovalDeletion +// method. +type VirtualEnclaveClientBeginHandleApprovalDeletionOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// VirtualEnclaveClientBeginUpdateOptions contains the optional parameters for the VirtualEnclaveClient.BeginUpdate method. +type VirtualEnclaveClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// VirtualEnclaveClientGetOptions contains the optional parameters for the VirtualEnclaveClient.Get method. +type VirtualEnclaveClientGetOptions struct { + // placeholder for future optional parameters +} + +// VirtualEnclaveClientListByResourceGroupOptions contains the optional parameters for the VirtualEnclaveClient.NewListByResourceGroupPager +// method. +type VirtualEnclaveClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// VirtualEnclaveClientListBySubscriptionOptions contains the optional parameters for the VirtualEnclaveClient.NewListBySubscriptionPager +// method. +type VirtualEnclaveClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// WorkloadClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkloadClient.BeginCreateOrUpdate method. +type WorkloadClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WorkloadClientBeginDeleteOptions contains the optional parameters for the WorkloadClient.BeginDelete method. +type WorkloadClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WorkloadClientBeginUpdateOptions contains the optional parameters for the WorkloadClient.BeginUpdate method. +type WorkloadClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WorkloadClientGetOptions contains the optional parameters for the WorkloadClient.Get method. +type WorkloadClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkloadClientListByEnclaveResourceOptions contains the optional parameters for the WorkloadClient.NewListByEnclaveResourcePager +// method. +type WorkloadClientListByEnclaveResourceOptions struct { + // placeholder for future optional parameters +} + +// WorkloadClientListBySubscriptionOptions contains the optional parameters for the WorkloadClient.NewListBySubscriptionPager +// method. +type WorkloadClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/responses.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/responses.go new file mode 100644 index 000000000000..046a34fc8185 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/responses.go @@ -0,0 +1,345 @@ +// 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 armvirtualenclaves + +// ApprovalClientCreateOrUpdateResponse contains the response from method ApprovalClient.BeginCreateOrUpdate. +type ApprovalClientCreateOrUpdateResponse struct { + // Approval Model Resource + ApprovalResource +} + +// ApprovalClientDeleteResponse contains the response from method ApprovalClient.BeginDelete. +type ApprovalClientDeleteResponse struct { + // placeholder for future response values +} + +// ApprovalClientGetResponse contains the response from method ApprovalClient.Get. +type ApprovalClientGetResponse struct { + // Approval Model Resource + ApprovalResource +} + +// ApprovalClientListByParentResponse contains the response from method ApprovalClient.NewListByParentPager. +type ApprovalClientListByParentResponse struct { + // The response of a ApprovalResource list operation. + ApprovalResourceListResult +} + +// ApprovalClientNotifyInitiatorResponse contains the response from method ApprovalClient.BeginNotifyInitiator. +type ApprovalClientNotifyInitiatorResponse struct { + // Response body after handling of approvalCallbackRequest + ApprovalActionResponse +} + +// ApprovalClientUpdateResponse contains the response from method ApprovalClient.BeginUpdate. +type ApprovalClientUpdateResponse struct { + // Approval Model Resource + ApprovalResource +} + +// CommunityClientCheckAddressSpaceAvailabilityResponse contains the response from method CommunityClient.CheckAddressSpaceAvailability. +type CommunityClientCheckAddressSpaceAvailabilityResponse struct { + // Response of availability of the requested address space. + CheckAddressSpaceAvailabilityResponse +} + +// CommunityClientCreateOrUpdateResponse contains the response from method CommunityClient.BeginCreateOrUpdate. +type CommunityClientCreateOrUpdateResponse struct { + // Community Model Resource + CommunityResource +} + +// CommunityClientDeleteResponse contains the response from method CommunityClient.BeginDelete. +type CommunityClientDeleteResponse struct { + // placeholder for future response values +} + +// CommunityClientGetResponse contains the response from method CommunityClient.Get. +type CommunityClientGetResponse struct { + // Community Model Resource + CommunityResource +} + +// CommunityClientListByResourceGroupResponse contains the response from method CommunityClient.NewListByResourceGroupPager. +type CommunityClientListByResourceGroupResponse struct { + // The response of a CommunityResource list operation. + CommunityResourceListResult +} + +// CommunityClientListBySubscriptionResponse contains the response from method CommunityClient.NewListBySubscriptionPager. +type CommunityClientListBySubscriptionResponse struct { + // The response of a CommunityResource list operation. + CommunityResourceListResult +} + +// CommunityClientUpdateResponse contains the response from method CommunityClient.BeginUpdate. +type CommunityClientUpdateResponse struct { + // Community Model Resource + CommunityResource +} + +// CommunityEndpointsClientCreateOrUpdateResponse contains the response from method CommunityEndpointsClient.BeginCreateOrUpdate. +type CommunityEndpointsClientCreateOrUpdateResponse struct { + // CommunityEndpoint Model Resource + CommunityEndpointResource +} + +// CommunityEndpointsClientDeleteResponse contains the response from method CommunityEndpointsClient.BeginDelete. +type CommunityEndpointsClientDeleteResponse struct { + // placeholder for future response values +} + +// CommunityEndpointsClientGetResponse contains the response from method CommunityEndpointsClient.Get. +type CommunityEndpointsClientGetResponse struct { + // CommunityEndpoint Model Resource + CommunityEndpointResource +} + +// CommunityEndpointsClientHandleApprovalCreationResponse contains the response from method CommunityEndpointsClient.BeginHandleApprovalCreation. +type CommunityEndpointsClientHandleApprovalCreationResponse struct { + // Response body after handling of approvalCallbackRequest + ApprovalActionResponse +} + +// CommunityEndpointsClientHandleApprovalDeletionResponse contains the response from method CommunityEndpointsClient.BeginHandleApprovalDeletion. +type CommunityEndpointsClientHandleApprovalDeletionResponse struct { + // Response body after handling of approvalCallbackRequest + ApprovalActionResponse +} + +// CommunityEndpointsClientListByCommunityResourceResponse contains the response from method CommunityEndpointsClient.NewListByCommunityResourcePager. +type CommunityEndpointsClientListByCommunityResourceResponse struct { + // The response of a CommunityEndpointResource list operation. + CommunityEndpointResourceListResult +} + +// CommunityEndpointsClientListBySubscriptionResponse contains the response from method CommunityEndpointsClient.NewListBySubscriptionPager. +type CommunityEndpointsClientListBySubscriptionResponse struct { + // The response of a CommunityEndpointResource list operation. + CommunityEndpointResourceListResult +} + +// CommunityEndpointsClientUpdateResponse contains the response from method CommunityEndpointsClient.BeginUpdate. +type CommunityEndpointsClientUpdateResponse struct { + // CommunityEndpoint Model Resource + CommunityEndpointResource +} + +// EnclaveConnectionClientCreateOrUpdateResponse contains the response from method EnclaveConnectionClient.BeginCreateOrUpdate. +type EnclaveConnectionClientCreateOrUpdateResponse struct { + // EnclaveConnection Model Resource + EnclaveConnectionResource +} + +// EnclaveConnectionClientDeleteResponse contains the response from method EnclaveConnectionClient.BeginDelete. +type EnclaveConnectionClientDeleteResponse struct { + // placeholder for future response values +} + +// EnclaveConnectionClientGetResponse contains the response from method EnclaveConnectionClient.Get. +type EnclaveConnectionClientGetResponse struct { + // EnclaveConnection Model Resource + EnclaveConnectionResource +} + +// EnclaveConnectionClientHandleApprovalCreationResponse contains the response from method EnclaveConnectionClient.BeginHandleApprovalCreation. +type EnclaveConnectionClientHandleApprovalCreationResponse struct { + // Response body after handling of approvalCallbackRequest + ApprovalActionResponse +} + +// EnclaveConnectionClientHandleApprovalDeletionResponse contains the response from method EnclaveConnectionClient.BeginHandleApprovalDeletion. +type EnclaveConnectionClientHandleApprovalDeletionResponse struct { + // Response body after handling of approvalCallbackRequest + ApprovalActionResponse +} + +// EnclaveConnectionClientListByResourceGroupResponse contains the response from method EnclaveConnectionClient.NewListByResourceGroupPager. +type EnclaveConnectionClientListByResourceGroupResponse struct { + // The response of a EnclaveConnectionResource list operation. + EnclaveConnectionResourceListResult +} + +// EnclaveConnectionClientListBySubscriptionResponse contains the response from method EnclaveConnectionClient.NewListBySubscriptionPager. +type EnclaveConnectionClientListBySubscriptionResponse struct { + // The response of a EnclaveConnectionResource list operation. + EnclaveConnectionResourceListResult +} + +// EnclaveConnectionClientUpdateResponse contains the response from method EnclaveConnectionClient.BeginUpdate. +type EnclaveConnectionClientUpdateResponse struct { + // EnclaveConnection Model Resource + EnclaveConnectionResource +} + +// EnclaveEndpointsClientCreateOrUpdateResponse contains the response from method EnclaveEndpointsClient.BeginCreateOrUpdate. +type EnclaveEndpointsClientCreateOrUpdateResponse struct { + // EnclaveEndpoint Model Resource + EnclaveEndpointResource +} + +// EnclaveEndpointsClientDeleteResponse contains the response from method EnclaveEndpointsClient.BeginDelete. +type EnclaveEndpointsClientDeleteResponse struct { + // placeholder for future response values +} + +// EnclaveEndpointsClientGetResponse contains the response from method EnclaveEndpointsClient.Get. +type EnclaveEndpointsClientGetResponse struct { + // EnclaveEndpoint Model Resource + EnclaveEndpointResource +} + +// EnclaveEndpointsClientHandleApprovalCreationResponse contains the response from method EnclaveEndpointsClient.BeginHandleApprovalCreation. +type EnclaveEndpointsClientHandleApprovalCreationResponse struct { + // Response body after handling of approvalCallbackRequest + ApprovalActionResponse +} + +// EnclaveEndpointsClientHandleApprovalDeletionResponse contains the response from method EnclaveEndpointsClient.BeginHandleApprovalDeletion. +type EnclaveEndpointsClientHandleApprovalDeletionResponse struct { + // Response body after handling of approvalCallbackRequest + ApprovalActionResponse +} + +// EnclaveEndpointsClientListByEnclaveResourceResponse contains the response from method EnclaveEndpointsClient.NewListByEnclaveResourcePager. +type EnclaveEndpointsClientListByEnclaveResourceResponse struct { + // The response of a EnclaveEndpointResource list operation. + EnclaveEndpointResourceListResult +} + +// EnclaveEndpointsClientListBySubscriptionResponse contains the response from method EnclaveEndpointsClient.NewListBySubscriptionPager. +type EnclaveEndpointsClientListBySubscriptionResponse struct { + // The response of a EnclaveEndpointResource list operation. + EnclaveEndpointResourceListResult +} + +// EnclaveEndpointsClientUpdateResponse contains the response from method EnclaveEndpointsClient.BeginUpdate. +type EnclaveEndpointsClientUpdateResponse struct { + // EnclaveEndpoint Model Resource + EnclaveEndpointResource +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} + +// TransitHubClientCreateOrUpdateResponse contains the response from method TransitHubClient.BeginCreateOrUpdate. +type TransitHubClientCreateOrUpdateResponse struct { + // TransitHub Model Resource + TransitHubResource +} + +// TransitHubClientDeleteResponse contains the response from method TransitHubClient.BeginDelete. +type TransitHubClientDeleteResponse struct { + // placeholder for future response values +} + +// TransitHubClientGetResponse contains the response from method TransitHubClient.Get. +type TransitHubClientGetResponse struct { + // TransitHub Model Resource + TransitHubResource +} + +// TransitHubClientListByCommunityResourceResponse contains the response from method TransitHubClient.NewListByCommunityResourcePager. +type TransitHubClientListByCommunityResourceResponse struct { + // The response of a TransitHubResource list operation. + TransitHubResourceListResult +} + +// TransitHubClientListBySubscriptionResponse contains the response from method TransitHubClient.NewListBySubscriptionPager. +type TransitHubClientListBySubscriptionResponse struct { + // The response of a TransitHubResource list operation. + TransitHubResourceListResult +} + +// TransitHubClientUpdateResponse contains the response from method TransitHubClient.BeginUpdate. +type TransitHubClientUpdateResponse struct { + // TransitHub Model Resource + TransitHubResource +} + +// VirtualEnclaveClientCreateOrUpdateResponse contains the response from method VirtualEnclaveClient.BeginCreateOrUpdate. +type VirtualEnclaveClientCreateOrUpdateResponse struct { + // Virtual Enclave Model Resource + EnclaveResource +} + +// VirtualEnclaveClientDeleteResponse contains the response from method VirtualEnclaveClient.BeginDelete. +type VirtualEnclaveClientDeleteResponse struct { + // placeholder for future response values +} + +// VirtualEnclaveClientGetResponse contains the response from method VirtualEnclaveClient.Get. +type VirtualEnclaveClientGetResponse struct { + // Virtual Enclave Model Resource + EnclaveResource +} + +// VirtualEnclaveClientHandleApprovalCreationResponse contains the response from method VirtualEnclaveClient.BeginHandleApprovalCreation. +type VirtualEnclaveClientHandleApprovalCreationResponse struct { + // Response body after handling of approvalCallbackRequest + ApprovalActionResponse +} + +// VirtualEnclaveClientHandleApprovalDeletionResponse contains the response from method VirtualEnclaveClient.BeginHandleApprovalDeletion. +type VirtualEnclaveClientHandleApprovalDeletionResponse struct { + // Response body after handling of approvalCallbackRequest + ApprovalActionResponse +} + +// VirtualEnclaveClientListByResourceGroupResponse contains the response from method VirtualEnclaveClient.NewListByResourceGroupPager. +type VirtualEnclaveClientListByResourceGroupResponse struct { + // The response of a EnclaveResource list operation. + EnclaveResourceListResult +} + +// VirtualEnclaveClientListBySubscriptionResponse contains the response from method VirtualEnclaveClient.NewListBySubscriptionPager. +type VirtualEnclaveClientListBySubscriptionResponse struct { + // The response of a EnclaveResource list operation. + EnclaveResourceListResult +} + +// VirtualEnclaveClientUpdateResponse contains the response from method VirtualEnclaveClient.BeginUpdate. +type VirtualEnclaveClientUpdateResponse struct { + // Virtual Enclave Model Resource + EnclaveResource +} + +// WorkloadClientCreateOrUpdateResponse contains the response from method WorkloadClient.BeginCreateOrUpdate. +type WorkloadClientCreateOrUpdateResponse struct { + // Workload Model Resource + WorkloadResource +} + +// WorkloadClientDeleteResponse contains the response from method WorkloadClient.BeginDelete. +type WorkloadClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkloadClientGetResponse contains the response from method WorkloadClient.Get. +type WorkloadClientGetResponse struct { + // Workload Model Resource + WorkloadResource +} + +// WorkloadClientListByEnclaveResourceResponse contains the response from method WorkloadClient.NewListByEnclaveResourcePager. +type WorkloadClientListByEnclaveResourceResponse struct { + // The response of a WorkloadResource list operation. + WorkloadResourceListResult +} + +// WorkloadClientListBySubscriptionResponse contains the response from method WorkloadClient.NewListBySubscriptionPager. +type WorkloadClientListBySubscriptionResponse struct { + // The response of a WorkloadResource list operation. + WorkloadResourceListResult +} + +// WorkloadClientUpdateResponse contains the response from method WorkloadClient.BeginUpdate. +type WorkloadClientUpdateResponse struct { + // Workload Model Resource + WorkloadResource +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/testdata/_metadata.json b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/testdata/_metadata.json new file mode 100644 index 000000000000..c7f6b2b9e5b5 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/testdata/_metadata.json @@ -0,0 +1,4 @@ +{ + "apiVersion": "2025-05-01-preview", + "emitterVersion": "0.8.3" +} \ No newline at end of file diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/time_rfc3339.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/time_rfc3339.go new file mode 100644 index 000000000000..1925ad88f025 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/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 armvirtualenclaves + +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/virtualenclaves/armvirtualenclaves/transithub_client.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/transithub_client.go new file mode 100644 index 000000000000..e19bc5c094d1 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/transithub_client.go @@ -0,0 +1,485 @@ +// 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 armvirtualenclaves + +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" +) + +// TransitHubClient - TransitHub Interface +// Don't use this type directly, use NewTransitHubClient() instead. +type TransitHubClient struct { + internal *arm.Client + subscriptionID string +} + +// NewTransitHubClient creates a new instance of TransitHubClient 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 NewTransitHubClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TransitHubClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &TransitHubClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a TransitHubResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - transitHubName - The name of the TransitHub Resource +// - resource - Resource create parameters. +// - options - TransitHubClientBeginCreateOrUpdateOptions contains the optional parameters for the TransitHubClient.BeginCreateOrUpdate +// method. +func (client *TransitHubClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, resource TransitHubResource, options *TransitHubClientBeginCreateOrUpdateOptions) (*runtime.Poller[TransitHubClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, communityName, transitHubName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TransitHubClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TransitHubClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a TransitHubResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *TransitHubClient) createOrUpdate(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, resource TransitHubResource, options *TransitHubClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "TransitHubClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, communityName, transitHubName, 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 +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *TransitHubClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, resource TransitHubResource, _ *TransitHubClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName}" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + if transitHubName == "" { + return nil, errors.New("parameter transitHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transitHubName}", url.PathEscape(transitHubName)) + 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-05-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 TransitHubResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - transitHubName - The name of the TransitHub Resource +// - options - TransitHubClientBeginDeleteOptions contains the optional parameters for the TransitHubClient.BeginDelete method. +func (client *TransitHubClient) BeginDelete(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, options *TransitHubClientBeginDeleteOptions) (*runtime.Poller[TransitHubClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, communityName, transitHubName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TransitHubClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TransitHubClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a TransitHubResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *TransitHubClient) deleteOperation(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, options *TransitHubClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "TransitHubClient.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, communityName, transitHubName, 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 *TransitHubClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, _ *TransitHubClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName}" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + if transitHubName == "" { + return nil, errors.New("parameter transitHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transitHubName}", url.PathEscape(transitHubName)) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Get a TransitHubResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - transitHubName - The name of the TransitHub Resource +// - options - TransitHubClientGetOptions contains the optional parameters for the TransitHubClient.Get method. +func (client *TransitHubClient) Get(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, options *TransitHubClientGetOptions) (TransitHubClientGetResponse, error) { + var err error + const operationName = "TransitHubClient.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, communityName, transitHubName, options) + if err != nil { + return TransitHubClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return TransitHubClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TransitHubClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *TransitHubClient) getCreateRequest(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, _ *TransitHubClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName}" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + if transitHubName == "" { + return nil, errors.New("parameter transitHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transitHubName}", url.PathEscape(transitHubName)) + 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-05-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 *TransitHubClient) getHandleResponse(resp *http.Response) (TransitHubClientGetResponse, error) { + result := TransitHubClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TransitHubResource); err != nil { + return TransitHubClientGetResponse{}, err + } + return result, nil +} + +// NewListByCommunityResourcePager - List TransitHubResource resources by CommunityResource +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - options - TransitHubClientListByCommunityResourceOptions contains the optional parameters for the TransitHubClient.NewListByCommunityResourcePager +// method. +func (client *TransitHubClient) NewListByCommunityResourcePager(resourceGroupName string, communityName string, options *TransitHubClientListByCommunityResourceOptions) *runtime.Pager[TransitHubClientListByCommunityResourceResponse] { + return runtime.NewPager(runtime.PagingHandler[TransitHubClientListByCommunityResourceResponse]{ + More: func(page TransitHubClientListByCommunityResourceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TransitHubClientListByCommunityResourceResponse) (TransitHubClientListByCommunityResourceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TransitHubClient.NewListByCommunityResourcePager") + 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.listByCommunityResourceCreateRequest(ctx, resourceGroupName, communityName, options) + }, nil) + if err != nil { + return TransitHubClientListByCommunityResourceResponse{}, err + } + return client.listByCommunityResourceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByCommunityResourceCreateRequest creates the ListByCommunityResource request. +func (client *TransitHubClient) listByCommunityResourceCreateRequest(ctx context.Context, resourceGroupName string, communityName string, _ *TransitHubClientListByCommunityResourceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByCommunityResourceHandleResponse handles the ListByCommunityResource response. +func (client *TransitHubClient) listByCommunityResourceHandleResponse(resp *http.Response) (TransitHubClientListByCommunityResourceResponse, error) { + result := TransitHubClientListByCommunityResourceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TransitHubResourceListResult); err != nil { + return TransitHubClientListByCommunityResourceResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List TransitHubResource resources by subscription ID +// +// Generated from API version 2025-05-01-preview +// - communityName - The name of the communityResource Resource +// - options - TransitHubClientListBySubscriptionOptions contains the optional parameters for the TransitHubClient.NewListBySubscriptionPager +// method. +func (client *TransitHubClient) NewListBySubscriptionPager(communityName string, options *TransitHubClientListBySubscriptionOptions) *runtime.Pager[TransitHubClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[TransitHubClientListBySubscriptionResponse]{ + More: func(page TransitHubClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *TransitHubClientListBySubscriptionResponse) (TransitHubClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TransitHubClient.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, communityName, options) + }, nil) + if err != nil { + return TransitHubClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *TransitHubClient) listBySubscriptionCreateRequest(ctx context.Context, communityName string, _ *TransitHubClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Mission/communities/{communityName}/transitHubs" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + 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-05-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 *TransitHubClient) listBySubscriptionHandleResponse(resp *http.Response) (TransitHubClientListBySubscriptionResponse, error) { + result := TransitHubClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.TransitHubResourceListResult); err != nil { + return TransitHubClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a TransitHubResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - communityName - The name of the communityResource Resource +// - transitHubName - The name of the TransitHub Resource +// - properties - The resource properties to be updated. +// - options - TransitHubClientBeginUpdateOptions contains the optional parameters for the TransitHubClient.BeginUpdate method. +func (client *TransitHubClient) BeginUpdate(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, properties TransitHubPatchModel, options *TransitHubClientBeginUpdateOptions) (*runtime.Poller[TransitHubClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, communityName, transitHubName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[TransitHubClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[TransitHubClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a TransitHubResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *TransitHubClient) update(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, properties TransitHubPatchModel, options *TransitHubClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "TransitHubClient.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, communityName, transitHubName, 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 *TransitHubClient) updateCreateRequest(ctx context.Context, resourceGroupName string, communityName string, transitHubName string, properties TransitHubPatchModel, _ *TransitHubClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/communities/{communityName}/transitHubs/{transitHubName}" + 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 communityName == "" { + return nil, errors.New("parameter communityName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{communityName}", url.PathEscape(communityName)) + if transitHubName == "" { + return nil, errors.New("parameter transitHubName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{transitHubName}", url.PathEscape(transitHubName)) + 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-05-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/virtualenclaves/armvirtualenclaves/transithub_client_example_test.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/transithub_client_example_test.go new file mode 100644 index 000000000000..9337b63025c0 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/transithub_client_example_test.go @@ -0,0 +1,349 @@ +// 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 armvirtualenclaves_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/virtualenclaves/armvirtualenclaves" + "log" +) + +// Generated from example definition: 2025-05-01-preview/TransitHub_CreateOrUpdate.json +func ExampleTransitHubClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTransitHubClient().BeginCreateOrUpdate(ctx, "rgopenapi", "TestMyCommunity", "TestThName", armvirtualenclaves.TransitHubResource{ + Properties: &armvirtualenclaves.TransitHubProperties{ + State: to.Ptr(armvirtualenclaves.TransitHubStatePendingApproval), + TransitOption: &armvirtualenclaves.TransitOption{ + Type: to.Ptr(armvirtualenclaves.TransitOptionTypeExpressRoute), + Params: &armvirtualenclaves.TransitOptionParams{ + ScaleUnits: to.Ptr[int64](1), + }, + }, + }, + Tags: map[string]*string{ + "Tag1": to.Ptr("Value1"), + }, + Location: to.Ptr("westcentralus"), + }, 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 = armvirtualenclaves.TransitHubClientCreateOrUpdateResponse{ + // TransitHubResource: &armvirtualenclaves.TransitHubResource{ + // Properties: &armvirtualenclaves.TransitHubProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // State: to.Ptr(armvirtualenclaves.TransitHubStatePendingApproval), + // TransitOption: &armvirtualenclaves.TransitOption{ + // Type: to.Ptr(armvirtualenclaves.TransitOptionTypeExpressRoute), + // Params: &armvirtualenclaves.TransitOptionParams{ + // ScaleUnits: to.Ptr[int64](1), + // }, + // }, + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // }, + // Tags: map[string]*string{ + // "Tag1": to.Ptr("Value1"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), + // Name: to.Ptr("TestThName"), + // Type: to.Ptr("microsoft.mission/communities/transithubs"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/TransitHub_Delete.json +func ExampleTransitHubClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTransitHubClient().BeginDelete(ctx, "rgopenapi", "TestMyCommunity", "TestThName", 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-05-01-preview/TransitHub_Get.json +func ExampleTransitHubClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTransitHubClient().Get(ctx, "rgopenapi", "TestMyCommunity", "TestThName", 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 = armvirtualenclaves.TransitHubClientGetResponse{ + // TransitHubResource: &armvirtualenclaves.TransitHubResource{ + // Properties: &armvirtualenclaves.TransitHubProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // State: to.Ptr(armvirtualenclaves.TransitHubStatePendingApproval), + // TransitOption: &armvirtualenclaves.TransitOption{ + // Type: to.Ptr(armvirtualenclaves.TransitOptionTypeExpressRoute), + // Params: &armvirtualenclaves.TransitOptionParams{ + // ScaleUnits: to.Ptr[int64](1), + // }, + // }, + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // }, + // Tags: map[string]*string{ + // "Tag1": to.Ptr("Value1"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), + // Name: to.Ptr("TestThName"), + // Type: to.Ptr("microsoft.mission/communities/transithubs"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/TransitHub_ListByCommunityResource.json +func ExampleTransitHubClient_NewListByCommunityResourcePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTransitHubClient().NewListByCommunityResourcePager("rgopenapi", "TestMyCommunity", 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 = armvirtualenclaves.TransitHubClientListByCommunityResourceResponse{ + // TransitHubResourceListResult: armvirtualenclaves.TransitHubResourceListResult{ + // Value: []*armvirtualenclaves.TransitHubResource{ + // { + // Properties: &armvirtualenclaves.TransitHubProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // State: to.Ptr(armvirtualenclaves.TransitHubStatePendingApproval), + // TransitOption: &armvirtualenclaves.TransitOption{ + // Type: to.Ptr(armvirtualenclaves.TransitOptionTypeExpressRoute), + // Params: &armvirtualenclaves.TransitOptionParams{ + // ScaleUnits: to.Ptr[int64](1), + // }, + // }, + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // }, + // Tags: map[string]*string{ + // "Tag1": to.Ptr("Value1"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), + // Name: to.Ptr("TestThName"), + // Type: to.Ptr("microsoft.mission/communities/transithub"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/TransitHub_ListBySubscription.json +func ExampleTransitHubClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTransitHubClient().NewListBySubscriptionPager("TestMyCommunity", 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 = armvirtualenclaves.TransitHubClientListBySubscriptionResponse{ + // TransitHubResourceListResult: armvirtualenclaves.TransitHubResourceListResult{ + // Value: []*armvirtualenclaves.TransitHubResource{ + // { + // Properties: &armvirtualenclaves.TransitHubProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // State: to.Ptr(armvirtualenclaves.TransitHubStatePendingApproval), + // TransitOption: &armvirtualenclaves.TransitOption{ + // Type: to.Ptr(armvirtualenclaves.TransitOptionTypeExpressRoute), + // Params: &armvirtualenclaves.TransitOptionParams{ + // ScaleUnits: to.Ptr[int64](1), + // }, + // }, + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // }, + // Tags: map[string]*string{ + // "Tag1": to.Ptr("Value1"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), + // Name: to.Ptr("TestThName"), + // Type: to.Ptr("microsoft.mission/communities/transithubs"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/TransitHub_Update.json +func ExampleTransitHubClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewTransitHubClient().BeginUpdate(ctx, "rgopenapi", "TestMyCommunity", "TestThName", armvirtualenclaves.TransitHubPatchModel{ + Tags: map[string]*string{ + "key4278": to.Ptr("hjoxhwofxcshowbnafdrrzq"), + }, + Properties: &armvirtualenclaves.TransitHubPatchProperties{ + State: to.Ptr(armvirtualenclaves.TransitHubStatePendingApproval), + TransitOption: &armvirtualenclaves.TransitOption{ + Type: to.Ptr(armvirtualenclaves.TransitOptionTypeExpressRoute), + Params: &armvirtualenclaves.TransitOptionParams{ + ScaleUnits: to.Ptr[int64](1), + }, + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armvirtualenclaves.TransitHubClientUpdateResponse{ + // TransitHubResource: &armvirtualenclaves.TransitHubResource{ + // Properties: &armvirtualenclaves.TransitHubProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // State: to.Ptr(armvirtualenclaves.TransitHubStatePendingApproval), + // TransitOption: &armvirtualenclaves.TransitOption{ + // Type: to.Ptr(armvirtualenclaves.TransitOptionTypeExpressRoute), + // Params: &armvirtualenclaves.TransitOptionParams{ + // ScaleUnits: to.Ptr[int64](1), + // }, + // }, + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // }, + // Tags: map[string]*string{ + // "Tag1": to.Ptr("Value1"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/testrg/providers/Microsoft.Mission/communities/TestMyCommunity/transitHubs/TestThName"), + // Name: to.Ptr("TestThName"), + // Type: to.Ptr("microsoft.mission/communities/transithubs"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/tsp-location.yaml b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/tsp-location.yaml new file mode 100644 index 000000000000..d703434037cd --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/mission/Mission.Management +commit: 1bd335533d57d11a33d41be9b5841e6986ec3567 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/version.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/version.go new file mode 100644 index 000000000000..cffe8d0f24f1 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/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 armvirtualenclaves + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/virtualenclaves/armvirtualenclaves" + moduleVersion = "v0.1.0" +) diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/virtualenclave_client.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/virtualenclave_client.go new file mode 100644 index 000000000000..223805e66d7e --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/virtualenclave_client.go @@ -0,0 +1,619 @@ +// 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 armvirtualenclaves + +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" +) + +// VirtualEnclaveClient - Virtual Enclave Interface +// Don't use this type directly, use NewVirtualEnclaveClient() instead. +type VirtualEnclaveClient struct { + internal *arm.Client + subscriptionID string +} + +// NewVirtualEnclaveClient creates a new instance of VirtualEnclaveClient 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 NewVirtualEnclaveClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualEnclaveClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &VirtualEnclaveClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a EnclaveResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - resource - Resource create parameters. +// - options - VirtualEnclaveClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualEnclaveClient.BeginCreateOrUpdate +// method. +func (client *VirtualEnclaveClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualEnclaveName string, resource EnclaveResource, options *VirtualEnclaveClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualEnclaveClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, virtualEnclaveName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualEnclaveClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualEnclaveClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a EnclaveResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *VirtualEnclaveClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualEnclaveName string, resource EnclaveResource, options *VirtualEnclaveClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "VirtualEnclaveClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, virtualEnclaveName, 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 +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *VirtualEnclaveClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, resource EnclaveResource, _ *VirtualEnclaveClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + 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-05-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 EnclaveResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - options - VirtualEnclaveClientBeginDeleteOptions contains the optional parameters for the VirtualEnclaveClient.BeginDelete +// method. +func (client *VirtualEnclaveClient) BeginDelete(ctx context.Context, resourceGroupName string, virtualEnclaveName string, options *VirtualEnclaveClientBeginDeleteOptions) (*runtime.Poller[VirtualEnclaveClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, virtualEnclaveName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualEnclaveClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualEnclaveClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a EnclaveResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *VirtualEnclaveClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualEnclaveName string, options *VirtualEnclaveClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "VirtualEnclaveClient.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, virtualEnclaveName, 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 *VirtualEnclaveClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, _ *VirtualEnclaveClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Get a EnclaveResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - options - VirtualEnclaveClientGetOptions contains the optional parameters for the VirtualEnclaveClient.Get method. +func (client *VirtualEnclaveClient) Get(ctx context.Context, resourceGroupName string, virtualEnclaveName string, options *VirtualEnclaveClientGetOptions) (VirtualEnclaveClientGetResponse, error) { + var err error + const operationName = "VirtualEnclaveClient.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, virtualEnclaveName, options) + if err != nil { + return VirtualEnclaveClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VirtualEnclaveClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VirtualEnclaveClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *VirtualEnclaveClient) getCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, _ *VirtualEnclaveClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + 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-05-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 *VirtualEnclaveClient) getHandleResponse(resp *http.Response) (VirtualEnclaveClientGetResponse, error) { + result := VirtualEnclaveClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnclaveResource); err != nil { + return VirtualEnclaveClientGetResponse{}, err + } + return result, nil +} + +// BeginHandleApprovalCreation - Callback that triggers on approval state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - body - The content of the action request +// - options - VirtualEnclaveClientBeginHandleApprovalCreationOptions contains the optional parameters for the VirtualEnclaveClient.BeginHandleApprovalCreation +// method. +func (client *VirtualEnclaveClient) BeginHandleApprovalCreation(ctx context.Context, resourceGroupName string, virtualEnclaveName string, body ApprovalCallbackRequest, options *VirtualEnclaveClientBeginHandleApprovalCreationOptions) (*runtime.Poller[VirtualEnclaveClientHandleApprovalCreationResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.handleApprovalCreation(ctx, resourceGroupName, virtualEnclaveName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualEnclaveClientHandleApprovalCreationResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualEnclaveClientHandleApprovalCreationResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// HandleApprovalCreation - Callback that triggers on approval state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *VirtualEnclaveClient) handleApprovalCreation(ctx context.Context, resourceGroupName string, virtualEnclaveName string, body ApprovalCallbackRequest, options *VirtualEnclaveClientBeginHandleApprovalCreationOptions) (*http.Response, error) { + var err error + const operationName = "VirtualEnclaveClient.BeginHandleApprovalCreation" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.handleApprovalCreationCreateRequest(ctx, resourceGroupName, virtualEnclaveName, 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 +} + +// handleApprovalCreationCreateRequest creates the HandleApprovalCreation request. +func (client *VirtualEnclaveClient) handleApprovalCreationCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, body ApprovalCallbackRequest, _ *VirtualEnclaveClientBeginHandleApprovalCreationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/handleApprovalCreation" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + 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-05-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 +} + +// BeginHandleApprovalDeletion - Callback that triggers on approval deletion state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - body - The content of the action request +// - options - VirtualEnclaveClientBeginHandleApprovalDeletionOptions contains the optional parameters for the VirtualEnclaveClient.BeginHandleApprovalDeletion +// method. +func (client *VirtualEnclaveClient) BeginHandleApprovalDeletion(ctx context.Context, resourceGroupName string, virtualEnclaveName string, body ApprovalDeletionCallbackRequest, options *VirtualEnclaveClientBeginHandleApprovalDeletionOptions) (*runtime.Poller[VirtualEnclaveClientHandleApprovalDeletionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.handleApprovalDeletion(ctx, resourceGroupName, virtualEnclaveName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualEnclaveClientHandleApprovalDeletionResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualEnclaveClientHandleApprovalDeletionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// HandleApprovalDeletion - Callback that triggers on approval deletion state change. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *VirtualEnclaveClient) handleApprovalDeletion(ctx context.Context, resourceGroupName string, virtualEnclaveName string, body ApprovalDeletionCallbackRequest, options *VirtualEnclaveClientBeginHandleApprovalDeletionOptions) (*http.Response, error) { + var err error + const operationName = "VirtualEnclaveClient.BeginHandleApprovalDeletion" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.handleApprovalDeletionCreateRequest(ctx, resourceGroupName, virtualEnclaveName, 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 +} + +// handleApprovalDeletionCreateRequest creates the HandleApprovalDeletion request. +func (client *VirtualEnclaveClient) handleApprovalDeletionCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, body ApprovalDeletionCallbackRequest, _ *VirtualEnclaveClientBeginHandleApprovalDeletionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/handleApprovalDeletion" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + 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-05-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 +} + +// NewListByResourceGroupPager - List EnclaveResource resources by resource group +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - VirtualEnclaveClientListByResourceGroupOptions contains the optional parameters for the VirtualEnclaveClient.NewListByResourceGroupPager +// method. +func (client *VirtualEnclaveClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualEnclaveClientListByResourceGroupOptions) *runtime.Pager[VirtualEnclaveClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[VirtualEnclaveClientListByResourceGroupResponse]{ + More: func(page VirtualEnclaveClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VirtualEnclaveClientListByResourceGroupResponse) (VirtualEnclaveClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VirtualEnclaveClient.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 VirtualEnclaveClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *VirtualEnclaveClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *VirtualEnclaveClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves" + 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-05-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 *VirtualEnclaveClient) listByResourceGroupHandleResponse(resp *http.Response) (VirtualEnclaveClientListByResourceGroupResponse, error) { + result := VirtualEnclaveClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnclaveResourceListResult); err != nil { + return VirtualEnclaveClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List EnclaveResource resources by subscription ID +// +// Generated from API version 2025-05-01-preview +// - options - VirtualEnclaveClientListBySubscriptionOptions contains the optional parameters for the VirtualEnclaveClient.NewListBySubscriptionPager +// method. +func (client *VirtualEnclaveClient) NewListBySubscriptionPager(options *VirtualEnclaveClientListBySubscriptionOptions) *runtime.Pager[VirtualEnclaveClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[VirtualEnclaveClientListBySubscriptionResponse]{ + More: func(page VirtualEnclaveClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VirtualEnclaveClientListBySubscriptionResponse) (VirtualEnclaveClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VirtualEnclaveClient.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 VirtualEnclaveClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *VirtualEnclaveClient) listBySubscriptionCreateRequest(ctx context.Context, _ *VirtualEnclaveClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves" + 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-05-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 *VirtualEnclaveClient) listBySubscriptionHandleResponse(resp *http.Response) (VirtualEnclaveClientListBySubscriptionResponse, error) { + result := VirtualEnclaveClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnclaveResourceListResult); err != nil { + return VirtualEnclaveClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a EnclaveResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - properties - The resource properties to be updated. +// - options - VirtualEnclaveClientBeginUpdateOptions contains the optional parameters for the VirtualEnclaveClient.BeginUpdate +// method. +func (client *VirtualEnclaveClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualEnclaveName string, properties VirtualEnclavePatchModel, options *VirtualEnclaveClientBeginUpdateOptions) (*runtime.Poller[VirtualEnclaveClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, virtualEnclaveName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualEnclaveClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualEnclaveClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a EnclaveResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *VirtualEnclaveClient) update(ctx context.Context, resourceGroupName string, virtualEnclaveName string, properties VirtualEnclavePatchModel, options *VirtualEnclaveClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "VirtualEnclaveClient.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, virtualEnclaveName, 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 *VirtualEnclaveClient) updateCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, properties VirtualEnclavePatchModel, _ *VirtualEnclaveClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + 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-05-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/virtualenclaves/armvirtualenclaves/virtualenclave_client_example_test.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/virtualenclave_client_example_test.go new file mode 100644 index 000000000000..60f79d5dd1ea --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/virtualenclave_client_example_test.go @@ -0,0 +1,959 @@ +// 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 armvirtualenclaves_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/virtualenclaves/armvirtualenclaves" + "log" +) + +// Generated from example definition: 2025-05-01-preview/VirtualEnclave_CreateOrUpdate.json +func ExampleVirtualEnclaveClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualEnclaveClient().BeginCreateOrUpdate(ctx, "rgopenapi", "TestMyEnclave", armvirtualenclaves.EnclaveResource{ + Identity: &armvirtualenclaves.ManagedServiceIdentity{ + Type: to.Ptr(armvirtualenclaves.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + UserAssignedIdentities: map[string]*armvirtualenclaves.UserAssignedIdentity{ + "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, + }, + }, + Properties: &armvirtualenclaves.VirtualEnclaveProperties{ + EnclaveVirtualNetwork: &armvirtualenclaves.EnclaveVirtualNetworkModel{ + NetworkSize: to.Ptr("small"), + CustomCidrRange: to.Ptr("10.0.0.0/24"), + SubnetConfigurations: []*armvirtualenclaves.SubnetConfiguration{ + { + SubnetName: to.Ptr("test"), + NetworkPrefixSize: to.Ptr[int32](26), + }, + }, + AllowSubnetCommunication: to.Ptr(true), + }, + CommunityResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/communities/TestMyCommunity"), + EnclaveDefaultSettings: &armvirtualenclaves.EnclaveDefaultSettingsModel{ + DiagnosticDestination: to.Ptr(armvirtualenclaves.DiagnosticDestinationBoth), + }, + MaintenanceModeConfiguration: &armvirtualenclaves.MaintenanceModeConfigurationModel{ + Mode: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelModeOff), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + }, + }, + Justification: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelJustificationOff), + }, + BastionEnabled: to.Ptr(true), + EnclaveRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + { + RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + }, + { + ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + }, + }, + }, + { + RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + }, + }, + }, + }, + WorkloadRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + { + RoleDefinitionID: to.Ptr("d73bb868-a0df-4d4d-bd69-98a00b01fccb"), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + }, + }, + }, + { + RoleDefinitionID: to.Ptr("fb879df8-f326-4884-b1cf-06f3ad86be52"), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + }, + }, + }, + }, + }, + Tags: map[string]*string{ + "Tag1": to.Ptr("Value1"), + }, + Location: to.Ptr("westcentralus"), + }, 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 = armvirtualenclaves.VirtualEnclaveClientCreateOrUpdateResponse{ + // EnclaveResource: &armvirtualenclaves.EnclaveResource{ + // Identity: &armvirtualenclaves.ManagedServiceIdentity{ + // Type: to.Ptr(armvirtualenclaves.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + // PrincipalID: to.Ptr("1a2e532b-9900-414c-8600-cfc6126628d7"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), + // UserAssignedIdentities: map[string]*armvirtualenclaves.UserAssignedIdentity{ + // "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armvirtualenclaves.UserAssignedIdentity{ + // PrincipalID: to.Ptr("f4aa4954-a564-4933-a7e1-502019d807c2"), + // ClientID: to.Ptr("b82bf757-ee7f-4632-9df1-5e52a720fdd2"), + // }, + // }, + // }, + // Properties: &armvirtualenclaves.VirtualEnclaveProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // EnclaveVirtualNetwork: &armvirtualenclaves.EnclaveVirtualNetworkModel{ + // NetworkSize: to.Ptr("small"), + // CustomCidrRange: to.Ptr("10.0.0.0/24"), + // SubnetConfigurations: []*armvirtualenclaves.SubnetConfiguration{ + // { + // SubnetName: to.Ptr("test"), + // NetworkPrefixSize: to.Ptr[int32](26), + // }, + // }, + // AllowSubnetCommunication: to.Ptr(true), + // }, + // CommunityResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/communities/TestMyCommunity"), + // EnclaveDefaultSettings: &armvirtualenclaves.EnclaveDefaultSettingsModel{ + // KeyVaultResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.KeyVault/vaults/TestMyKeyVault1"), + // StorageAccountResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Storage/storageAccounts/TestMyStorageAccount"), + // LogAnalyticsResourceIDCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.OperationalInsights/workspaces/TestMyLogA1"), + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.OperationalInsights/workspaces/TestMyLogA2"), + // }, + // DiagnosticDestination: to.Ptr(armvirtualenclaves.DiagnosticDestinationBoth), + // }, + // ResourceCollection: []*string{ + // }, + // MaintenanceModeConfiguration: &armvirtualenclaves.MaintenanceModeConfigurationModel{ + // Mode: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelModeOff), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // Justification: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelJustificationOff), + // }, + // BastionEnabled: to.Ptr(true), + // EnclaveRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // }, + // WorkloadRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("d73bb868-a0df-4d4d-bd69-98a00b01fccb"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("fb879df8-f326-4884-b1cf-06f3ad86be52"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "Tag1": to.Ptr("Value1"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // Name: to.Ptr("TestMyEnclave"), + // Type: to.Ptr("microsoft.mission/virtualenclaves"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/VirtualEnclave_Delete.json +func ExampleVirtualEnclaveClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualEnclaveClient().BeginDelete(ctx, "rgopenapi", "TestMyEnclave", 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-05-01-preview/VirtualEnclave_Get.json +func ExampleVirtualEnclaveClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualEnclaveClient().Get(ctx, "rgopenapi", "TestMyEnclave", 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 = armvirtualenclaves.VirtualEnclaveClientGetResponse{ + // EnclaveResource: &armvirtualenclaves.EnclaveResource{ + // Identity: &armvirtualenclaves.ManagedServiceIdentity{ + // Type: to.Ptr(armvirtualenclaves.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + // PrincipalID: to.Ptr("1a2e532b-9900-414c-8600-cfc6126628d7"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), + // UserAssignedIdentities: map[string]*armvirtualenclaves.UserAssignedIdentity{ + // "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armvirtualenclaves.UserAssignedIdentity{ + // PrincipalID: to.Ptr("f4aa4954-a564-4933-a7e1-502019d807c2"), + // ClientID: to.Ptr("b82bf757-ee7f-4632-9df1-5e52a720fdd2"), + // }, + // }, + // }, + // Properties: &armvirtualenclaves.VirtualEnclaveProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // EnclaveVirtualNetwork: &armvirtualenclaves.EnclaveVirtualNetworkModel{ + // NetworkSize: to.Ptr("small"), + // CustomCidrRange: to.Ptr("10.0.0.0/24"), + // SubnetConfigurations: []*armvirtualenclaves.SubnetConfiguration{ + // { + // SubnetName: to.Ptr("test"), + // SubnetResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.KeyVault/vaults/TestMyKeyVault1"), + // NetworkPrefixSize: to.Ptr[int32](26), + // AddressPrefix: to.Ptr("10.0.0.0/26"), + // NetworkSecurityGroupResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.KeyVault/vaults/TestMyKeyVault1"), + // }, + // }, + // AllowSubnetCommunication: to.Ptr(true), + // }, + // ManagedOnBehalfOfConfiguration: &armvirtualenclaves.ManagedOnBehalfOfConfiguration{ + // MoboBrokerResources: []*armvirtualenclaves.MoboBrokerResource{ + // { + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Resources/moboBrokers/bnthrkwfkfeorrzvtdxbfz"), + // }, + // }, + // }, + // CommunityResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/communities/TestMyCommunity"), + // EnclaveDefaultSettings: &armvirtualenclaves.EnclaveDefaultSettingsModel{ + // KeyVaultResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.KeyVault/vaults/TestMyKeyVault1"), + // StorageAccountResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Storage/storageAccounts/TestMyStorageAccount"), + // LogAnalyticsResourceIDCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.OperationalInsights/workspaces/TestMyLogA1"), + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.OperationalInsights/workspaces/TestMyLogA2"), + // }, + // DiagnosticDestination: to.Ptr(armvirtualenclaves.DiagnosticDestinationBoth), + // }, + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // MaintenanceModeConfiguration: &armvirtualenclaves.MaintenanceModeConfigurationModel{ + // Mode: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelModeOff), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // Justification: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelJustificationOff), + // }, + // BastionEnabled: to.Ptr(true), + // EnclaveRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // }, + // WorkloadRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("d73bb868-a0df-4d4d-bd69-98a00b01fccb"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("fb879df8-f326-4884-b1cf-06f3ad86be52"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "Tag1": to.Ptr("Value1"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // Name: to.Ptr("TestMyEnclave"), + // Type: to.Ptr("microsoft.mission/virtualenclaves"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/VirtualEnclave_HandleApprovalCreation.json +func ExampleVirtualEnclaveClient_BeginHandleApprovalCreation() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualEnclaveClient().BeginHandleApprovalCreation(ctx, "rgopenapi", "TestMyEnclave", armvirtualenclaves.ApprovalCallbackRequest{ + ResourceRequestAction: to.Ptr(armvirtualenclaves.ApprovalCallbackRequestResourceRequestActionCreate), + ApprovalStatus: to.Ptr(armvirtualenclaves.ApprovalCallbackRequestApprovalStatusApproved), + ApprovalCallbackPayload: to.Ptr("{\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n}"), + }, 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 = armvirtualenclaves.VirtualEnclaveClientHandleApprovalCreationResponse{ + // ApprovalActionResponse: &armvirtualenclaves.ApprovalActionResponse{ + // Message: to.Ptr("Approval state change handled successfully."), + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/VirtualEnclave_HandleApprovalDeletion.json +func ExampleVirtualEnclaveClient_BeginHandleApprovalDeletion() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualEnclaveClient().BeginHandleApprovalDeletion(ctx, "rgopenapi", "TestMyEnclave", armvirtualenclaves.ApprovalDeletionCallbackRequest{ + ResourceRequestAction: to.Ptr(armvirtualenclaves.ApprovalDeletionCallbackRequestResourceRequestActionCreate), + }, 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 = armvirtualenclaves.VirtualEnclaveClientHandleApprovalDeletionResponse{ + // ApprovalActionResponse: &armvirtualenclaves.ApprovalActionResponse{ + // Message: to.Ptr("Approval state change handled successfully."), + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/VirtualEnclave_ListByResourceGroup.json +func ExampleVirtualEnclaveClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVirtualEnclaveClient().NewListByResourceGroupPager("rgopenapi", 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 = armvirtualenclaves.VirtualEnclaveClientListByResourceGroupResponse{ + // EnclaveResourceListResult: armvirtualenclaves.EnclaveResourceListResult{ + // Value: []*armvirtualenclaves.EnclaveResource{ + // { + // Identity: &armvirtualenclaves.ManagedServiceIdentity{ + // Type: to.Ptr(armvirtualenclaves.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + // PrincipalID: to.Ptr("1a2e532b-9900-414c-8600-cfc6126628d7"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), + // UserAssignedIdentities: map[string]*armvirtualenclaves.UserAssignedIdentity{ + // "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armvirtualenclaves.UserAssignedIdentity{ + // PrincipalID: to.Ptr("f4aa4954-a564-4933-a7e1-502019d807c2"), + // ClientID: to.Ptr("b82bf757-ee7f-4632-9df1-5e52a720fdd2"), + // }, + // }, + // }, + // Properties: &armvirtualenclaves.VirtualEnclaveProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // EnclaveVirtualNetwork: &armvirtualenclaves.EnclaveVirtualNetworkModel{ + // NetworkSize: to.Ptr("small"), + // CustomCidrRange: to.Ptr("10.0.0.0/24"), + // SubnetConfigurations: []*armvirtualenclaves.SubnetConfiguration{ + // { + // SubnetName: to.Ptr("test"), + // SubnetResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.KeyVault/vaults/TestMyKeyVault1"), + // NetworkPrefixSize: to.Ptr[int32](26), + // AddressPrefix: to.Ptr("10.0.0.0/26"), + // NetworkSecurityGroupResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.KeyVault/vaults/TestMyKeyVault1"), + // }, + // }, + // AllowSubnetCommunication: to.Ptr(true), + // }, + // CommunityResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/communities/TestMyCommunity"), + // EnclaveDefaultSettings: &armvirtualenclaves.EnclaveDefaultSettingsModel{ + // KeyVaultResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.KeyVault/vaults/TestMyKeyVault1"), + // StorageAccountResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Storage/storageAccounts/TestMyStorageAccount"), + // LogAnalyticsResourceIDCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.OperationalInsights/workspaces/TestMyLogA1"), + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.OperationalInsights/workspaces/TestMyLogA2"), + // }, + // DiagnosticDestination: to.Ptr(armvirtualenclaves.DiagnosticDestinationBoth), + // }, + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // MaintenanceModeConfiguration: &armvirtualenclaves.MaintenanceModeConfigurationModel{ + // Mode: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelModeOff), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // Justification: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelJustificationOff), + // }, + // BastionEnabled: to.Ptr(true), + // EnclaveRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // }, + // WorkloadRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("d73bb868-a0df-4d4d-bd69-98a00b01fccb"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("fb879df8-f326-4884-b1cf-06f3ad86be52"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "Tag1": to.Ptr("Value1"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // Name: to.Ptr("TestMyEnclave"), + // Type: to.Ptr("microsoft.mission/virtualenclaves"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/VirtualEnclave_ListBySubscription.json +func ExampleVirtualEnclaveClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVirtualEnclaveClient().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 = armvirtualenclaves.VirtualEnclaveClientListBySubscriptionResponse{ + // EnclaveResourceListResult: armvirtualenclaves.EnclaveResourceListResult{ + // Value: []*armvirtualenclaves.EnclaveResource{ + // { + // Identity: &armvirtualenclaves.ManagedServiceIdentity{ + // Type: to.Ptr(armvirtualenclaves.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + // PrincipalID: to.Ptr("1a2e532b-9900-414c-8600-cfc6126628d7"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), + // UserAssignedIdentities: map[string]*armvirtualenclaves.UserAssignedIdentity{ + // "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armvirtualenclaves.UserAssignedIdentity{ + // PrincipalID: to.Ptr("f4aa4954-a564-4933-a7e1-502019d807c2"), + // ClientID: to.Ptr("b82bf757-ee7f-4632-9df1-5e52a720fdd2"), + // }, + // }, + // }, + // Properties: &armvirtualenclaves.VirtualEnclaveProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // EnclaveVirtualNetwork: &armvirtualenclaves.EnclaveVirtualNetworkModel{ + // NetworkSize: to.Ptr("small"), + // CustomCidrRange: to.Ptr("10.0.0.0/24"), + // SubnetConfigurations: []*armvirtualenclaves.SubnetConfiguration{ + // { + // SubnetName: to.Ptr("test"), + // SubnetResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.KeyVault/vaults/TestMyKeyVault1"), + // NetworkPrefixSize: to.Ptr[int32](26), + // AddressPrefix: to.Ptr("10.0.0.0/26"), + // NetworkSecurityGroupResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.KeyVault/vaults/TestMyKeyVault1"), + // }, + // }, + // AllowSubnetCommunication: to.Ptr(true), + // }, + // CommunityResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/communities/TestMyCommunity"), + // EnclaveDefaultSettings: &armvirtualenclaves.EnclaveDefaultSettingsModel{ + // KeyVaultResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.KeyVault/vaults/TestMyKeyVault1"), + // StorageAccountResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Storage/storageAccounts/TestMyStorageAccount"), + // LogAnalyticsResourceIDCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.OperationalInsights/workspaces/TestMyLogA1"), + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.OperationalInsights/workspaces/TestMyLogA2"), + // }, + // DiagnosticDestination: to.Ptr(armvirtualenclaves.DiagnosticDestinationBoth), + // }, + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // MaintenanceModeConfiguration: &armvirtualenclaves.MaintenanceModeConfigurationModel{ + // Mode: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelModeOff), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // Justification: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelJustificationOff), + // }, + // BastionEnabled: to.Ptr(true), + // EnclaveRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // }, + // WorkloadRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("d73bb868-a0df-4d4d-bd69-98a00b01fccb"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("fb879df8-f326-4884-b1cf-06f3ad86be52"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "Tag1": to.Ptr("Value1"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // Name: to.Ptr("TestMyEnclave"), + // Type: to.Ptr("microsoft.mission/virtualenclaves"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/VirtualEnclave_Update.json +func ExampleVirtualEnclaveClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualEnclaveClient().BeginUpdate(ctx, "rgopenapi", "TestMyEnclave", armvirtualenclaves.VirtualEnclavePatchModel{ + Tags: map[string]*string{ + "Tag1": to.Ptr("Value1"), + }, + Properties: &armvirtualenclaves.VirtualEnclavePatchProperties{ + EnclaveVirtualNetwork: &armvirtualenclaves.EnclaveVirtualNetworkModel{ + NetworkSize: to.Ptr("small"), + CustomCidrRange: to.Ptr("10.0.0.0/24"), + SubnetConfigurations: []*armvirtualenclaves.SubnetConfiguration{ + { + SubnetName: to.Ptr("test"), + NetworkPrefixSize: to.Ptr[int32](26), + }, + }, + AllowSubnetCommunication: to.Ptr(true), + }, + EnclaveDefaultSettings: &armvirtualenclaves.EnclaveDefaultSettingsPatchModel{ + DiagnosticDestination: to.Ptr(armvirtualenclaves.DiagnosticDestinationBoth), + }, + MaintenanceModeConfiguration: &armvirtualenclaves.MaintenanceModeConfigurationPatchModel{ + Mode: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelModeOff), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + }, + }, + Justification: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelJustificationOff), + }, + BastionEnabled: to.Ptr(true), + EnclaveRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + { + RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + }, + { + ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + }, + }, + }, + { + RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + }, + }, + }, + }, + WorkloadRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + { + RoleDefinitionID: to.Ptr("d73bb868-a0df-4d4d-bd69-98a00b01fccb"), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + }, + }, + }, + { + RoleDefinitionID: to.Ptr("fb879df8-f326-4884-b1cf-06f3ad86be52"), + Principals: []*armvirtualenclaves.Principal{ + { + ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + }, + }, + }, + }, + }, + }, 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 = armvirtualenclaves.VirtualEnclaveClientUpdateResponse{ + // EnclaveResource: &armvirtualenclaves.EnclaveResource{ + // Identity: &armvirtualenclaves.ManagedServiceIdentity{ + // Type: to.Ptr(armvirtualenclaves.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + // PrincipalID: to.Ptr("1a2e532b-9900-414c-8600-cfc6126628d7"), + // TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"), + // UserAssignedIdentities: map[string]*armvirtualenclaves.UserAssignedIdentity{ + // "/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armvirtualenclaves.UserAssignedIdentity{ + // PrincipalID: to.Ptr("f4aa4954-a564-4933-a7e1-502019d807c2"), + // ClientID: to.Ptr("b82bf757-ee7f-4632-9df1-5e52a720fdd2"), + // }, + // }, + // }, + // Properties: &armvirtualenclaves.VirtualEnclaveProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // EnclaveVirtualNetwork: &armvirtualenclaves.EnclaveVirtualNetworkModel{ + // NetworkSize: to.Ptr("small"), + // CustomCidrRange: to.Ptr("10.0.0.0/24"), + // SubnetConfigurations: []*armvirtualenclaves.SubnetConfiguration{ + // { + // SubnetName: to.Ptr("test"), + // NetworkPrefixSize: to.Ptr[int32](26), + // }, + // }, + // AllowSubnetCommunication: to.Ptr(true), + // }, + // CommunityResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/communities/TestMyCommunity"), + // EnclaveDefaultSettings: &armvirtualenclaves.EnclaveDefaultSettingsModel{ + // KeyVaultResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.KeyVault/vaults/TestMyKeyVault1"), + // StorageAccountResourceID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Storage/storageAccounts/TestMyStorageAccount"), + // LogAnalyticsResourceIDCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.OperationalInsights/workspaces/TestMyLogA1"), + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.OperationalInsights/workspaces/TestMyLogA2"), + // }, + // DiagnosticDestination: to.Ptr(armvirtualenclaves.DiagnosticDestinationBoth), + // }, + // ResourceCollection: []*string{ + // to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg"), + // }, + // MaintenanceModeConfiguration: &armvirtualenclaves.MaintenanceModeConfigurationModel{ + // Mode: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelModeOff), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // Justification: to.Ptr(armvirtualenclaves.MaintenanceModeConfigurationModelJustificationOff), + // }, + // BastionEnabled: to.Ptr(true), + // EnclaveRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("b24988ac-6180-42a0-ab88-20f7382dd24c"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c0"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("18d7d88d-d35e-4fb5-a5c3-7773c20a72d9"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("355a6bb0-abc0-4cba-000d-12a345b678c9"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeUser), + // }, + // }, + // }, + // }, + // WorkloadRoleAssignments: []*armvirtualenclaves.RoleAssignmentItem{ + // { + // RoleDefinitionID: to.Ptr("d73bb868-a0df-4d4d-bd69-98a00b01fccb"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // }, + // }, + // { + // RoleDefinitionID: to.Ptr("fb879df8-f326-4884-b1cf-06f3ad86be52"), + // Principals: []*armvirtualenclaves.Principal{ + // { + // ID: to.Ptr("01234567-89ab-ef01-2345-0123456789ab"), + // Type: to.Ptr(armvirtualenclaves.PrincipalTypeGroup), + // }, + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "Tag1": to.Ptr("Value1"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave"), + // Name: to.Ptr("TestMyEnclave"), + // Type: to.Ptr("microsoft.mission/virtualenclaves"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/workload_client.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/workload_client.go new file mode 100644 index 000000000000..2829eda671f5 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/workload_client.go @@ -0,0 +1,485 @@ +// 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 armvirtualenclaves + +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" +) + +// WorkloadClient - Workload Interface +// Don't use this type directly, use NewWorkloadClient() instead. +type WorkloadClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkloadClient creates a new instance of WorkloadClient 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 NewWorkloadClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkloadClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkloadClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a WorkloadResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - workloadName - The name of the workloadResource Resource +// - resource - Resource create parameters. +// - options - WorkloadClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkloadClient.BeginCreateOrUpdate +// method. +func (client *WorkloadClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, resource WorkloadResource, options *WorkloadClientBeginCreateOrUpdateOptions) (*runtime.Poller[WorkloadClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, virtualEnclaveName, workloadName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkloadClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WorkloadClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a WorkloadResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *WorkloadClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, resource WorkloadResource, options *WorkloadClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "WorkloadClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, virtualEnclaveName, workloadName, 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 +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkloadClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, resource WorkloadResource, _ *WorkloadClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName}" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + if workloadName == "" { + return nil, errors.New("parameter workloadName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workloadName}", url.PathEscape(workloadName)) + 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-05-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 WorkloadResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - workloadName - The name of the workloadResource Resource +// - options - WorkloadClientBeginDeleteOptions contains the optional parameters for the WorkloadClient.BeginDelete method. +func (client *WorkloadClient) BeginDelete(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, options *WorkloadClientBeginDeleteOptions) (*runtime.Poller[WorkloadClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, virtualEnclaveName, workloadName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkloadClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WorkloadClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a WorkloadResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *WorkloadClient) deleteOperation(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, options *WorkloadClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "WorkloadClient.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, virtualEnclaveName, workloadName, 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 *WorkloadClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, _ *WorkloadClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName}" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + if workloadName == "" { + return nil, errors.New("parameter workloadName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workloadName}", url.PathEscape(workloadName)) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + return req, nil +} + +// Get - Get a WorkloadResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - workloadName - The name of the workloadResource Resource +// - options - WorkloadClientGetOptions contains the optional parameters for the WorkloadClient.Get method. +func (client *WorkloadClient) Get(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, options *WorkloadClientGetOptions) (WorkloadClientGetResponse, error) { + var err error + const operationName = "WorkloadClient.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, virtualEnclaveName, workloadName, options) + if err != nil { + return WorkloadClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkloadClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkloadClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkloadClient) getCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, _ *WorkloadClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName}" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + if workloadName == "" { + return nil, errors.New("parameter workloadName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workloadName}", url.PathEscape(workloadName)) + 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-05-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 *WorkloadClient) getHandleResponse(resp *http.Response) (WorkloadClientGetResponse, error) { + result := WorkloadClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadResource); err != nil { + return WorkloadClientGetResponse{}, err + } + return result, nil +} + +// NewListByEnclaveResourcePager - List WorkloadResource resources by EnclaveResource +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - options - WorkloadClientListByEnclaveResourceOptions contains the optional parameters for the WorkloadClient.NewListByEnclaveResourcePager +// method. +func (client *WorkloadClient) NewListByEnclaveResourcePager(resourceGroupName string, virtualEnclaveName string, options *WorkloadClientListByEnclaveResourceOptions) *runtime.Pager[WorkloadClientListByEnclaveResourceResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkloadClientListByEnclaveResourceResponse]{ + More: func(page WorkloadClientListByEnclaveResourceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkloadClientListByEnclaveResourceResponse) (WorkloadClientListByEnclaveResourceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkloadClient.NewListByEnclaveResourcePager") + 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.listByEnclaveResourceCreateRequest(ctx, resourceGroupName, virtualEnclaveName, options) + }, nil) + if err != nil { + return WorkloadClientListByEnclaveResourceResponse{}, err + } + return client.listByEnclaveResourceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByEnclaveResourceCreateRequest creates the ListByEnclaveResource request. +func (client *WorkloadClient) listByEnclaveResourceCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, _ *WorkloadClientListByEnclaveResourceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + 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-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByEnclaveResourceHandleResponse handles the ListByEnclaveResource response. +func (client *WorkloadClient) listByEnclaveResourceHandleResponse(resp *http.Response) (WorkloadClientListByEnclaveResourceResponse, error) { + result := WorkloadClientListByEnclaveResourceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadResourceListResult); err != nil { + return WorkloadClientListByEnclaveResourceResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List WorkloadResource resources by subscription ID +// +// Generated from API version 2025-05-01-preview +// - virtualEnclaveName - The name of the enclaveResource Resource +// - options - WorkloadClientListBySubscriptionOptions contains the optional parameters for the WorkloadClient.NewListBySubscriptionPager +// method. +func (client *WorkloadClient) NewListBySubscriptionPager(virtualEnclaveName string, options *WorkloadClientListBySubscriptionOptions) *runtime.Pager[WorkloadClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkloadClientListBySubscriptionResponse]{ + More: func(page WorkloadClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkloadClientListBySubscriptionResponse) (WorkloadClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkloadClient.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, virtualEnclaveName, options) + }, nil) + if err != nil { + return WorkloadClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *WorkloadClient) listBySubscriptionCreateRequest(ctx context.Context, virtualEnclaveName string, _ *WorkloadClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + 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-05-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 *WorkloadClient) listBySubscriptionHandleResponse(resp *http.Response) (WorkloadClientListBySubscriptionResponse, error) { + result := WorkloadClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkloadResourceListResult); err != nil { + return WorkloadClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a WorkloadResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - virtualEnclaveName - The name of the enclaveResource Resource +// - workloadName - The name of the workloadResource Resource +// - properties - The resource properties to be updated. +// - options - WorkloadClientBeginUpdateOptions contains the optional parameters for the WorkloadClient.BeginUpdate method. +func (client *WorkloadClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, properties WorkloadPatchModel, options *WorkloadClientBeginUpdateOptions) (*runtime.Poller[WorkloadClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, virtualEnclaveName, workloadName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkloadClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WorkloadClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a WorkloadResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-01-preview +func (client *WorkloadClient) update(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, properties WorkloadPatchModel, options *WorkloadClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "WorkloadClient.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, virtualEnclaveName, workloadName, 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 *WorkloadClient) updateCreateRequest(ctx context.Context, resourceGroupName string, virtualEnclaveName string, workloadName string, properties WorkloadPatchModel, _ *WorkloadClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Mission/virtualEnclaves/{virtualEnclaveName}/workloads/{workloadName}" + 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 virtualEnclaveName == "" { + return nil, errors.New("parameter virtualEnclaveName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualEnclaveName}", url.PathEscape(virtualEnclaveName)) + if workloadName == "" { + return nil, errors.New("parameter workloadName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{workloadName}", url.PathEscape(workloadName)) + 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-05-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/virtualenclaves/armvirtualenclaves/workload_client_example_test.go b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/workload_client_example_test.go new file mode 100644 index 000000000000..874c40431f49 --- /dev/null +++ b/sdk/resourcemanager/virtualenclaves/armvirtualenclaves/workload_client_example_test.go @@ -0,0 +1,310 @@ +// 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 armvirtualenclaves_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/virtualenclaves/armvirtualenclaves" + "log" +) + +// Generated from example definition: 2025-05-01-preview/Workload_CreateOrUpdate.json +func ExampleWorkloadClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewWorkloadClient().BeginCreateOrUpdate(ctx, "rgopenapi", "TestMyEnclave", "TestMyWorkload", armvirtualenclaves.WorkloadResource{ + Properties: &armvirtualenclaves.WorkloadProperties{ + ResourceGroupCollection: []*string{}, + }, + Tags: map[string]*string{ + "TestKey": to.Ptr("TestValue"), + }, + Location: to.Ptr("westcentralus"), + }, 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 = armvirtualenclaves.WorkloadClientCreateOrUpdateResponse{ + // WorkloadResource: &armvirtualenclaves.WorkloadResource{ + // Properties: &armvirtualenclaves.WorkloadProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // ResourceGroupCollection: []*string{ + // }, + // }, + // Tags: map[string]*string{ + // "TestKey": to.Ptr("TestValue"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave/workloads/kxzylwqnmxtivpmupnlho"), + // Name: to.Ptr("kxzylwqnmxtivpmupnlho"), + // Type: to.Ptr("microsoft.mission/virtualenclaves/workloads"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/Workload_Delete.json +func ExampleWorkloadClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewWorkloadClient().BeginDelete(ctx, "rgopenapi", "TestMyEnclave", "TestMyWorkload", 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-05-01-preview/Workload_Get.json +func ExampleWorkloadClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkloadClient().Get(ctx, "rgopenapi", "TestMyEnclave", "TestMyWorkload", 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 = armvirtualenclaves.WorkloadClientGetResponse{ + // WorkloadResource: &armvirtualenclaves.WorkloadResource{ + // Properties: &armvirtualenclaves.WorkloadProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // ResourceGroupCollection: []*string{ + // to.Ptr("g"), + // }, + // ManagedOnBehalfOfConfiguration: &armvirtualenclaves.ManagedOnBehalfOfConfiguration{ + // MoboBrokerResources: []*armvirtualenclaves.MoboBrokerResource{ + // { + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/Microsoft.Resources/moboBrokers/bnthrkwfkfeorrzvtdxbfz"), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "TestKey": to.Ptr("TestValue"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave/workloads/kxzylwqnmxtivpmupnlho"), + // Name: to.Ptr("kxzylwqnmxtivpmupnlho"), + // Type: to.Ptr("microsoft.mission/virtualenclaves/workloads"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2025-05-01-preview/Workload_ListByEnclaveResource.json +func ExampleWorkloadClient_NewListByEnclaveResourcePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWorkloadClient().NewListByEnclaveResourcePager("rgopenapi", "TestMyEnclave", 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 = armvirtualenclaves.WorkloadClientListByEnclaveResourceResponse{ + // WorkloadResourceListResult: armvirtualenclaves.WorkloadResourceListResult{ + // Value: []*armvirtualenclaves.WorkloadResource{ + // { + // Properties: &armvirtualenclaves.WorkloadProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // ResourceGroupCollection: []*string{ + // to.Ptr("g"), + // }, + // }, + // Tags: map[string]*string{ + // "TestKey": to.Ptr("TestValue"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave/workloads/kxzylwqnmxtivpmupnlho"), + // Name: to.Ptr("kxzylwqnmxtivpmupnlho"), + // Type: to.Ptr("microsoft.mission/virtualenclaves/workloads"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/Workload_ListBySubscription.json +func ExampleWorkloadClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewWorkloadClient().NewListBySubscriptionPager("TestMyEnclave", 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 = armvirtualenclaves.WorkloadClientListBySubscriptionResponse{ + // WorkloadResourceListResult: armvirtualenclaves.WorkloadResourceListResult{ + // Value: []*armvirtualenclaves.WorkloadResource{ + // { + // Properties: &armvirtualenclaves.WorkloadProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // ResourceGroupCollection: []*string{ + // to.Ptr("g"), + // }, + // }, + // Tags: map[string]*string{ + // "TestKey": to.Ptr("TestValue"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave/workloads/kxzylwqnmxtivpmupnlho"), + // Name: to.Ptr("kxzylwqnmxtivpmupnlho"), + // Type: to.Ptr("microsoft.mission/virtualenclaves/workloads"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2025-05-01-preview/Workload_Update.json +func ExampleWorkloadClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualenclaves.NewClientFactory("CA1CB369-DD26-4DB2-9D43-9AFEF0F22093", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewWorkloadClient().BeginUpdate(ctx, "rgopenapi", "TestMyEnclave", "TestMyWorkload", armvirtualenclaves.WorkloadPatchModel{ + Tags: map[string]*string{ + "key9465": to.Ptr("cylmdprdhhwpcdxpynwostvzytkryj"), + }, + Properties: &armvirtualenclaves.WorkloadPatchProperties{ + ResourceGroupCollection: []*string{ + to.Ptr("g"), + }, + }, + }, 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 = armvirtualenclaves.WorkloadClientUpdateResponse{ + // WorkloadResource: &armvirtualenclaves.WorkloadResource{ + // Properties: &armvirtualenclaves.WorkloadProperties{ + // ProvisioningState: to.Ptr(armvirtualenclaves.ProvisioningStateSucceeded), + // ResourceGroupCollection: []*string{ + // to.Ptr("g"), + // }, + // }, + // Tags: map[string]*string{ + // "TestKey": to.Ptr("TestValue"), + // }, + // Location: to.Ptr("westcentralus"), + // ID: to.Ptr("/subscriptions/c64f6eca-bdc5-4bc2-88d6-f8f1dc23f86c/resourceGroups/TestMyRg/providers/microsoft.mission/virtualenclaves/TestMyEnclave/workloads/kxzylwqnmxtivpmupnlho"), + // Name: to.Ptr("kxzylwqnmxtivpmupnlho"), + // Type: to.Ptr("microsoft.mission/virtualenclaves/workloads"), + // SystemData: &armvirtualenclaves.SystemData{ + // CreatedBy: to.Ptr("myAlias"), + // CreatedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // LastModifiedBy: to.Ptr("myAlias"), + // LastModifiedByType: to.Ptr(armvirtualenclaves.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-17T20:43:17.760Z"); return t}()), + // }, + // }, + // } +}