From 123f61ca26daae79521241c2ab10063e063ab7b8 Mon Sep 17 00:00:00 2001 From: jliusan Date: Wed, 7 May 2025 13:57:09 +0800 Subject: [PATCH 1/2] [Release] sdk/resourcemanager/mongodbatlas/armmongodbatlas/0.1.0 generation from spec commit: c0d9186502bf5acb015cda9c0ef6fb22a531d896 --- .../mongodbatlas/armmongodbatlas/CHANGELOG.md | 8 + .../mongodbatlas/armmongodbatlas/LICENSE.txt | 21 + .../mongodbatlas/armmongodbatlas/README.md | 90 +++ .../mongodbatlas/armmongodbatlas/ci.yml | 27 + .../armmongodbatlas/client_factory.go | 48 ++ .../mongodbatlas/armmongodbatlas/constants.go | 141 +++++ .../armmongodbatlas/fake/internal.go | 65 +++ .../armmongodbatlas/fake/operations_server.go | 117 ++++ .../fake/organizations_server.go | 374 ++++++++++++ .../armmongodbatlas/fake/server_factory.go | 81 +++ .../mongodbatlas/armmongodbatlas/go.mod | 23 + .../mongodbatlas/armmongodbatlas/go.sum | 33 ++ .../mongodbatlas/armmongodbatlas/models.go | 219 +++++++ .../armmongodbatlas/models_serde.go | 551 +++++++++++++++++ .../armmongodbatlas/operations_client.go | 84 +++ .../operations_client_example_test.go | 85 +++ .../mongodbatlas/armmongodbatlas/options.go | 46 ++ .../armmongodbatlas/organizations_client.go | 457 +++++++++++++++ .../organizations_client_example_test.go | 552 ++++++++++++++++++ .../mongodbatlas/armmongodbatlas/responses.go | 46 ++ .../armmongodbatlas/time_rfc3339.go | 109 ++++ .../armmongodbatlas/tsp-location.yaml | 4 + 22 files changed, 3181 insertions(+) create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/CHANGELOG.md create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/LICENSE.txt create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/README.md create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/ci.yml create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/client_factory.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/constants.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/fake/internal.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/fake/operations_server.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/fake/organizations_server.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/fake/server_factory.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/go.mod create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/go.sum create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/models.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/models_serde.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/operations_client.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/operations_client_example_test.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/options.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/organizations_client.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/organizations_client_example_test.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/responses.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/time_rfc3339.go create mode 100644 sdk/resourcemanager/mongodbatlas/armmongodbatlas/tsp-location.yaml diff --git a/sdk/resourcemanager/mongodbatlas/armmongodbatlas/CHANGELOG.md b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/CHANGELOG.md new file mode 100644 index 000000000000..97540caa8561 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-05-07) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongodbatlas/armmongodbatlas` 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/mongodbatlas/armmongodbatlas/LICENSE.txt b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/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/mongodbatlas/armmongodbatlas/README.md b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/README.md new file mode 100644 index 000000000000..4a56a489ff96 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/README.md @@ -0,0 +1,90 @@ +# Azure Mongodbatlas Module for Go + +The `armmongodbatlas` module provides operations for working with Azure Mongodbatlas. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/mongodbatlas/armmongodbatlas) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (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 Mongodbatlas module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongodbatlas/armmongodbatlas +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Mongodbatlas. 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 Mongodbatlas 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 := armmongodbatlas.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 := armmongodbatlas.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.NewOrganizationsClient() +``` + +## 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 `Mongodbatlas` 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/mongodbatlas/armmongodbatlas/ci.yml b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/ci.yml new file mode 100644 index 000000000000..cf804d21f785 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/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/mongodbatlas/armmongodbatlas/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/mongodbatlas/armmongodbatlas/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/mongodbatlas/armmongodbatlas' diff --git a/sdk/resourcemanager/mongodbatlas/armmongodbatlas/client_factory.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/client_factory.go new file mode 100644 index 000000000000..676e132ac549 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/client_factory.go @@ -0,0 +1,48 @@ +// 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 armmongodbatlas + +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 +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} + +// NewOrganizationsClient creates a new instance of OrganizationsClient. +func (c *ClientFactory) NewOrganizationsClient() *OrganizationsClient { + return &OrganizationsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/mongodbatlas/armmongodbatlas/constants.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/constants.go new file mode 100644 index 000000000000..3a60c5e8301a --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/constants.go @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armmongodbatlas + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongodbatlas/armmongodbatlas" + moduleVersion = "v0.1.0" +) + +// 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, + } +} + +// 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, + } +} + +// 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, + } +} + +// MarketplaceSubscriptionStatus - Marketplace subscription status of a resource. +type MarketplaceSubscriptionStatus string + +const ( + // MarketplaceSubscriptionStatusPendingFulfillmentStart - Purchased but not yet activated + MarketplaceSubscriptionStatusPendingFulfillmentStart MarketplaceSubscriptionStatus = "PendingFulfillmentStart" + // MarketplaceSubscriptionStatusSubscribed - Marketplace subscription is activated + MarketplaceSubscriptionStatusSubscribed MarketplaceSubscriptionStatus = "Subscribed" + // MarketplaceSubscriptionStatusSuspended - This state indicates that a customer's payment for the Marketplace service was + // not received + MarketplaceSubscriptionStatusSuspended MarketplaceSubscriptionStatus = "Suspended" + // MarketplaceSubscriptionStatusUnsubscribed - Customer has cancelled the subscription + MarketplaceSubscriptionStatusUnsubscribed MarketplaceSubscriptionStatus = "Unsubscribed" +) + +// PossibleMarketplaceSubscriptionStatusValues returns the possible values for the MarketplaceSubscriptionStatus const type. +func PossibleMarketplaceSubscriptionStatusValues() []MarketplaceSubscriptionStatus { + return []MarketplaceSubscriptionStatus{ + MarketplaceSubscriptionStatusPendingFulfillmentStart, + MarketplaceSubscriptionStatusSubscribed, + MarketplaceSubscriptionStatusSuspended, + MarketplaceSubscriptionStatusUnsubscribed, + } +} + +// 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, + } +} + +// ResourceProvisioningState - The provisioning state of a resource type. +type ResourceProvisioningState string + +const ( + // ResourceProvisioningStateCanceled - Resource creation was canceled. + ResourceProvisioningStateCanceled ResourceProvisioningState = "Canceled" + // ResourceProvisioningStateFailed - Resource creation failed. + ResourceProvisioningStateFailed ResourceProvisioningState = "Failed" + // ResourceProvisioningStateSucceeded - Resource has been created. + ResourceProvisioningStateSucceeded ResourceProvisioningState = "Succeeded" +) + +// PossibleResourceProvisioningStateValues returns the possible values for the ResourceProvisioningState const type. +func PossibleResourceProvisioningStateValues() []ResourceProvisioningState { + return []ResourceProvisioningState{ + ResourceProvisioningStateCanceled, + ResourceProvisioningStateFailed, + ResourceProvisioningStateSucceeded, + } +} diff --git a/sdk/resourcemanager/mongodbatlas/armmongodbatlas/fake/internal.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/fake/internal.go new file mode 100644 index 000000000000..7425b6a669e2 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/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/mongodbatlas/armmongodbatlas/fake/operations_server.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/fake/operations_server.go new file mode 100644 index 000000000000..498f2c96d6a3 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/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/mongodbatlas/armmongodbatlas" + "net/http" +) + +// OperationsServer is a fake server for instances of the armmongodbatlas.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armmongodbatlas.OperationsClientListOptions) (resp azfake.PagerResponder[armmongodbatlas.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armmongodbatlas.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[armmongodbatlas.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armmongodbatlas.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armmongodbatlas.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 *armmongodbatlas.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/mongodbatlas/armmongodbatlas/fake/organizations_server.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/fake/organizations_server.go new file mode 100644 index 000000000000..39daab0f78a1 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/fake/organizations_server.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 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/mongodbatlas/armmongodbatlas" + "net/http" + "net/url" + "regexp" +) + +// OrganizationsServer is a fake server for instances of the armmongodbatlas.OrganizationsClient type. +type OrganizationsServer struct { + // BeginCreateOrUpdate is the fake for method OrganizationsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, organizationName string, resource armmongodbatlas.OrganizationResource, options *armmongodbatlas.OrganizationsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armmongodbatlas.OrganizationsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method OrganizationsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, organizationName string, options *armmongodbatlas.OrganizationsClientBeginDeleteOptions) (resp azfake.PollerResponder[armmongodbatlas.OrganizationsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method OrganizationsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, organizationName string, options *armmongodbatlas.OrganizationsClientGetOptions) (resp azfake.Responder[armmongodbatlas.OrganizationsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method OrganizationsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armmongodbatlas.OrganizationsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armmongodbatlas.OrganizationsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method OrganizationsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armmongodbatlas.OrganizationsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armmongodbatlas.OrganizationsClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method OrganizationsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, organizationName string, properties armmongodbatlas.OrganizationResource, options *armmongodbatlas.OrganizationsClientBeginUpdateOptions) (resp azfake.PollerResponder[armmongodbatlas.OrganizationsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewOrganizationsServerTransport creates a new instance of OrganizationsServerTransport with the provided implementation. +// The returned OrganizationsServerTransport instance is connected to an instance of armmongodbatlas.OrganizationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOrganizationsServerTransport(srv *OrganizationsServer) *OrganizationsServerTransport { + return &OrganizationsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armmongodbatlas.OrganizationsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armmongodbatlas.OrganizationsClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armmongodbatlas.OrganizationsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armmongodbatlas.OrganizationsClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armmongodbatlas.OrganizationsClientUpdateResponse]](), + } +} + +// OrganizationsServerTransport connects instances of armmongodbatlas.OrganizationsClient to instances of OrganizationsServer. +// Don't use this type directly, use NewOrganizationsServerTransport instead. +type OrganizationsServerTransport struct { + srv *OrganizationsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armmongodbatlas.OrganizationsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armmongodbatlas.OrganizationsClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armmongodbatlas.OrganizationsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armmongodbatlas.OrganizationsClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armmongodbatlas.OrganizationsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for OrganizationsServerTransport. +func (o *OrganizationsServerTransport) 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 *OrganizationsServerTransport) 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 organizationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = organizationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OrganizationsClient.BeginCreateOrUpdate": + res.resp, res.err = o.dispatchBeginCreateOrUpdate(req) + case "OrganizationsClient.BeginDelete": + res.resp, res.err = o.dispatchBeginDelete(req) + case "OrganizationsClient.Get": + res.resp, res.err = o.dispatchGet(req) + case "OrganizationsClient.NewListByResourceGroupPager": + res.resp, res.err = o.dispatchNewListByResourceGroupPager(req) + case "OrganizationsClient.NewListBySubscriptionPager": + res.resp, res.err = o.dispatchNewListBySubscriptionPager(req) + case "OrganizationsClient.BeginUpdate": + res.resp, res.err = o.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 (o *OrganizationsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if o.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := o.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/MongoDB\.Atlas/organizations/(?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[armmongodbatlas.OrganizationResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, organizationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + o.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) { + o.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) { + o.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (o *OrganizationsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if o.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := o.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/MongoDB\.Atlas/organizations/(?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 + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.BeginDelete(req.Context(), resourceGroupNameParam, organizationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + o.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) { + o.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) { + o.beginDelete.remove(req) + } + + return resp, nil +} + +func (o *OrganizationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.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/MongoDB\.Atlas/organizations/(?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 + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), resourceGroupNameParam, organizationNameParam, 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).OrganizationResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (o *OrganizationsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := o.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/MongoDB\.Atlas/organizations` + 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 := o.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + o.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armmongodbatlas.OrganizationsClientListByResourceGroupResponse, 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) { + o.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + o.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (o *OrganizationsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := o.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/MongoDB\.Atlas/organizations` + 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 := o.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + o.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armmongodbatlas.OrganizationsClientListBySubscriptionResponse, 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) { + o.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + o.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (o *OrganizationsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if o.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := o.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/MongoDB\.Atlas/organizations/(?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[armmongodbatlas.OrganizationResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + organizationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("organizationName")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.BeginUpdate(req.Context(), resourceGroupNameParam, organizationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + o.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) { + o.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) { + o.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to OrganizationsServerTransport +var organizationsServerTransportInterceptor 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/mongodbatlas/armmongodbatlas/fake/server_factory.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/fake/server_factory.go new file mode 100644 index 000000000000..22212933cb86 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/fake/server_factory.go @@ -0,0 +1,81 @@ +// 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 armmongodbatlas.ClientFactory type. +type ServerFactory struct { + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // OrganizationsServer contains the fakes for client OrganizationsClient + OrganizationsServer OrganizationsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armmongodbatlas.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 armmongodbatlas.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trOperationsServer *OperationsServerTransport + trOrganizationsServer *OrganizationsServerTransport +} + +// 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 "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "OrganizationsClient": + initServer(s, &s.trOrganizationsServer, func() *OrganizationsServerTransport { + return NewOrganizationsServerTransport(&s.srv.OrganizationsServer) + }) + resp, err = s.trOrganizationsServer.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/mongodbatlas/armmongodbatlas/go.mod b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/go.mod new file mode 100644 index 000000000000..cb483479f1d2 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/go.mod @@ -0,0 +1,23 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongodbatlas/armmongodbatlas + +go 1.23.0 + +toolchain go1.23.9 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // 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.36.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/sys v0.31.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/mongodbatlas/armmongodbatlas/go.sum b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/go.sum new file mode 100644 index 000000000000..1f92486fbbcf --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/go.sum @@ -0,0 +1,33 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +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.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +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/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.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +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/mongodbatlas/armmongodbatlas/models.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/models.go new file mode 100644 index 000000000000..eb33fc9f6c7c --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/models.go @@ -0,0 +1,219 @@ +// 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 armmongodbatlas + +import "time" + +// 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 +} + +// MarketplaceDetails - Marketplace details for an organization +type MarketplaceDetails struct { + // REQUIRED; Offer details for the marketplace that is selected by the user + OfferDetails *OfferDetails + + // REQUIRED; Azure subscription id for the the marketplace offer is purchased from + SubscriptionID *string + + // READ-ONLY; Marketplace subscription status + SubscriptionStatus *MarketplaceSubscriptionStatus +} + +// OfferDetails - Offer details for the marketplace that is selected by the user +type OfferDetails struct { + // REQUIRED; Offer Id for the marketplace offer + OfferID *string + + // REQUIRED; Plan Id for the marketplace offer + PlanID *string + + // REQUIRED; Publisher Id for the marketplace offer + PublisherID *string + + // Plan Name for the marketplace offer + PlanName *string + + // Plan Display Name for the marketplace offer + TermID *string + + // Plan Display Name for the marketplace offer + TermUnit *string +} + +// 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 +} + +// OrganizationProperties - Properties specific to Organization +type OrganizationProperties struct { + // REQUIRED; Marketplace details of the resource. + Marketplace *MarketplaceDetails + + // REQUIRED; Details of the user. + User *UserDetails + + // MongoDB properties + PartnerProperties *PartnerProperties + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ResourceProvisioningState +} + +// OrganizationResource - The resource model definition for an Azure Organization +type OrganizationResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // READ-ONLY; Name of the Organization resource + Name *string + + // The managed service identities assigned to this resource. + Identity *ManagedServiceIdentity + + // The resource-specific properties for this resource. + Properties *OrganizationProperties + + // 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; 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 +} + +// OrganizationResourceListResult - The response of a OrganizationResource list operation. +type OrganizationResourceListResult struct { + // REQUIRED; The OrganizationResource items on this page + Value []*OrganizationResource + + // The link to the next page of items + NextLink *string +} + +// PartnerProperties - MongoDB specific Properties +type PartnerProperties struct { + // REQUIRED; Organization name in MongoDB system + OrganizationName *string + + // Organization Id in MongoDB system + OrganizationID *string + + // Redirect URL for the MongoDB + RedirectURL *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 +} + +// 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 +} + +// UserDetails - User details for an organization +type UserDetails struct { + // REQUIRED; Email address of the user + EmailAddress *string + + // REQUIRED; First name of the user + FirstName *string + + // REQUIRED; Last name of the user + LastName *string + + // Company Name + CompanyName *string + + // User's phone number + PhoneNumber *string + + // User's principal name + Upn *string +} diff --git a/sdk/resourcemanager/mongodbatlas/armmongodbatlas/models_serde.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/models_serde.go new file mode 100644 index 000000000000..167ab71d3e84 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/models_serde.go @@ -0,0 +1,551 @@ +// 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 armmongodbatlas + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// 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 MarketplaceDetails. +func (m MarketplaceDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "offerDetails", m.OfferDetails) + populate(objectMap, "subscriptionId", m.SubscriptionID) + populate(objectMap, "subscriptionStatus", m.SubscriptionStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MarketplaceDetails. +func (m *MarketplaceDetails) 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 "offerDetails": + err = unpopulate(val, "OfferDetails", &m.OfferDetails) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &m.SubscriptionID) + delete(rawMsg, key) + case "subscriptionStatus": + err = unpopulate(val, "SubscriptionStatus", &m.SubscriptionStatus) + 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 OfferDetails. +func (o OfferDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "offerId", o.OfferID) + populate(objectMap, "planId", o.PlanID) + populate(objectMap, "planName", o.PlanName) + populate(objectMap, "publisherId", o.PublisherID) + populate(objectMap, "termId", o.TermID) + populate(objectMap, "termUnit", o.TermUnit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OfferDetails. +func (o *OfferDetails) 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 "offerId": + err = unpopulate(val, "OfferID", &o.OfferID) + delete(rawMsg, key) + case "planId": + err = unpopulate(val, "PlanID", &o.PlanID) + delete(rawMsg, key) + case "planName": + err = unpopulate(val, "PlanName", &o.PlanName) + delete(rawMsg, key) + case "publisherId": + err = unpopulate(val, "PublisherID", &o.PublisherID) + delete(rawMsg, key) + case "termId": + err = unpopulate(val, "TermID", &o.TermID) + delete(rawMsg, key) + case "termUnit": + err = unpopulate(val, "TermUnit", &o.TermUnit) + 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 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 OrganizationProperties. +func (o OrganizationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "marketplace", o.Marketplace) + populate(objectMap, "partnerProperties", o.PartnerProperties) + populate(objectMap, "provisioningState", o.ProvisioningState) + populate(objectMap, "user", o.User) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationProperties. +func (o *OrganizationProperties) 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 "marketplace": + err = unpopulate(val, "Marketplace", &o.Marketplace) + delete(rawMsg, key) + case "partnerProperties": + err = unpopulate(val, "PartnerProperties", &o.PartnerProperties) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &o.ProvisioningState) + delete(rawMsg, key) + case "user": + err = unpopulate(val, "User", &o.User) + 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 OrganizationResource. +func (o OrganizationResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "identity", o.Identity) + populate(objectMap, "location", o.Location) + populate(objectMap, "name", o.Name) + populate(objectMap, "properties", o.Properties) + populate(objectMap, "systemData", o.SystemData) + populate(objectMap, "tags", o.Tags) + populate(objectMap, "type", o.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrganizationResource. +func (o *OrganizationResource) 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 "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &o.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &o.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &o.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &o.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &o.Type) + 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 OrganizationResourceListResult. +func (o OrganizationResourceListResult) 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 OrganizationResourceListResult. +func (o *OrganizationResourceListResult) 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 PartnerProperties. +func (p PartnerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "organizationId", p.OrganizationID) + populate(objectMap, "organizationName", p.OrganizationName) + populate(objectMap, "redirectUrl", p.RedirectURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PartnerProperties. +func (p *PartnerProperties) 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 "organizationId": + err = unpopulate(val, "OrganizationID", &p.OrganizationID) + delete(rawMsg, key) + case "organizationName": + err = unpopulate(val, "OrganizationName", &p.OrganizationName) + delete(rawMsg, key) + case "redirectUrl": + err = unpopulate(val, "RedirectURL", &p.RedirectURL) + 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 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 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 UserDetails. +func (u UserDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "companyName", u.CompanyName) + populate(objectMap, "emailAddress", u.EmailAddress) + populate(objectMap, "firstName", u.FirstName) + populate(objectMap, "lastName", u.LastName) + populate(objectMap, "phoneNumber", u.PhoneNumber) + populate(objectMap, "upn", u.Upn) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserDetails. +func (u *UserDetails) 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 "companyName": + err = unpopulate(val, "CompanyName", &u.CompanyName) + delete(rawMsg, key) + case "emailAddress": + err = unpopulate(val, "EmailAddress", &u.EmailAddress) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, "FirstName", &u.FirstName) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, "LastName", &u.LastName) + delete(rawMsg, key) + case "phoneNumber": + err = unpopulate(val, "PhoneNumber", &u.PhoneNumber) + delete(rawMsg, key) + case "upn": + err = unpopulate(val, "Upn", &u.Upn) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func 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/mongodbatlas/armmongodbatlas/operations_client.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/operations_client.go new file mode 100644 index 000000000000..6bd99429c42b --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/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 armmongodbatlas + +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 - 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 2024-11-18-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/MongoDB.Atlas/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", "2024-11-18-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/mongodbatlas/armmongodbatlas/operations_client_example_test.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/operations_client_example_test.go new file mode 100644 index 000000000000..da639d0dbe16 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/operations_client_example_test.go @@ -0,0 +1,85 @@ +// 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 armmongodbatlas_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongodbatlas/armmongodbatlas" + "log" +) + +// Generated from example definition: 2024-11-18-preview/Operations_List_MaximumSet_Gen.json +func ExampleOperationsClient_NewListPager_operationsListMaximumSet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongodbatlas.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 = armmongodbatlas.OperationsClientListResponse{ + // OperationListResult: armmongodbatlas.OperationListResult{ + // Value: []*armmongodbatlas.Operation{ + // { + // Name: to.Ptr("glurvmlhuxhlxhmjoiycpicdrjmsd"), + // IsDataAction: to.Ptr(true), + // Display: &armmongodbatlas.OperationDisplay{ + // Provider: to.Ptr("ybkvitxcbahxljn"), + // Resource: to.Ptr("wsdbqubnkmfbclp"), + // Operation: to.Ptr("vsix"), + // Description: to.Ptr("ichocwjfmgzbiliknwwnasvdsnowu"), + // }, + // Origin: to.Ptr(armmongodbatlas.OriginUser), + // ActionType: to.Ptr(armmongodbatlas.ActionTypeInternal), + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2024-11-18-preview/Operations_List_MinimumSet_Gen.json +func ExampleOperationsClient_NewListPager_operationsListMinimumSet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongodbatlas.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 = armmongodbatlas.OperationsClientListResponse{ + // OperationListResult: armmongodbatlas.OperationListResult{ + // }, + // } + } +} diff --git a/sdk/resourcemanager/mongodbatlas/armmongodbatlas/options.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/options.go new file mode 100644 index 000000000000..e2e9e5ecf192 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/options.go @@ -0,0 +1,46 @@ +// 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 armmongodbatlas + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// OrganizationsClientBeginCreateOrUpdateOptions contains the optional parameters for the OrganizationsClient.BeginCreateOrUpdate +// method. +type OrganizationsClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// OrganizationsClientBeginDeleteOptions contains the optional parameters for the OrganizationsClient.BeginDelete method. +type OrganizationsClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// OrganizationsClientBeginUpdateOptions contains the optional parameters for the OrganizationsClient.BeginUpdate method. +type OrganizationsClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// OrganizationsClientGetOptions contains the optional parameters for the OrganizationsClient.Get method. +type OrganizationsClientGetOptions struct { + // placeholder for future optional parameters +} + +// OrganizationsClientListByResourceGroupOptions contains the optional parameters for the OrganizationsClient.NewListByResourceGroupPager +// method. +type OrganizationsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// OrganizationsClientListBySubscriptionOptions contains the optional parameters for the OrganizationsClient.NewListBySubscriptionPager +// method. +type OrganizationsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/mongodbatlas/armmongodbatlas/organizations_client.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/organizations_client.go new file mode 100644 index 000000000000..36fd7387d621 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/organizations_client.go @@ -0,0 +1,457 @@ +// 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 armmongodbatlas + +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" +) + +// OrganizationsClient contains the methods for the Organizations group. +// Don't use this type directly, use NewOrganizationsClient() instead. +type OrganizationsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewOrganizationsClient creates a new instance of OrganizationsClient 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 - pass nil to accept the default values. +func NewOrganizationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OrganizationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OrganizationsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Create a OrganizationResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-18-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Name of the Organization resource +// - resource - Resource create parameters. +// - options - OrganizationsClientBeginCreateOrUpdateOptions contains the optional parameters for the OrganizationsClient.BeginCreateOrUpdate +// method. +func (client *OrganizationsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, organizationName string, resource OrganizationResource, options *OrganizationsClientBeginCreateOrUpdateOptions) (*runtime.Poller[OrganizationsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, organizationName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[OrganizationsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[OrganizationsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a OrganizationResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-18-preview +func (client *OrganizationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, organizationName string, resource OrganizationResource, options *OrganizationsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "OrganizationsClient.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, organizationName, 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 *OrganizationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, organizationName string, resource OrganizationResource, _ *OrganizationsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}" + 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 organizationName == "" { + return nil, errors.New("parameter organizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) + 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", "2024-11-18-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 OrganizationResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-18-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Name of the Organization resource +// - options - OrganizationsClientBeginDeleteOptions contains the optional parameters for the OrganizationsClient.BeginDelete +// method. +func (client *OrganizationsClient) BeginDelete(ctx context.Context, resourceGroupName string, organizationName string, options *OrganizationsClientBeginDeleteOptions) (*runtime.Poller[OrganizationsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, organizationName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[OrganizationsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[OrganizationsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a OrganizationResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-18-preview +func (client *OrganizationsClient) deleteOperation(ctx context.Context, resourceGroupName string, organizationName string, options *OrganizationsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "OrganizationsClient.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, organizationName, 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 *OrganizationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, organizationName string, _ *OrganizationsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}" + 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 organizationName == "" { + return nil, errors.New("parameter organizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) + 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", "2024-11-18-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a OrganizationResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-18-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Name of the Organization resource +// - options - OrganizationsClientGetOptions contains the optional parameters for the OrganizationsClient.Get method. +func (client *OrganizationsClient) Get(ctx context.Context, resourceGroupName string, organizationName string, options *OrganizationsClientGetOptions) (OrganizationsClientGetResponse, error) { + var err error + const operationName = "OrganizationsClient.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, organizationName, options) + if err != nil { + return OrganizationsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OrganizationsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OrganizationsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *OrganizationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, organizationName string, _ *OrganizationsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}" + 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 organizationName == "" { + return nil, errors.New("parameter organizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) + 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", "2024-11-18-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *OrganizationsClient) getHandleResponse(resp *http.Response) (OrganizationsClientGetResponse, error) { + result := OrganizationsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OrganizationResource); err != nil { + return OrganizationsClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List OrganizationResource resources by resource group +// +// Generated from API version 2024-11-18-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - OrganizationsClientListByResourceGroupOptions contains the optional parameters for the OrganizationsClient.NewListByResourceGroupPager +// method. +func (client *OrganizationsClient) NewListByResourceGroupPager(resourceGroupName string, options *OrganizationsClientListByResourceGroupOptions) *runtime.Pager[OrganizationsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[OrganizationsClientListByResourceGroupResponse]{ + More: func(page OrganizationsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OrganizationsClientListByResourceGroupResponse) (OrganizationsClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OrganizationsClient.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 OrganizationsClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *OrganizationsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *OrganizationsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations" + 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", "2024-11-18-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *OrganizationsClient) listByResourceGroupHandleResponse(resp *http.Response) (OrganizationsClientListByResourceGroupResponse, error) { + result := OrganizationsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OrganizationResourceListResult); err != nil { + return OrganizationsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List OrganizationResource resources by subscription ID +// +// Generated from API version 2024-11-18-preview +// - options - OrganizationsClientListBySubscriptionOptions contains the optional parameters for the OrganizationsClient.NewListBySubscriptionPager +// method. +func (client *OrganizationsClient) NewListBySubscriptionPager(options *OrganizationsClientListBySubscriptionOptions) *runtime.Pager[OrganizationsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[OrganizationsClientListBySubscriptionResponse]{ + More: func(page OrganizationsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OrganizationsClientListBySubscriptionResponse) (OrganizationsClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OrganizationsClient.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 OrganizationsClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *OrganizationsClient) listBySubscriptionCreateRequest(ctx context.Context, _ *OrganizationsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/MongoDB.Atlas/organizations" + 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", "2024-11-18-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *OrganizationsClient) listBySubscriptionHandleResponse(resp *http.Response) (OrganizationsClientListBySubscriptionResponse, error) { + result := OrganizationsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OrganizationResourceListResult); err != nil { + return OrganizationsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a OrganizationResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-18-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Name of the Organization resource +// - properties - The resource properties to be updated. +// - options - OrganizationsClientBeginUpdateOptions contains the optional parameters for the OrganizationsClient.BeginUpdate +// method. +func (client *OrganizationsClient) BeginUpdate(ctx context.Context, resourceGroupName string, organizationName string, properties OrganizationResource, options *OrganizationsClientBeginUpdateOptions) (*runtime.Poller[OrganizationsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, organizationName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[OrganizationsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[OrganizationsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a OrganizationResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-11-18-preview +func (client *OrganizationsClient) update(ctx context.Context, resourceGroupName string, organizationName string, properties OrganizationResource, options *OrganizationsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "OrganizationsClient.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, organizationName, 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 *OrganizationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, organizationName string, properties OrganizationResource, _ *OrganizationsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/MongoDB.Atlas/organizations/{organizationName}" + 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 organizationName == "" { + return nil, errors.New("parameter organizationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{organizationName}", url.PathEscape(organizationName)) + 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", "2024-11-18-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/mongodbatlas/armmongodbatlas/organizations_client_example_test.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/organizations_client_example_test.go new file mode 100644 index 000000000000..7b067c6687fe --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/organizations_client_example_test.go @@ -0,0 +1,552 @@ +// 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 armmongodbatlas_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/mongodbatlas/armmongodbatlas" + "log" +) + +// Generated from example definition: 2024-11-18-preview/Organizations_CreateOrUpdate_MaximumSet_Gen.json +func ExampleOrganizationsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongodbatlas.NewClientFactory("AD4FE133-6EF1-4ED8-82DB-5C1CBA58597E", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewOrganizationsClient().BeginCreateOrUpdate(ctx, "rgopenapi", "U.1-:7", armmongodbatlas.OrganizationResource{ + Properties: &armmongodbatlas.OrganizationProperties{ + Marketplace: &armmongodbatlas.MarketplaceDetails{ + SubscriptionID: to.Ptr("o"), + SubscriptionStatus: to.Ptr(armmongodbatlas.MarketplaceSubscriptionStatusPendingFulfillmentStart), + OfferDetails: &armmongodbatlas.OfferDetails{ + PublisherID: to.Ptr("rxglearenxsgpwzlsxmiicynks"), + OfferID: to.Ptr("ohnquleylybvjrtnpjupvwlk"), + PlanID: to.Ptr("obhxnhvrtbcnoovgofbs"), + PlanName: to.Ptr("lkwdzpfhvjezjusrqzyftcikxdt"), + TermUnit: to.Ptr("omkxrnburbnruglwqgjlahvjmbfcse"), + TermID: to.Ptr("bqmmltwmtpdcdeszbka"), + }, + }, + User: &armmongodbatlas.UserDetails{ + FirstName: to.Ptr("aslybvdwwddqxwazxvxhjrs"), + LastName: to.Ptr("cnuitqoqpcyvmuqowgnxpwxjcveyr"), + EmailAddress: to.Ptr(".K_@e7N-g1.xjqnbPs"), + Upn: to.Ptr("howdzmfy"), + PhoneNumber: to.Ptr("ilypntsrbmbbbexbasuu"), + CompanyName: to.Ptr("oxdcwwl"), + }, + PartnerProperties: &armmongodbatlas.PartnerProperties{ + OrganizationID: to.Ptr("lyombjlhvwxithkiy"), + RedirectURL: to.Ptr("cbxwtehraetlluocdihfgchvjzockn"), + OrganizationName: to.Ptr("U.1-:7"), + }, + }, + Identity: &armmongodbatlas.ManagedServiceIdentity{ + Type: to.Ptr(armmongodbatlas.ManagedServiceIdentityTypeNone), + UserAssignedIdentities: map[string]*armmongodbatlas.UserAssignedIdentity{}, + }, + Tags: map[string]*string{}, + Location: to.Ptr("wobqn"), + }, 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 = armmongodbatlas.OrganizationsClientCreateOrUpdateResponse{ + // OrganizationResource: &armmongodbatlas.OrganizationResource{ + // Properties: &armmongodbatlas.OrganizationProperties{ + // Marketplace: &armmongodbatlas.MarketplaceDetails{ + // SubscriptionID: to.Ptr("o"), + // SubscriptionStatus: to.Ptr(armmongodbatlas.MarketplaceSubscriptionStatusPendingFulfillmentStart), + // OfferDetails: &armmongodbatlas.OfferDetails{ + // PublisherID: to.Ptr("rxglearenxsgpwzlsxmiicynks"), + // OfferID: to.Ptr("ohnquleylybvjrtnpjupvwlk"), + // PlanID: to.Ptr("obhxnhvrtbcnoovgofbs"), + // PlanName: to.Ptr("lkwdzpfhvjezjusrqzyftcikxdt"), + // TermUnit: to.Ptr("omkxrnburbnruglwqgjlahvjmbfcse"), + // TermID: to.Ptr("bqmmltwmtpdcdeszbka"), + // }, + // }, + // User: &armmongodbatlas.UserDetails{ + // FirstName: to.Ptr("aslybvdwwddqxwazxvxhjrs"), + // LastName: to.Ptr("cnuitqoqpcyvmuqowgnxpwxjcveyr"), + // EmailAddress: to.Ptr(".K_@e7N-g1.xjqnbPs"), + // Upn: to.Ptr("howdzmfy"), + // PhoneNumber: to.Ptr("ilypntsrbmbbbexbasuu"), + // CompanyName: to.Ptr("oxdcwwl"), + // }, + // ProvisioningState: to.Ptr(armmongodbatlas.ResourceProvisioningStateSucceeded), + // PartnerProperties: &armmongodbatlas.PartnerProperties{ + // OrganizationID: to.Ptr("lpmdubvuizsthw"), + // RedirectURL: to.Ptr("cbxwtehraetlluocdihfgchvjzockn"), + // OrganizationName: to.Ptr("U.1-:7"), + // }, + // }, + // Identity: &armmongodbatlas.ManagedServiceIdentity{ + // PrincipalID: to.Ptr("123e4567-e89b-12d3-a456-426614174000"), + // TenantID: to.Ptr("123e4567-e89b-12d3-a456-426614174000"), + // Type: to.Ptr(armmongodbatlas.ManagedServiceIdentityTypeNone), + // UserAssignedIdentities: map[string]*armmongodbatlas.UserAssignedIdentity{ + // }, + // }, + // Tags: map[string]*string{ + // "key8183": to.Ptr("ibdiopeuhthfvnjjbtkwipooa"), + // }, + // Location: to.Ptr("wobqn"), + // ID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/myResourceGroup/providers/MongoDB.Atlas/organizations/testorg"), + // Name: to.Ptr("qcdj"), + // Type: to.Ptr("pfmxfnhzmwmnmbdbluynkxomgwtqz"), + // SystemData: &armmongodbatlas.SystemData{ + // CreatedBy: to.Ptr("rwy"), + // CreatedByType: to.Ptr(armmongodbatlas.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-12-04T04:51:37.109Z"); return t}()), + // LastModifiedBy: to.Ptr("ceflhxjkjslg"), + // LastModifiedByType: to.Ptr(armmongodbatlas.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-12-04T04:51:37.109Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-11-18-preview/Organizations_Delete_MaximumSet_Gen.json +func ExampleOrganizationsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongodbatlas.NewClientFactory("4AFC1287-D389-4265-B2D4-59B96A45CACC", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewOrganizationsClient().BeginDelete(ctx, "rgopenapi", "U.1-:7", 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: 2024-11-18-preview/Organizations_Get_MaximumSet_Gen.json +func ExampleOrganizationsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongodbatlas.NewClientFactory("4AFC1287-D389-4265-B2D4-59B96A45CACC", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewOrganizationsClient().Get(ctx, "rgopenapi", "U.1-:7", 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 = armmongodbatlas.OrganizationsClientGetResponse{ + // OrganizationResource: &armmongodbatlas.OrganizationResource{ + // Properties: &armmongodbatlas.OrganizationProperties{ + // Marketplace: &armmongodbatlas.MarketplaceDetails{ + // SubscriptionID: to.Ptr("isxzpjgmsgvwmqaridgqgnz"), + // SubscriptionStatus: to.Ptr(armmongodbatlas.MarketplaceSubscriptionStatusPendingFulfillmentStart), + // OfferDetails: &armmongodbatlas.OfferDetails{ + // PublisherID: to.Ptr("fpojslpbvfsqvckbafx"), + // OfferID: to.Ptr("armdqpexqptdprwn"), + // PlanID: to.Ptr("gnbu"), + // PlanName: to.Ptr("tajluzdogtzyep"), + // TermUnit: to.Ptr("wzbofhcxshswsdtq"), + // TermID: to.Ptr("lfppyeno"), + // }, + // }, + // User: &armmongodbatlas.UserDetails{ + // FirstName: to.Ptr("xyiejuwmngdgwkuj"), + // LastName: to.Ptr("qvvxiyucekcxfhkyoasgiluqnk"), + // EmailAddress: to.Ptr(".K_@e7N-g1.xjqnbPs"), + // Upn: to.Ptr("mlcjscht"), + // PhoneNumber: to.Ptr("hkfsjzqbqsskl"), + // CompanyName: to.Ptr("iupxjimdyphrdncsikbuqkeics"), + // }, + // PartnerProperties: &armmongodbatlas.PartnerProperties{ + // OrganizationID: to.Ptr("nshpooeewedeppupwedibg"), + // RedirectURL: to.Ptr("cbxwtehraetlluocdihfgchvjzockn"), + // OrganizationName: to.Ptr("U.1-:7"), + // }, + // ProvisioningState: to.Ptr(armmongodbatlas.ResourceProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("tjmlissxvwsk"), + // Identity: &armmongodbatlas.ManagedServiceIdentity{ + // Type: to.Ptr(armmongodbatlas.ManagedServiceIdentityTypeNone), + // UserAssignedIdentities: map[string]*armmongodbatlas.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("123e4567-e89b-12d3-a456-426614174000"), + // TenantID: to.Ptr("123e4567-e89b-12d3-a456-426614174000"), + // }, + // ID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/myResourceGroup/providers/MongoDB.Atlas/organizations/testorg"), + // Name: to.Ptr("ginfhwxvil"), + // Type: to.Ptr("zmnehscunk"), + // SystemData: &armmongodbatlas.SystemData{ + // CreatedBy: to.Ptr("hetkdvvtqdzyaxbgvpgvthdhw"), + // CreatedByType: to.Ptr(armmongodbatlas.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-19T10:17:41.372Z"); return t}()), + // LastModifiedBy: to.Ptr("aghbfhfodcoagjdcmutdqwh"), + // LastModifiedByType: to.Ptr(armmongodbatlas.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-19T10:17:41.372Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-11-18-preview/Organizations_ListByResourceGroup_MaximumSet_Gen.json +func ExampleOrganizationsClient_NewListByResourceGroupPager_organizationsListByResourceGroupMaximumSet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongodbatlas.NewClientFactory("4AFC1287-D389-4265-B2D4-59B96A45CACC", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOrganizationsClient().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 = armmongodbatlas.OrganizationsClientListByResourceGroupResponse{ + // OrganizationResourceListResult: armmongodbatlas.OrganizationResourceListResult{ + // Value: []*armmongodbatlas.OrganizationResource{ + // { + // Properties: &armmongodbatlas.OrganizationProperties{ + // Marketplace: &armmongodbatlas.MarketplaceDetails{ + // SubscriptionID: to.Ptr("isxzpjgmsgvwmqaridgqgnz"), + // SubscriptionStatus: to.Ptr(armmongodbatlas.MarketplaceSubscriptionStatusPendingFulfillmentStart), + // OfferDetails: &armmongodbatlas.OfferDetails{ + // PublisherID: to.Ptr("fpojslpbvfsqvckbafx"), + // OfferID: to.Ptr("armdqpexqptdprwn"), + // PlanID: to.Ptr("gnbu"), + // PlanName: to.Ptr("tajluzdogtzyep"), + // TermUnit: to.Ptr("wzbofhcxshswsdtq"), + // TermID: to.Ptr("lfppyeno"), + // }, + // }, + // User: &armmongodbatlas.UserDetails{ + // FirstName: to.Ptr("xyiejuwmngdgwkuj"), + // LastName: to.Ptr("qvvxiyucekcxfhkyoasgiluqnk"), + // EmailAddress: to.Ptr(".K_@e7N-g1.xjqnbPs"), + // Upn: to.Ptr("mlcjscht"), + // PhoneNumber: to.Ptr("hkfsjzqbqsskl"), + // CompanyName: to.Ptr("iupxjimdyphrdncsikbuqkeics"), + // }, + // ProvisioningState: to.Ptr(armmongodbatlas.ResourceProvisioningStateSucceeded), + // PartnerProperties: &armmongodbatlas.PartnerProperties{ + // OrganizationID: to.Ptr("nshpooeewedeppupwedibg"), + // RedirectURL: to.Ptr("cbxwtehraetlluocdihfgchvjzockn"), + // OrganizationName: to.Ptr("U.1-:7"), + // }, + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("tjmlissxvwsk"), + // ID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/myResourceGroup/providers/MongoDB.Atlas/organizations/testorg"), + // Name: to.Ptr("ginfhwxvil"), + // Type: to.Ptr("zmnehscunk"), + // SystemData: &armmongodbatlas.SystemData{ + // CreatedBy: to.Ptr("hetkdvvtqdzyaxbgvpgvthdhw"), + // CreatedByType: to.Ptr(armmongodbatlas.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-19T10:17:41.372Z"); return t}()), + // LastModifiedBy: to.Ptr("aghbfhfodcoagjdcmutdqwh"), + // LastModifiedByType: to.Ptr(armmongodbatlas.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-19T10:17:41.372Z"); return t}()), + // }, + // Identity: &armmongodbatlas.ManagedServiceIdentity{ + // PrincipalID: to.Ptr("123e4567-e89b-12d3-a456-426614174000"), + // TenantID: to.Ptr("123e4567-e89b-12d3-a456-426614174000"), + // Type: to.Ptr(armmongodbatlas.ManagedServiceIdentityTypeNone), + // UserAssignedIdentities: map[string]*armmongodbatlas.UserAssignedIdentity{ + // }, + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2024-11-18-preview/Organizations_ListByResourceGroup_MinimumSet_Gen.json +func ExampleOrganizationsClient_NewListByResourceGroupPager_organizationsListByResourceGroupMaximumSetGeneratedByMinimumSetRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongodbatlas.NewClientFactory("422A4D59-A5BC-4DBB-8831-EC666633F64F", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOrganizationsClient().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 = armmongodbatlas.OrganizationsClientListByResourceGroupResponse{ + // OrganizationResourceListResult: armmongodbatlas.OrganizationResourceListResult{ + // Value: []*armmongodbatlas.OrganizationResource{ + // { + // Location: to.Ptr("tjmlissxvwsk"), + // ID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/myResourceGroup/providers/MongoDB.Atlas/organizations/testorg"), + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-11-18-preview/Organizations_ListBySubscription_MaximumSet_Gen.json +func ExampleOrganizationsClient_NewListBySubscriptionPager_organizationsListBySubscriptionMaximumSet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongodbatlas.NewClientFactory("4AFC1287-D389-4265-B2D4-59B96A45CACC", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOrganizationsClient().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 = armmongodbatlas.OrganizationsClientListBySubscriptionResponse{ + // OrganizationResourceListResult: armmongodbatlas.OrganizationResourceListResult{ + // Value: []*armmongodbatlas.OrganizationResource{ + // { + // Properties: &armmongodbatlas.OrganizationProperties{ + // Marketplace: &armmongodbatlas.MarketplaceDetails{ + // SubscriptionID: to.Ptr("isxzpjgmsgvwmqaridgqgnz"), + // SubscriptionStatus: to.Ptr(armmongodbatlas.MarketplaceSubscriptionStatusPendingFulfillmentStart), + // OfferDetails: &armmongodbatlas.OfferDetails{ + // PublisherID: to.Ptr("fpojslpbvfsqvckbafx"), + // OfferID: to.Ptr("armdqpexqptdprwn"), + // PlanID: to.Ptr("gnbu"), + // PlanName: to.Ptr("tajluzdogtzyep"), + // TermUnit: to.Ptr("wzbofhcxshswsdtq"), + // TermID: to.Ptr("lfppyeno"), + // }, + // }, + // User: &armmongodbatlas.UserDetails{ + // FirstName: to.Ptr("xyiejuwmngdgwkuj"), + // LastName: to.Ptr("qvvxiyucekcxfhkyoasgiluqnk"), + // EmailAddress: to.Ptr(".K_@e7N-g1.xjqnbPs"), + // Upn: to.Ptr("mlcjscht"), + // PhoneNumber: to.Ptr("hkfsjzqbqsskl"), + // CompanyName: to.Ptr("iupxjimdyphrdncsikbuqkeics"), + // }, + // ProvisioningState: to.Ptr(armmongodbatlas.ResourceProvisioningStateSucceeded), + // PartnerProperties: &armmongodbatlas.PartnerProperties{ + // OrganizationID: to.Ptr("nshpooeewedeppupwedibg"), + // RedirectURL: to.Ptr("cbxwtehraetlluocdihfgchvjzockn"), + // OrganizationName: to.Ptr("U.1-:7"), + // }, + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("tjmlissxvwsk"), + // ID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/myResourceGroup/providers/MongoDB.Atlas/organizations/testorg"), + // Name: to.Ptr("ginfhwxvil"), + // Type: to.Ptr("zmnehscunk"), + // SystemData: &armmongodbatlas.SystemData{ + // CreatedBy: to.Ptr("hetkdvvtqdzyaxbgvpgvthdhw"), + // CreatedByType: to.Ptr(armmongodbatlas.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-19T10:17:41.372Z"); return t}()), + // LastModifiedBy: to.Ptr("aghbfhfodcoagjdcmutdqwh"), + // LastModifiedByType: to.Ptr(armmongodbatlas.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-19T10:17:41.372Z"); return t}()), + // }, + // Identity: &armmongodbatlas.ManagedServiceIdentity{ + // PrincipalID: to.Ptr("123e4567-e89b-12d3-a456-426614174000"), + // TenantID: to.Ptr("123e4567-e89b-12d3-a456-426614174000"), + // Type: to.Ptr(armmongodbatlas.ManagedServiceIdentityTypeNone), + // UserAssignedIdentities: map[string]*armmongodbatlas.UserAssignedIdentity{ + // }, + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2024-11-18-preview/Organizations_ListBySubscription_MinimumSet_Gen.json +func ExampleOrganizationsClient_NewListBySubscriptionPager_organizationsListBySubscriptionMaximumSetGeneratedByMinimumSetRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongodbatlas.NewClientFactory("422A4D59-A5BC-4DBB-8831-EC666633F64F", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOrganizationsClient().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 = armmongodbatlas.OrganizationsClientListBySubscriptionResponse{ + // OrganizationResourceListResult: armmongodbatlas.OrganizationResourceListResult{ + // Value: []*armmongodbatlas.OrganizationResource{ + // { + // Location: to.Ptr("tjmlissxvwsk"), + // ID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/myResourceGroup/providers/MongoDB.Atlas/organizations/testorg"), + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-11-18-preview/Organizations_Update_MaximumSet_Gen.json +func ExampleOrganizationsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmongodbatlas.NewClientFactory("422A4D59-A5BC-4DBB-8831-EC666633F64F", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewOrganizationsClient().BeginUpdate(ctx, "rgopenapi", "U.1-:7", armmongodbatlas.OrganizationResource{ + Tags: map[string]*string{}, + Properties: &armmongodbatlas.OrganizationProperties{ + User: &armmongodbatlas.UserDetails{ + FirstName: to.Ptr("btyhwmlbzzihjfimviefebg"), + LastName: to.Ptr("xx"), + EmailAddress: to.Ptr(".K_@e7N-g1.xjqnbPs"), + Upn: to.Ptr("mxtbogd"), + PhoneNumber: to.Ptr("isvc"), + CompanyName: to.Ptr("oztteysco"), + }, + PartnerProperties: &armmongodbatlas.PartnerProperties{ + OrganizationID: to.Ptr("vugtqrobendjkinziswxlqueouo"), + RedirectURL: to.Ptr("cbxwtehraetlluocdihfgchvjzockn"), + OrganizationName: to.Ptr("U.1-:7"), + }, + }, + Identity: &armmongodbatlas.ManagedServiceIdentity{ + Type: to.Ptr(armmongodbatlas.ManagedServiceIdentityTypeNone), + UserAssignedIdentities: map[string]*armmongodbatlas.UserAssignedIdentity{}, + }, + }, 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 = armmongodbatlas.OrganizationsClientUpdateResponse{ + // OrganizationResource: &armmongodbatlas.OrganizationResource{ + // Properties: &armmongodbatlas.OrganizationProperties{ + // Marketplace: &armmongodbatlas.MarketplaceDetails{ + // SubscriptionID: to.Ptr("isxzpjgmsgvwmqaridgqgnz"), + // SubscriptionStatus: to.Ptr(armmongodbatlas.MarketplaceSubscriptionStatusPendingFulfillmentStart), + // OfferDetails: &armmongodbatlas.OfferDetails{ + // PublisherID: to.Ptr("fpojslpbvfsqvckbafx"), + // OfferID: to.Ptr("armdqpexqptdprwn"), + // PlanID: to.Ptr("gnbu"), + // PlanName: to.Ptr("tajluzdogtzyep"), + // TermUnit: to.Ptr("wzbofhcxshswsdtq"), + // TermID: to.Ptr("lfppyeno"), + // }, + // }, + // User: &armmongodbatlas.UserDetails{ + // FirstName: to.Ptr("btyhwmlbzzihjfimviefebg"), + // LastName: to.Ptr("xx"), + // EmailAddress: to.Ptr(".K_@e7N-g1.xjqnbPs"), + // Upn: to.Ptr("mxtbogd"), + // PhoneNumber: to.Ptr("isvc"), + // CompanyName: to.Ptr("oztteysco"), + // }, + // PartnerProperties: &armmongodbatlas.PartnerProperties{ + // OrganizationID: to.Ptr("vugtqrobendjkinziswxlqueouo"), + // OrganizationName: to.Ptr("U.1-:7"), + // }, + // ProvisioningState: to.Ptr(armmongodbatlas.ResourceProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // }, + // Location: to.Ptr("tjmlissxvwsk"), + // Identity: &armmongodbatlas.ManagedServiceIdentity{ + // Type: to.Ptr(armmongodbatlas.ManagedServiceIdentityTypeNone), + // UserAssignedIdentities: map[string]*armmongodbatlas.UserAssignedIdentity{ + // }, + // PrincipalID: to.Ptr("123e4567-e89b-12d3-a456-426614174000"), + // TenantID: to.Ptr("123e4567-e89b-12d3-a456-426614174000"), + // }, + // ID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM"), + // Name: to.Ptr("ginfhwxvil"), + // Type: to.Ptr("zmnehscunk"), + // SystemData: &armmongodbatlas.SystemData{ + // CreatedBy: to.Ptr("hetkdvvtqdzyaxbgvpgvthdhw"), + // CreatedByType: to.Ptr(armmongodbatlas.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-19T10:17:41.372Z"); return t}()), + // LastModifiedBy: to.Ptr("aghbfhfodcoagjdcmutdqwh"), + // LastModifiedByType: to.Ptr(armmongodbatlas.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-19T10:17:41.372Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/mongodbatlas/armmongodbatlas/responses.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/responses.go new file mode 100644 index 000000000000..b526da64819c --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/responses.go @@ -0,0 +1,46 @@ +// 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 armmongodbatlas + +// 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 +} + +// OrganizationsClientCreateOrUpdateResponse contains the response from method OrganizationsClient.BeginCreateOrUpdate. +type OrganizationsClientCreateOrUpdateResponse struct { + // The resource model definition for an Azure Organization + OrganizationResource +} + +// OrganizationsClientDeleteResponse contains the response from method OrganizationsClient.BeginDelete. +type OrganizationsClientDeleteResponse struct { + // placeholder for future response values +} + +// OrganizationsClientGetResponse contains the response from method OrganizationsClient.Get. +type OrganizationsClientGetResponse struct { + // The resource model definition for an Azure Organization + OrganizationResource +} + +// OrganizationsClientListByResourceGroupResponse contains the response from method OrganizationsClient.NewListByResourceGroupPager. +type OrganizationsClientListByResourceGroupResponse struct { + // The response of a OrganizationResource list operation. + OrganizationResourceListResult +} + +// OrganizationsClientListBySubscriptionResponse contains the response from method OrganizationsClient.NewListBySubscriptionPager. +type OrganizationsClientListBySubscriptionResponse struct { + // The response of a OrganizationResource list operation. + OrganizationResourceListResult +} + +// OrganizationsClientUpdateResponse contains the response from method OrganizationsClient.BeginUpdate. +type OrganizationsClientUpdateResponse struct { + // The resource model definition for an Azure Organization + OrganizationResource +} diff --git a/sdk/resourcemanager/mongodbatlas/armmongodbatlas/time_rfc3339.go b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/time_rfc3339.go new file mode 100644 index 000000000000..55bbaae9c208 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/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 armmongodbatlas + +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/mongodbatlas/armmongodbatlas/tsp-location.yaml b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/tsp-location.yaml new file mode 100644 index 000000000000..710d5b68c664 --- /dev/null +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/liftrmongodb/MongoDB.Atlas.Management +commit: c0d9186502bf5acb015cda9c0ef6fb22a531d896 +repo: Azure/azure-rest-api-specs +additionalDirectories: \ No newline at end of file From 806b009c0f6e8cc334a56a3a466e0f522f2e5a44 Mon Sep 17 00:00:00 2001 From: jliusan Date: Thu, 8 May 2025 10:33:02 +0800 Subject: [PATCH 2/2] rename module name --- .../mongodbatlas/armmongodbatlas/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/resourcemanager/mongodbatlas/armmongodbatlas/README.md b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/README.md index 4a56a489ff96..cf9fb278cd0f 100644 --- a/sdk/resourcemanager/mongodbatlas/armmongodbatlas/README.md +++ b/sdk/resourcemanager/mongodbatlas/armmongodbatlas/README.md @@ -1,6 +1,6 @@ -# Azure Mongodbatlas Module for Go +# Azure Mongodb Atlas Module for Go -The `armmongodbatlas` module provides operations for working with Azure Mongodbatlas. +The `armmongodbatlas` module provides operations for working with Azure Mongodb Atlas. [Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/mongodbatlas/armmongodbatlas) @@ -15,7 +15,7 @@ The `armmongodbatlas` module provides operations for working with Azure Mongodba This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. -Install the Azure Mongodbatlas module: +Install the Azure Mongodb Atlas module: ```sh go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongodbatlas/armmongodbatlas @@ -23,7 +23,7 @@ go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mongodbatlas/armmon ## Authorization -When creating a client, you will need to provide a credential for authenticating with Azure Mongodbatlas. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. +When creating a client, you will need to provide a credential for authenticating with Azure Mongodb Atlas. 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) @@ -33,7 +33,7 @@ For more information on authentication, please see the documentation for `aziden ## Client Factory -Azure Mongodbatlas module consists of one or more clients. We provide a client factory which could be used to create any client in this module. +Azure Mongodb Atlas 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 := armmongodbatlas.NewClientFactory(, cred, nil)