diff --git a/sdk/resourcemanager/neonpostgres/armneonpostgres/CHANGELOG.md b/sdk/resourcemanager/neonpostgres/armneonpostgres/CHANGELOG.md new file mode 100644 index 000000000000..1cc6386b8b8b --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2024-11-20) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/neonpostgres/armneonpostgres` 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/neonpostgres/armneonpostgres/LICENSE.txt b/sdk/resourcemanager/neonpostgres/armneonpostgres/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/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/neonpostgres/armneonpostgres/README.md b/sdk/resourcemanager/neonpostgres/armneonpostgres/README.md new file mode 100644 index 000000000000..b174d993f553 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/README.md @@ -0,0 +1,90 @@ +# Azure Neon Postgres Module for Go + +The `armneonpostgres` module provides operations for working with Azure Neon Postgres. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/neonpostgres/armneonpostgres) + +# 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 Neon Postgres module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/neonpostgres/armneonpostgres +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Neon Postgres. 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 Neon Postgres 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 := armneonpostgres.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 := armneonpostgres.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 `Neon Postgres` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. diff --git a/sdk/resourcemanager/neonpostgres/armneonpostgres/ci.yml b/sdk/resourcemanager/neonpostgres/armneonpostgres/ci.yml new file mode 100644 index 000000000000..5c7817a545e6 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/ci.yml @@ -0,0 +1,28 @@ +# 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/neonpostgres/armneonpostgres/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/neonpostgres/armneonpostgres/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/neonpostgres/armneonpostgres' diff --git a/sdk/resourcemanager/neonpostgres/armneonpostgres/client_factory.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/client_factory.go new file mode 100644 index 000000000000..9952282e6d03 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/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 armneonpostgres + +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/neonpostgres/armneonpostgres/constants.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/constants.go new file mode 100644 index 000000000000..471985f693d9 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/constants.go @@ -0,0 +1,138 @@ +// 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 armneonpostgres + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/neonpostgres/armneonpostgres" + 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, + } +} + +// 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, + } +} + +// SingleSignOnStates - Various states of the SSO resource +type SingleSignOnStates string + +const ( + // SingleSignOnStatesDisable - SSO is disabled for the organization + SingleSignOnStatesDisable SingleSignOnStates = "Disable" + // SingleSignOnStatesEnable - SSO is enabled for the organization + SingleSignOnStatesEnable SingleSignOnStates = "Enable" + // SingleSignOnStatesInitial - Initial state of the SSO resource + SingleSignOnStatesInitial SingleSignOnStates = "Initial" +) + +// PossibleSingleSignOnStatesValues returns the possible values for the SingleSignOnStates const type. +func PossibleSingleSignOnStatesValues() []SingleSignOnStates { + return []SingleSignOnStates{ + SingleSignOnStatesDisable, + SingleSignOnStatesEnable, + SingleSignOnStatesInitial, + } +} diff --git a/sdk/resourcemanager/neonpostgres/armneonpostgres/fake/internal.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/fake/internal.go new file mode 100644 index 000000000000..7425b6a669e2 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/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/neonpostgres/armneonpostgres/fake/operations_server.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/fake/operations_server.go new file mode 100644 index 000000000000..c30b0623a4d2 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/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/neonpostgres/armneonpostgres" + "net/http" +) + +// OperationsServer is a fake server for instances of the armneonpostgres.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armneonpostgres.OperationsClientListOptions) (resp azfake.PagerResponder[armneonpostgres.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armneonpostgres.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[armneonpostgres.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armneonpostgres.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armneonpostgres.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 *armneonpostgres.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/neonpostgres/armneonpostgres/fake/organizations_server.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/fake/organizations_server.go new file mode 100644 index 000000000000..10e568444f2e --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/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/neonpostgres/armneonpostgres" + "net/http" + "net/url" + "regexp" +) + +// OrganizationsServer is a fake server for instances of the armneonpostgres.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 armneonpostgres.OrganizationResource, options *armneonpostgres.OrganizationsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armneonpostgres.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 *armneonpostgres.OrganizationsClientBeginDeleteOptions) (resp azfake.PollerResponder[armneonpostgres.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 *armneonpostgres.OrganizationsClientGetOptions) (resp azfake.Responder[armneonpostgres.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 *armneonpostgres.OrganizationsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armneonpostgres.OrganizationsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method OrganizationsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armneonpostgres.OrganizationsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armneonpostgres.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 armneonpostgres.OrganizationResource, options *armneonpostgres.OrganizationsClientBeginUpdateOptions) (resp azfake.PollerResponder[armneonpostgres.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 armneonpostgres.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[armneonpostgres.OrganizationsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armneonpostgres.OrganizationsClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armneonpostgres.OrganizationsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armneonpostgres.OrganizationsClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armneonpostgres.OrganizationsClientUpdateResponse]](), + } +} + +// OrganizationsServerTransport connects instances of armneonpostgres.OrganizationsClient to instances of OrganizationsServer. +// Don't use this type directly, use NewOrganizationsServerTransport instead. +type OrganizationsServerTransport struct { + srv *OrganizationsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armneonpostgres.OrganizationsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armneonpostgres.OrganizationsClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armneonpostgres.OrganizationsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armneonpostgres.OrganizationsClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armneonpostgres.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/Neon\.Postgres/organizations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armneonpostgres.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/Neon\.Postgres/organizations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || 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 + } + 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/Neon\.Postgres/organizations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || 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 + } + 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/Neon\.Postgres/organizations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + 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 *armneonpostgres.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/Neon\.Postgres/organizations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + 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 *armneonpostgres.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/Neon\.Postgres/organizations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armneonpostgres.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/neonpostgres/armneonpostgres/fake/server_factory.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/fake/server_factory.go new file mode 100644 index 000000000000..556d0757b464 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/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 armneonpostgres.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 armneonpostgres.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 armneonpostgres.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/neonpostgres/armneonpostgres/fake/time_rfc3339.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/fake/time_rfc3339.go new file mode 100644 index 000000000000..87ee11e83b32 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/fake/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 fake + +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/neonpostgres/armneonpostgres/go.mod b/sdk/resourcemanager/neonpostgres/armneonpostgres/go.mod new file mode 100644 index 000000000000..153029e47ec0 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/neonpostgres/armneonpostgres + +go 1.18 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 + 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.27.0 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/text v0.18.0 // indirect +) diff --git a/sdk/resourcemanager/neonpostgres/armneonpostgres/go.sum b/sdk/resourcemanager/neonpostgres/armneonpostgres/go.sum new file mode 100644 index 000000000000..cbddbbd9ecec --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/go.sum @@ -0,0 +1,29 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 h1:JZg6HRh6W6U4OLl6lk7BZ7BLisIzM9dG1R50zUk9C/M= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0/go.mod h1:YL1xnZ6QejvQHWJrX/AvhFl4WW4rqHVoKspWNVwFk0M= +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/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/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/neonpostgres/armneonpostgres/models.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/models.go new file mode 100644 index 000000000000..c2f676abe180 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/models.go @@ -0,0 +1,227 @@ +// 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 armneonpostgres + +import "time" + +// CompanyDetails - Company details for an organization +type CompanyDetails struct { + // Business phone number of the company + BusinessPhone *string + + // Company name + CompanyName *string + + // Country name of the company + Country *string + + // Domain of the user + Domain *string + + // Number of employees in the company + NumberOfEmployees *int64 + + // Office address of the company + OfficeAddress *string +} + +// MarketplaceDetails - Marketplace details for an organization +type MarketplaceDetails struct { + // REQUIRED; Offer details for the marketplace that is selected by the user + OfferDetails *OfferDetails + + // SaaS subscription id for the the marketplace offer + SubscriptionID *string + + // 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 + + // Term Id for the marketplace offer + TermID *string + + // Term Name for the marketplace offer + TermUnit *string +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Localized display information for this particular operation. + Display *OperationDisplay + + // 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 Data Organization resource +type OrganizationProperties struct { + // REQUIRED; Details of the company. + CompanyDetails *CompanyDetails + + // REQUIRED; Marketplace details of the resource. + MarketplaceDetails *MarketplaceDetails + + // REQUIRED; Details of the user. + UserDetails *UserDetails + + // Organization properties + PartnerOrganizationProperties *PartnerOrganizationProperties + + // READ-ONLY; Provisioning state of the resource. + ProvisioningState *ResourceProvisioningState +} + +// OrganizationResource - Organization Resource by Neon +type OrganizationResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *OrganizationProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Name of the Neon Organizations resource + Name *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 +} + +// PartnerOrganizationProperties - Properties specific to Partner's organization +type PartnerOrganizationProperties struct { + // REQUIRED; Organization name in partner's system + OrganizationName *string + + // Organization Id in partner's system + OrganizationID *string + + // Single Sign On properties for the organization + SingleSignOnProperties *SingleSignOnProperties +} + +// SingleSignOnProperties - Properties specific to Single Sign On Resource +type SingleSignOnProperties struct { + // List of AAD domains fetched from Microsoft Graph for user. + AADDomains []*string + + // AAD enterprise application Id used to setup SSO + EnterpriseAppID *string + + // State of the Single Sign On for the organization + SingleSignOnState *SingleSignOnStates + + // URL for SSO to be used by the partner to redirect the user to their system + SingleSignOnURL *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 +} + +// UserDetails - User details for an organization +type UserDetails struct { + // Email address of the user + EmailAddress *string + + // First name of the user + FirstName *string + + // Last name of the user + LastName *string + + // User's phone number + PhoneNumber *string + + // User's principal name + Upn *string +} diff --git a/sdk/resourcemanager/neonpostgres/armneonpostgres/models_serde.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/models_serde.go new file mode 100644 index 000000000000..717b61c582bb --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/models_serde.go @@ -0,0 +1,563 @@ +// 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 armneonpostgres + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type CompanyDetails. +func (c CompanyDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "businessPhone", c.BusinessPhone) + populate(objectMap, "companyName", c.CompanyName) + populate(objectMap, "country", c.Country) + populate(objectMap, "domain", c.Domain) + populate(objectMap, "numberOfEmployees", c.NumberOfEmployees) + populate(objectMap, "officeAddress", c.OfficeAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CompanyDetails. +func (c *CompanyDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "businessPhone": + err = unpopulate(val, "BusinessPhone", &c.BusinessPhone) + delete(rawMsg, key) + case "companyName": + err = unpopulate(val, "CompanyName", &c.CompanyName) + delete(rawMsg, key) + case "country": + err = unpopulate(val, "Country", &c.Country) + delete(rawMsg, key) + case "domain": + err = unpopulate(val, "Domain", &c.Domain) + delete(rawMsg, key) + case "numberOfEmployees": + err = unpopulate(val, "NumberOfEmployees", &c.NumberOfEmployees) + delete(rawMsg, key) + case "officeAddress": + err = unpopulate(val, "OfficeAddress", &c.OfficeAddress) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type 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, "companyDetails", o.CompanyDetails) + populate(objectMap, "marketplaceDetails", o.MarketplaceDetails) + populate(objectMap, "partnerOrganizationProperties", o.PartnerOrganizationProperties) + populate(objectMap, "provisioningState", o.ProvisioningState) + populate(objectMap, "userDetails", o.UserDetails) + 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 "companyDetails": + err = unpopulate(val, "CompanyDetails", &o.CompanyDetails) + delete(rawMsg, key) + case "marketplaceDetails": + err = unpopulate(val, "MarketplaceDetails", &o.MarketplaceDetails) + delete(rawMsg, key) + case "partnerOrganizationProperties": + err = unpopulate(val, "PartnerOrganizationProperties", &o.PartnerOrganizationProperties) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &o.ProvisioningState) + delete(rawMsg, key) + case "userDetails": + err = unpopulate(val, "UserDetails", &o.UserDetails) + 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, "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 "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 PartnerOrganizationProperties. +func (p PartnerOrganizationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "organizationId", p.OrganizationID) + populate(objectMap, "organizationName", p.OrganizationName) + populate(objectMap, "singleSignOnProperties", p.SingleSignOnProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PartnerOrganizationProperties. +func (p *PartnerOrganizationProperties) 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 "singleSignOnProperties": + err = unpopulate(val, "SingleSignOnProperties", &p.SingleSignOnProperties) + 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 SingleSignOnProperties. +func (s SingleSignOnProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "aadDomains", s.AADDomains) + populate(objectMap, "enterpriseAppId", s.EnterpriseAppID) + populate(objectMap, "singleSignOnState", s.SingleSignOnState) + populate(objectMap, "singleSignOnUrl", s.SingleSignOnURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SingleSignOnProperties. +func (s *SingleSignOnProperties) 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 "aadDomains": + err = unpopulate(val, "AADDomains", &s.AADDomains) + delete(rawMsg, key) + case "enterpriseAppId": + err = unpopulate(val, "EnterpriseAppID", &s.EnterpriseAppID) + delete(rawMsg, key) + case "singleSignOnState": + err = unpopulate(val, "SingleSignOnState", &s.SingleSignOnState) + delete(rawMsg, key) + case "singleSignOnUrl": + err = unpopulate(val, "SingleSignOnURL", &s.SingleSignOnURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserDetails. +func (u UserDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 "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/neonpostgres/armneonpostgres/operations_client.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/operations_client.go new file mode 100644 index 000000000000..d4de494eccb2 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/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 armneonpostgres + +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-08-01-preview +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Neon.Postgres/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-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/neonpostgres/armneonpostgres/operations_client_example_test.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/operations_client_example_test.go new file mode 100644 index 000000000000..88e995b751b9 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/operations_client_example_test.go @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. + +package armneonpostgres_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/neonpostgres/armneonpostgres" + "log" +) + +// Generated from example definition: 2024-08-01-preview/Operations_List_MaximumSet_Gen.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armneonpostgres.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 = armneonpostgres.OperationsClientListResponse{ + // OperationListResult: armneonpostgres.OperationListResult{ + // Value: []*armneonpostgres.Operation{ + // { + // Name: to.Ptr("ekvuojrpbuyogrikfuzyghio"), + // IsDataAction: to.Ptr(true), + // Display: &armneonpostgres.OperationDisplay{ + // Provider: to.Ptr("lvppuskqcdcoejwuvsqrloczvnouy"), + // Resource: to.Ptr("rvvd"), + // Operation: to.Ptr("odjjqnodcgszczpsdrhrpwmqssrybr"), + // Description: to.Ptr("bwmstukaiaoisiu"), + // }, + // Origin: to.Ptr(armneonpostgres.OriginUser), + // ActionType: to.Ptr(armneonpostgres.ActionTypeInternal), + // }, + // }, + // NextLink: to.Ptr("https://contoso.com/nextlink"), + // }, + // } + } +} diff --git a/sdk/resourcemanager/neonpostgres/armneonpostgres/options.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/options.go new file mode 100644 index 000000000000..bfccbb6f8dfa --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/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 armneonpostgres + +// 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/neonpostgres/armneonpostgres/organizations_client.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/organizations_client.go new file mode 100644 index 000000000000..81c23c12b462 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/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 armneonpostgres + +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-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Name of the Neon Organizations 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-08-01-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/Neon.Postgres/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-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a OrganizationResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Name of the Neon Organizations 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-08-01-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/Neon.Postgres/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-08-01-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-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Name of the Neon Organizations 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/Neon.Postgres/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-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *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-08-01-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/Neon.Postgres/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-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *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-08-01-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/Neon.Postgres/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-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *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-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - organizationName - Name of the Neon Organizations 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-08-01-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/Neon.Postgres/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-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/neonpostgres/armneonpostgres/organizations_client_example_test.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/organizations_client_example_test.go new file mode 100644 index 000000000000..8c1b36426b1d --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/organizations_client_example_test.go @@ -0,0 +1,546 @@ +// 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 armneonpostgres_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/neonpostgres/armneonpostgres" + "log" +) + +// Generated from example definition: 2024-08-01-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 := armneonpostgres.NewClientFactory("1178323D-8270-4757-B639-D528B6266487", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewOrganizationsClient().BeginCreateOrUpdate(ctx, "rgneon", "XB-.:", armneonpostgres.OrganizationResource{ + Properties: &armneonpostgres.OrganizationProperties{ + MarketplaceDetails: &armneonpostgres.MarketplaceDetails{ + SubscriptionID: to.Ptr("yxmkfivp"), + SubscriptionStatus: to.Ptr(armneonpostgres.MarketplaceSubscriptionStatusPendingFulfillmentStart), + OfferDetails: &armneonpostgres.OfferDetails{ + PublisherID: to.Ptr("hporaxnopmolttlnkbarw"), + OfferID: to.Ptr("bunyeeupoedueofwrzej"), + PlanID: to.Ptr("nlbfiwtslenfwek"), + PlanName: to.Ptr("ljbmgpkfqklaufacbpml"), + TermUnit: to.Ptr("qbcq"), + TermID: to.Ptr("aedlchikwqckuploswthvshe"), + }, + }, + UserDetails: &armneonpostgres.UserDetails{ + FirstName: to.Ptr("buwwe"), + LastName: to.Ptr("escynjpynkoox"), + EmailAddress: to.Ptr("3i_%@w8-y.H-p.tvj.dG"), + Upn: to.Ptr("fwedjamgwwrotcjaucuzdwycfjdqn"), + PhoneNumber: to.Ptr("dlrqoowumy"), + }, + CompanyDetails: &armneonpostgres.CompanyDetails{ + CompanyName: to.Ptr("uxn"), + Country: to.Ptr("lpajqzptqchuko"), + OfficeAddress: to.Ptr("chpkrlpmfslmawgunjxdllzcrctykq"), + BusinessPhone: to.Ptr("hbeb"), + Domain: to.Ptr("krjldeakhwiepvs"), + NumberOfEmployees: to.Ptr[int64](23), + }, + PartnerOrganizationProperties: &armneonpostgres.PartnerOrganizationProperties{ + OrganizationID: to.Ptr("nrhvoqzulowcunhmvwfgjcaibvwcl"), + OrganizationName: to.Ptr("2__.-"), + SingleSignOnProperties: &armneonpostgres.SingleSignOnProperties{ + SingleSignOnState: to.Ptr(armneonpostgres.SingleSignOnStatesInitial), + EnterpriseAppID: to.Ptr("fpibacregjfncfdsojs"), + SingleSignOnURL: to.Ptr("tmojh"), + AADDomains: []*string{ + to.Ptr("kndszgrwzbvvlssvkej"), + }, + }, + }, + }, + Tags: map[string]*string{ + "key2099": to.Ptr("omjjymaqtrqzksxszhzgyl"), + }, + Location: to.Ptr("upxxgikyqrbnv"), + }, 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 = armneonpostgres.OrganizationsClientCreateOrUpdateResponse{ + // OrganizationResource: &armneonpostgres.OrganizationResource{ + // Properties: &armneonpostgres.OrganizationProperties{ + // MarketplaceDetails: &armneonpostgres.MarketplaceDetails{ + // SubscriptionID: to.Ptr("yxmkfivp"), + // SubscriptionStatus: to.Ptr(armneonpostgres.MarketplaceSubscriptionStatusPendingFulfillmentStart), + // OfferDetails: &armneonpostgres.OfferDetails{ + // PublisherID: to.Ptr("hporaxnopmolttlnkbarw"), + // OfferID: to.Ptr("bunyeeupoedueofwrzej"), + // PlanID: to.Ptr("nlbfiwtslenfwek"), + // PlanName: to.Ptr("ljbmgpkfqklaufacbpml"), + // TermUnit: to.Ptr("qbcq"), + // TermID: to.Ptr("aedlchikwqckuploswthvshe"), + // }, + // }, + // UserDetails: &armneonpostgres.UserDetails{ + // FirstName: to.Ptr("buwwe"), + // LastName: to.Ptr("escynjpynkoox"), + // EmailAddress: to.Ptr("3i_%@w8-y.H-p.tvj.dG"), + // Upn: to.Ptr("fwedjamgwwrotcjaucuzdwycfjdqn"), + // PhoneNumber: to.Ptr("dlrqoowumy"), + // }, + // CompanyDetails: &armneonpostgres.CompanyDetails{ + // CompanyName: to.Ptr("uxn"), + // Country: to.Ptr("lpajqzptqchuko"), + // OfficeAddress: to.Ptr("chpkrlpmfslmawgunjxdllzcrctykq"), + // BusinessPhone: to.Ptr("hbeb"), + // Domain: to.Ptr("krjldeakhwiepvs"), + // NumberOfEmployees: to.Ptr[int64](23), + // }, + // ProvisioningState: to.Ptr(armneonpostgres.ResourceProvisioningStateSucceeded), + // PartnerOrganizationProperties: &armneonpostgres.PartnerOrganizationProperties{ + // OrganizationID: to.Ptr("nrhvoqzulowcunhmvwfgjcaibvwcl"), + // OrganizationName: to.Ptr("2__.-"), + // SingleSignOnProperties: &armneonpostgres.SingleSignOnProperties{ + // SingleSignOnState: to.Ptr(armneonpostgres.SingleSignOnStatesInitial), + // EnterpriseAppID: to.Ptr("fpibacregjfncfdsojs"), + // SingleSignOnURL: to.Ptr("tmojh"), + // AADDomains: []*string{ + // to.Ptr("kndszgrwzbvvlssvkej"), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key2099": to.Ptr("omjjymaqtrqzksxszhzgyl"), + // }, + // Location: to.Ptr("upxxgikyqrbnv"), + // ID: to.Ptr("/subscriptions/1178323D-8270-4757-B639-D528B6266487/resourceGroups/rgneon/providers/Microsoft.Neon/organizations/2__.-"), + // Name: to.Ptr("grhdqtqnkqmu"), + // Type: to.Ptr("gapeymltyvlqlvpgdgfxidkkd"), + // SystemData: &armneonpostgres.SystemData{ + // CreatedBy: to.Ptr("qfhekdgpvdtqcohjhvlyhzd"), + // CreatedByType: to.Ptr(armneonpostgres.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-30T15:12:24.902Z"); return t}()), + // LastModifiedBy: to.Ptr("dqsjroejrtucfjyqcoonpdopfaa"), + // LastModifiedByType: to.Ptr(armneonpostgres.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-30T15:12:24.902Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-08-01-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 := armneonpostgres.NewClientFactory("1178323D-8270-4757-B639-D528B6266487", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewOrganizationsClient().BeginDelete(ctx, "rgneon", "2_3", 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-08-01-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 := armneonpostgres.NewClientFactory("1178323D-8270-4757-B639-D528B6266487", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewOrganizationsClient().Get(ctx, "rgneon", "5", 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 = armneonpostgres.OrganizationsClientGetResponse{ + // OrganizationResource: &armneonpostgres.OrganizationResource{ + // Properties: &armneonpostgres.OrganizationProperties{ + // MarketplaceDetails: &armneonpostgres.MarketplaceDetails{ + // SubscriptionID: to.Ptr("yxmkfivp"), + // SubscriptionStatus: to.Ptr(armneonpostgres.MarketplaceSubscriptionStatusPendingFulfillmentStart), + // OfferDetails: &armneonpostgres.OfferDetails{ + // PublisherID: to.Ptr("hporaxnopmolttlnkbarw"), + // OfferID: to.Ptr("bunyeeupoedueofwrzej"), + // PlanID: to.Ptr("nlbfiwtslenfwek"), + // PlanName: to.Ptr("ljbmgpkfqklaufacbpml"), + // TermUnit: to.Ptr("qbcq"), + // TermID: to.Ptr("aedlchikwqckuploswthvshe"), + // }, + // }, + // UserDetails: &armneonpostgres.UserDetails{ + // FirstName: to.Ptr("buwwe"), + // LastName: to.Ptr("escynjpynkoox"), + // EmailAddress: to.Ptr("3i_%@w8-y.H-p.tvj.dG"), + // Upn: to.Ptr("fwedjamgwwrotcjaucuzdwycfjdqn"), + // PhoneNumber: to.Ptr("dlrqoowumy"), + // }, + // CompanyDetails: &armneonpostgres.CompanyDetails{ + // CompanyName: to.Ptr("uxn"), + // Country: to.Ptr("lpajqzptqchuko"), + // OfficeAddress: to.Ptr("chpkrlpmfslmawgunjxdllzcrctykq"), + // BusinessPhone: to.Ptr("hbeb"), + // Domain: to.Ptr("krjldeakhwiepvs"), + // NumberOfEmployees: to.Ptr[int64](23), + // }, + // ProvisioningState: to.Ptr(armneonpostgres.ResourceProvisioningStateSucceeded), + // PartnerOrganizationProperties: &armneonpostgres.PartnerOrganizationProperties{ + // OrganizationID: to.Ptr("nrhvoqzulowcunhmvwfgjcaibvwcl"), + // OrganizationName: to.Ptr("2__.-"), + // SingleSignOnProperties: &armneonpostgres.SingleSignOnProperties{ + // SingleSignOnState: to.Ptr(armneonpostgres.SingleSignOnStatesInitial), + // EnterpriseAppID: to.Ptr("fpibacregjfncfdsojs"), + // SingleSignOnURL: to.Ptr("tmojh"), + // AADDomains: []*string{ + // to.Ptr("kndszgrwzbvvlssvkej"), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key2099": to.Ptr("omjjymaqtrqzksxszhzgyl"), + // }, + // Location: to.Ptr("upxxgikyqrbnv"), + // ID: to.Ptr("/subscriptions/1178323D-8270-4757-B639-D528B6266487/resourceGroups/rgneon/providers/Microsoft.Neon/organizations/2__.-"), + // Name: to.Ptr("grhdqtqnkqmu"), + // Type: to.Ptr("gapeymltyvlqlvpgdgfxidkkd"), + // SystemData: &armneonpostgres.SystemData{ + // CreatedBy: to.Ptr("qfhekdgpvdtqcohjhvlyhzd"), + // CreatedByType: to.Ptr(armneonpostgres.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-30T15:12:24.902Z"); return t}()), + // LastModifiedBy: to.Ptr("dqsjroejrtucfjyqcoonpdopfaa"), + // LastModifiedByType: to.Ptr(armneonpostgres.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-30T15:12:24.902Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-08-01-preview/Organizations_ListByResourceGroup_MaximumSet_Gen.json +func ExampleOrganizationsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armneonpostgres.NewClientFactory("1178323D-8270-4757-B639-D528B6266487", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOrganizationsClient().NewListByResourceGroupPager("rgneon", 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 = armneonpostgres.OrganizationsClientListByResourceGroupResponse{ + // OrganizationResourceListResult: armneonpostgres.OrganizationResourceListResult{ + // Value: []*armneonpostgres.OrganizationResource{ + // { + // Properties: &armneonpostgres.OrganizationProperties{ + // MarketplaceDetails: &armneonpostgres.MarketplaceDetails{ + // SubscriptionID: to.Ptr("yxmkfivp"), + // SubscriptionStatus: to.Ptr(armneonpostgres.MarketplaceSubscriptionStatusPendingFulfillmentStart), + // OfferDetails: &armneonpostgres.OfferDetails{ + // PublisherID: to.Ptr("hporaxnopmolttlnkbarw"), + // OfferID: to.Ptr("bunyeeupoedueofwrzej"), + // PlanID: to.Ptr("nlbfiwtslenfwek"), + // PlanName: to.Ptr("ljbmgpkfqklaufacbpml"), + // TermUnit: to.Ptr("qbcq"), + // TermID: to.Ptr("aedlchikwqckuploswthvshe"), + // }, + // }, + // UserDetails: &armneonpostgres.UserDetails{ + // FirstName: to.Ptr("buwwe"), + // LastName: to.Ptr("escynjpynkoox"), + // EmailAddress: to.Ptr("3i_%@w8-y.H-p.tvj.dG"), + // Upn: to.Ptr("fwedjamgwwrotcjaucuzdwycfjdqn"), + // PhoneNumber: to.Ptr("dlrqoowumy"), + // }, + // CompanyDetails: &armneonpostgres.CompanyDetails{ + // CompanyName: to.Ptr("uxn"), + // Country: to.Ptr("lpajqzptqchuko"), + // OfficeAddress: to.Ptr("chpkrlpmfslmawgunjxdllzcrctykq"), + // BusinessPhone: to.Ptr("hbeb"), + // Domain: to.Ptr("krjldeakhwiepvs"), + // NumberOfEmployees: to.Ptr[int64](23), + // }, + // ProvisioningState: to.Ptr(armneonpostgres.ResourceProvisioningStateSucceeded), + // PartnerOrganizationProperties: &armneonpostgres.PartnerOrganizationProperties{ + // OrganizationID: to.Ptr("nrhvoqzulowcunhmvwfgjcaibvwcl"), + // OrganizationName: to.Ptr("2__.-"), + // SingleSignOnProperties: &armneonpostgres.SingleSignOnProperties{ + // SingleSignOnState: to.Ptr(armneonpostgres.SingleSignOnStatesInitial), + // EnterpriseAppID: to.Ptr("fpibacregjfncfdsojs"), + // SingleSignOnURL: to.Ptr("tmojh"), + // AADDomains: []*string{ + // to.Ptr("kndszgrwzbvvlssvkej"), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key2099": to.Ptr("omjjymaqtrqzksxszhzgyl"), + // }, + // Location: to.Ptr("upxxgikyqrbnv"), + // ID: to.Ptr("/subscriptions/1178323D-8270-4757-B639-D528B6266487/resourceGroups/rgneon/providers/Microsoft.Neon/organizations/2__.-"), + // Name: to.Ptr("grhdqtqnkqmu"), + // Type: to.Ptr("gapeymltyvlqlvpgdgfxidkkd"), + // SystemData: &armneonpostgres.SystemData{ + // CreatedBy: to.Ptr("qfhekdgpvdtqcohjhvlyhzd"), + // CreatedByType: to.Ptr(armneonpostgres.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-30T15:12:24.902Z"); return t}()), + // LastModifiedBy: to.Ptr("dqsjroejrtucfjyqcoonpdopfaa"), + // LastModifiedByType: to.Ptr(armneonpostgres.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-30T15:12:24.902Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2024-08-01-preview/Organizations_ListBySubscription_MaximumSet_Gen.json +func ExampleOrganizationsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armneonpostgres.NewClientFactory("1178323D-8270-4757-B639-D528B6266487", 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 = armneonpostgres.OrganizationsClientListBySubscriptionResponse{ + // OrganizationResourceListResult: armneonpostgres.OrganizationResourceListResult{ + // Value: []*armneonpostgres.OrganizationResource{ + // { + // Properties: &armneonpostgres.OrganizationProperties{ + // MarketplaceDetails: &armneonpostgres.MarketplaceDetails{ + // SubscriptionID: to.Ptr("yxmkfivp"), + // SubscriptionStatus: to.Ptr(armneonpostgres.MarketplaceSubscriptionStatusPendingFulfillmentStart), + // OfferDetails: &armneonpostgres.OfferDetails{ + // PublisherID: to.Ptr("hporaxnopmolttlnkbarw"), + // OfferID: to.Ptr("bunyeeupoedueofwrzej"), + // PlanID: to.Ptr("nlbfiwtslenfwek"), + // PlanName: to.Ptr("ljbmgpkfqklaufacbpml"), + // TermUnit: to.Ptr("qbcq"), + // TermID: to.Ptr("aedlchikwqckuploswthvshe"), + // }, + // }, + // UserDetails: &armneonpostgres.UserDetails{ + // FirstName: to.Ptr("buwwe"), + // LastName: to.Ptr("escynjpynkoox"), + // EmailAddress: to.Ptr("3i_%@w8-y.H-p.tvj.dG"), + // Upn: to.Ptr("fwedjamgwwrotcjaucuzdwycfjdqn"), + // PhoneNumber: to.Ptr("dlrqoowumy"), + // }, + // CompanyDetails: &armneonpostgres.CompanyDetails{ + // CompanyName: to.Ptr("uxn"), + // Country: to.Ptr("lpajqzptqchuko"), + // OfficeAddress: to.Ptr("chpkrlpmfslmawgunjxdllzcrctykq"), + // BusinessPhone: to.Ptr("hbeb"), + // Domain: to.Ptr("krjldeakhwiepvs"), + // NumberOfEmployees: to.Ptr[int64](23), + // }, + // ProvisioningState: to.Ptr(armneonpostgres.ResourceProvisioningStateSucceeded), + // PartnerOrganizationProperties: &armneonpostgres.PartnerOrganizationProperties{ + // OrganizationID: to.Ptr("nrhvoqzulowcunhmvwfgjcaibvwcl"), + // OrganizationName: to.Ptr("2__.-"), + // SingleSignOnProperties: &armneonpostgres.SingleSignOnProperties{ + // SingleSignOnState: to.Ptr(armneonpostgres.SingleSignOnStatesInitial), + // EnterpriseAppID: to.Ptr("fpibacregjfncfdsojs"), + // SingleSignOnURL: to.Ptr("tmojh"), + // AADDomains: []*string{ + // to.Ptr("kndszgrwzbvvlssvkej"), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key2099": to.Ptr("omjjymaqtrqzksxszhzgyl"), + // }, + // Location: to.Ptr("upxxgikyqrbnv"), + // ID: to.Ptr("/subscriptions/1178323D-8270-4757-B639-D528B6266487/resourceGroups/rgneon/providers/Microsoft.Neon/organizations/2__.-"), + // Name: to.Ptr("grhdqtqnkqmu"), + // Type: to.Ptr("gapeymltyvlqlvpgdgfxidkkd"), + // SystemData: &armneonpostgres.SystemData{ + // CreatedBy: to.Ptr("qfhekdgpvdtqcohjhvlyhzd"), + // CreatedByType: to.Ptr(armneonpostgres.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-30T15:12:24.902Z"); return t}()), + // LastModifiedBy: to.Ptr("dqsjroejrtucfjyqcoonpdopfaa"), + // LastModifiedByType: to.Ptr(armneonpostgres.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-30T15:12:24.902Z"); return t}()), + // }, + // }, + // }, + // NextLink: to.Ptr("https://microsoft.com/a"), + // }, + // } + } +} + +// Generated from example definition: 2024-08-01-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 := armneonpostgres.NewClientFactory("1178323D-8270-4757-B639-D528B6266487", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewOrganizationsClient().BeginUpdate(ctx, "rgneon", "eRY-J_:", armneonpostgres.OrganizationResource{ + Properties: &armneonpostgres.OrganizationProperties{ + UserDetails: &armneonpostgres.UserDetails{ + FirstName: to.Ptr("buwwe"), + LastName: to.Ptr("escynjpynkoox"), + EmailAddress: to.Ptr("3i_%@w8-y.H-p.tvj.dG"), + Upn: to.Ptr("fwedjamgwwrotcjaucuzdwycfjdqn"), + PhoneNumber: to.Ptr("dlrqoowumy"), + }, + CompanyDetails: &armneonpostgres.CompanyDetails{ + CompanyName: to.Ptr("uxn"), + Country: to.Ptr("lpajqzptqchuko"), + OfficeAddress: to.Ptr("chpkrlpmfslmawgunjxdllzcrctykq"), + BusinessPhone: to.Ptr("hbeb"), + Domain: to.Ptr("krjldeakhwiepvs"), + NumberOfEmployees: to.Ptr[int64](23), + }, + PartnerOrganizationProperties: &armneonpostgres.PartnerOrganizationProperties{ + OrganizationID: to.Ptr("njyoqflcmfwzfsqe"), + OrganizationName: to.Ptr("J:.._3P"), + SingleSignOnProperties: &armneonpostgres.SingleSignOnProperties{ + SingleSignOnState: to.Ptr(armneonpostgres.SingleSignOnStatesInitial), + EnterpriseAppID: to.Ptr("fpibacregjfncfdsojs"), + SingleSignOnURL: to.Ptr("tmojh"), + AADDomains: []*string{ + to.Ptr("kndszgrwzbvvlssvkej"), + }, + }, + }, + }, + Tags: map[string]*string{ + "key8990": to.Ptr("wuvaontoqyttxtikvvahdegcfdfkz"), + }, + }, 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 = armneonpostgres.OrganizationsClientUpdateResponse{ + // OrganizationResource: &armneonpostgres.OrganizationResource{ + // Properties: &armneonpostgres.OrganizationProperties{ + // MarketplaceDetails: &armneonpostgres.MarketplaceDetails{ + // SubscriptionID: to.Ptr("yxmkfivp"), + // SubscriptionStatus: to.Ptr(armneonpostgres.MarketplaceSubscriptionStatusPendingFulfillmentStart), + // OfferDetails: &armneonpostgres.OfferDetails{ + // PublisherID: to.Ptr("hporaxnopmolttlnkbarw"), + // OfferID: to.Ptr("bunyeeupoedueofwrzej"), + // PlanID: to.Ptr("nlbfiwtslenfwek"), + // PlanName: to.Ptr("ljbmgpkfqklaufacbpml"), + // TermUnit: to.Ptr("qbcq"), + // TermID: to.Ptr("aedlchikwqckuploswthvshe"), + // }, + // }, + // UserDetails: &armneonpostgres.UserDetails{ + // FirstName: to.Ptr("buwwe"), + // LastName: to.Ptr("escynjpynkoox"), + // EmailAddress: to.Ptr("3i_%@w8-y.H-p.tvj.dG"), + // Upn: to.Ptr("fwedjamgwwrotcjaucuzdwycfjdqn"), + // PhoneNumber: to.Ptr("dlrqoowumy"), + // }, + // CompanyDetails: &armneonpostgres.CompanyDetails{ + // CompanyName: to.Ptr("uxn"), + // Country: to.Ptr("lpajqzptqchuko"), + // OfficeAddress: to.Ptr("chpkrlpmfslmawgunjxdllzcrctykq"), + // BusinessPhone: to.Ptr("hbeb"), + // Domain: to.Ptr("krjldeakhwiepvs"), + // NumberOfEmployees: to.Ptr[int64](23), + // }, + // ProvisioningState: to.Ptr(armneonpostgres.ResourceProvisioningStateSucceeded), + // PartnerOrganizationProperties: &armneonpostgres.PartnerOrganizationProperties{ + // OrganizationID: to.Ptr("njyoqflcmfwzfsqe"), + // OrganizationName: to.Ptr("J:.._3P"), + // SingleSignOnProperties: &armneonpostgres.SingleSignOnProperties{ + // SingleSignOnState: to.Ptr(armneonpostgres.SingleSignOnStatesInitial), + // EnterpriseAppID: to.Ptr("fpibacregjfncfdsojs"), + // SingleSignOnURL: to.Ptr("tmojh"), + // AADDomains: []*string{ + // to.Ptr("kndszgrwzbvvlssvkej"), + // }, + // }, + // }, + // }, + // Tags: map[string]*string{ + // "key2099": to.Ptr("omjjymaqtrqzksxszhzgyl"), + // }, + // Location: to.Ptr("upxxgikyqrbnv"), + // ID: to.Ptr("/subscriptions/1178323D-8270-4757-B639-D528B6266487/resourceGroups/rgneon/providers/Microsoft.Neon/organizations/eRY-J_:"), + // Name: to.Ptr("grhdqtqnkqmu"), + // Type: to.Ptr("gapeymltyvlqlvpgdgfxidkkd"), + // SystemData: &armneonpostgres.SystemData{ + // CreatedBy: to.Ptr("qfhekdgpvdtqcohjhvlyhzd"), + // CreatedByType: to.Ptr(armneonpostgres.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-30T15:12:24.902Z"); return t}()), + // LastModifiedBy: to.Ptr("dqsjroejrtucfjyqcoonpdopfaa"), + // LastModifiedByType: to.Ptr(armneonpostgres.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-07-30T15:12:24.902Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/neonpostgres/armneonpostgres/responses.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/responses.go new file mode 100644 index 000000000000..1eacfafa5069 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/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 armneonpostgres + +// 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 { + // Organization Resource by Neon + 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 { + // Organization Resource by Neon + 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 { + // Organization Resource by Neon + OrganizationResource +} diff --git a/sdk/resourcemanager/neonpostgres/armneonpostgres/time_rfc3339.go b/sdk/resourcemanager/neonpostgres/armneonpostgres/time_rfc3339.go new file mode 100644 index 000000000000..302675535299 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/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 armneonpostgres + +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/neonpostgres/armneonpostgres/tsp-location.yaml b/sdk/resourcemanager/neonpostgres/armneonpostgres/tsp-location.yaml new file mode 100644 index 000000000000..471fdd5cc1b4 --- /dev/null +++ b/sdk/resourcemanager/neonpostgres/armneonpostgres/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/liftrneon/Neon.Postgres.Management +commit: d477c7caa09bf82e22c419be0a99d170552b5892 +repo: Azure/azure-rest-api-specs +additionalDirectories: